| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 UI.ChartViewport = class extends UI.VBox { | 7 UI.ChartViewport = class extends UI.VBox { |
| 8 constructor() { | 8 constructor() { |
| 9 super(true); | 9 super(true); |
| 10 | 10 |
| 11 this.viewportElement = this.contentElement.createChild('div', 'fill'); | 11 this.viewportElement = this.contentElement.createChild('div', 'fill'); |
| 12 this.viewportElement.addEventListener('mousewheel', this._onMouseWheel.bind(
this), false); | 12 this.viewportElement.addEventListener('mousewheel', this._onMouseWheel.bind(
this), false); |
| 13 this.viewportElement.addEventListener('keydown', this._handleZoomPanKeys.bin
d(this), false); | 13 this.viewportElement.addEventListener('keydown', this._handleZoomPanKeys.bin
d(this), false); |
| 14 | 14 |
| 15 UI.installInertialDragHandle( | 15 UI.installInertialDragHandle( |
| 16 this.viewportElement, this._startDragging.bind(this), this._dragging.bin
d(this), this._endDragging.bind(this), | 16 this.viewportElement, this._startDragging.bind(this), this._dragging.bin
d(this), this._endDragging.bind(this), |
| 17 '-webkit-grabbing', null); | 17 '-webkit-grabbing', null); |
| 18 UI.installDragHandle( | 18 UI.installDragHandle( |
| 19 this.viewportElement, this._startRangeSelection.bind(this), this._rangeS
electionDragging.bind(this), | 19 this.viewportElement, this._startRangeSelection.bind(this), this._rangeS
electionDragging.bind(this), |
| 20 this._endRangeSelection.bind(this), 'text', null); | 20 this._endRangeSelection.bind(this), 'text', null); |
| 21 | 21 |
| 22 this._alwaysShowVerticalScroll = false; |
| 22 this._vScrollElement = this.contentElement.createChild('div', 'flame-chart-v
-scroll'); | 23 this._vScrollElement = this.contentElement.createChild('div', 'flame-chart-v
-scroll'); |
| 23 this._vScrollContent = this._vScrollElement.createChild('div'); | 24 this._vScrollContent = this._vScrollElement.createChild('div'); |
| 24 this._vScrollElement.addEventListener('scroll', this._onScroll.bind(this), f
alse); | 25 this._vScrollElement.addEventListener('scroll', this._onScroll.bind(this), f
alse); |
| 25 | 26 |
| 26 this._selectionOverlay = this.contentElement.createChild('div', 'flame-chart
-selection-overlay hidden'); | 27 this._selectionOverlay = this.contentElement.createChild('div', 'flame-chart
-selection-overlay hidden'); |
| 27 this._selectedTimeSpanLabel = this._selectionOverlay.createChild('div', 'tim
e-span'); | 28 this._selectedTimeSpanLabel = this._selectionOverlay.createChild('div', 'tim
e-span'); |
| 28 | 29 |
| 29 this.reset(); | 30 this.reset(); |
| 30 } | 31 } |
| 31 | 32 |
| 33 alwaysShowVerticalScroll() { |
| 34 this._alwaysShowVerticalScroll = true; |
| 35 this._vScrollElement.classList.add('always-show-scrollbar'); |
| 36 } |
| 37 |
| 32 /** | 38 /** |
| 33 * @return {boolean} | 39 * @return {boolean} |
| 34 */ | 40 */ |
| 35 isDragging() { | 41 isDragging() { |
| 36 return this._isDragging; | 42 return this._isDragging; |
| 37 } | 43 } |
| 38 | 44 |
| 39 /** | 45 /** |
| 40 * @override | 46 * @override |
| 41 * @return {!Array<!Element>} | 47 * @return {!Array<!Element>} |
| 42 */ | 48 */ |
| 43 elementsToRestoreScrollPositionsFor() { | 49 elementsToRestoreScrollPositionsFor() { |
| 44 return [this._vScrollElement]; | 50 return [this._vScrollElement]; |
| 45 } | 51 } |
| 46 | 52 |
| 47 /** | 53 /** |
| 48 * @private | 54 * @private |
| 49 */ | 55 */ |
| 50 _updateScrollBar() { | 56 _updateScrollBar() { |
| 51 var showScroll = this._totalHeight > this._offsetHeight; | 57 const showScroll = this._alwaysShowVerticalScroll || this._totalHeight > thi
s._offsetHeight; |
| 52 if (this._vScrollElement.classList.contains('hidden') !== showScroll) | 58 if (this._vScrollElement.classList.contains('hidden') !== showScroll) |
| 53 return; | 59 return; |
| 54 this._vScrollElement.classList.toggle('hidden', !showScroll); | 60 this._vScrollElement.classList.toggle('hidden', !showScroll); |
| 55 this._updateContentElementSize(); | 61 this._updateContentElementSize(); |
| 56 } | 62 } |
| 57 | 63 |
| 58 /** | 64 /** |
| 59 * @override | 65 * @override |
| 60 */ | 66 */ |
| 61 onResize() { | 67 onResize() { |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 436 } |
| 431 this._cancelAnimation(); | 437 this._cancelAnimation(); |
| 432 this._cancelWindowTimesAnimation = UI.animateFunction( | 438 this._cancelWindowTimesAnimation = UI.animateFunction( |
| 433 this.element.window(), this._animateWindowTimes.bind(this), | 439 this.element.window(), this._animateWindowTimes.bind(this), |
| 434 [{from: this._timeWindowLeft, to: startTime}, {from: this._timeWindowRig
ht, to: endTime}], 5, | 440 [{from: this._timeWindowLeft, to: startTime}, {from: this._timeWindowRig
ht, to: endTime}], 5, |
| 435 this._animationCompleted.bind(this)); | 441 this._animationCompleted.bind(this)); |
| 436 this._pendingAnimationTimeLeft = startTime; | 442 this._pendingAnimationTimeLeft = startTime; |
| 437 this._pendingAnimationTimeRight = endTime; | 443 this._pendingAnimationTimeRight = endTime; |
| 438 } | 444 } |
| 439 }; | 445 }; |
| OLD | NEW |