Mercurial > hg > ugly-duckling
diff src/app/waveform/waveform.component.ts @ 157:3f54066a0e01
Prevent seeking when panning with mouse. There's still potential for this approach to go wrong, for both zooming and panning. During the duration of the click, if the offset or zoom are returned to the starting position, the mouse will seek to its current x position.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Tue, 21 Mar 2017 17:34:48 +0000 |
parents | 53ddfd792844 |
children | 28cb8530300b |
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts Tue Mar 21 14:34:00 2017 +0000 +++ b/src/app/waveform/waveform.component.ts Tue Mar 21 17:34:48 2017 +0000 @@ -56,6 +56,7 @@ private initialZoom: number; private initialDistance: number; private zoomOnMouseDown: number; + private offsetOnMouseDown: number; constructor(private audioService: AudioPlayerService, private piperService: FeatureExtractionService, @@ -639,10 +640,15 @@ seekStart(): void { this.zoomOnMouseDown = this.timeline.timeContext.zoom; + this.offsetOnMouseDown = this.timeline.timeContext.offset; } seekEnd(x: number): void { - if (this.zoomOnMouseDown === this.timeline.timeContext.zoom) { + const hasSameZoom: boolean = this.zoomOnMouseDown === + this.timeline.timeContext.zoom; + const hasSameOffset: boolean = this.offsetOnMouseDown === + this.timeline.timeContext.offset; + if (hasSameZoom && hasSameOffset) { this.seek(x); } }