a2de693906
This CL adds a helper class for commonly used helper methods inside web components, decreasing the amount of duplicated code across the app. Bug: v8:10667, v8:10644 Change-Id: I754396a9b3598d0930a82fc487857e946bfd3805 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2299359 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Zeynep Cankara <zcankara@google.com> Cr-Commit-Position: refs/heads/master@{#68899}
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
import {defineCustomElement, V8CustomElement} from './helper.mjs';
|
|
|
|
defineCustomElement('timeline-panel', (templateText) =>
|
|
class TimelinePanel extends V8CustomElement {
|
|
constructor() {
|
|
super(templateText);
|
|
this.timelineOverview.addEventListener(
|
|
'mousemove', e => this.handleTimelineIndicatorMove(e));
|
|
}
|
|
|
|
get timelineOverview() {
|
|
return this.$('#timelineOverview');
|
|
}
|
|
|
|
get timelineOverviewIndicator() {
|
|
return this.$('#timelineOverviewIndicator');
|
|
}
|
|
|
|
get timelineCanvas() {
|
|
return this.$('#timelineCanvas');
|
|
}
|
|
|
|
get timelineChunks() {
|
|
return this.$('#timelineChunks');
|
|
}
|
|
|
|
get timeline() {
|
|
return this.$('#timeline');
|
|
}
|
|
|
|
handleTimelineIndicatorMove(event) {
|
|
if (event.buttons == 0) return;
|
|
let timelineTotalWidth = this.timelineCanvas.offsetWidth;
|
|
let factor = this.timelineOverview.offsetWidth / timelineTotalWidth;
|
|
this.timeline.scrollLeft += event.movementX / factor;
|
|
}
|
|
|
|
});
|