comparison 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
comparison
equal deleted inserted replaced
156:0d6acf5fdd41 157:3f54066a0e01
54 private isPlaying: boolean; 54 private isPlaying: boolean;
55 private offsetAtPanStart: number; 55 private offsetAtPanStart: number;
56 private initialZoom: number; 56 private initialZoom: number;
57 private initialDistance: number; 57 private initialDistance: number;
58 private zoomOnMouseDown: number; 58 private zoomOnMouseDown: number;
59 private offsetOnMouseDown: number;
59 60
60 constructor(private audioService: AudioPlayerService, 61 constructor(private audioService: AudioPlayerService,
61 private piperService: FeatureExtractionService, 62 private piperService: FeatureExtractionService,
62 public ngZone: NgZone) { 63 public ngZone: NgZone) {
63 this._audioBuffer = undefined; 64 this._audioBuffer = undefined;
637 this.seekedSubscription.unsubscribe(); 638 this.seekedSubscription.unsubscribe();
638 } 639 }
639 640
640 seekStart(): void { 641 seekStart(): void {
641 this.zoomOnMouseDown = this.timeline.timeContext.zoom; 642 this.zoomOnMouseDown = this.timeline.timeContext.zoom;
643 this.offsetOnMouseDown = this.timeline.timeContext.offset;
642 } 644 }
643 645
644 seekEnd(x: number): void { 646 seekEnd(x: number): void {
645 if (this.zoomOnMouseDown === this.timeline.timeContext.zoom) { 647 const hasSameZoom: boolean = this.zoomOnMouseDown ===
648 this.timeline.timeContext.zoom;
649 const hasSameOffset: boolean = this.offsetOnMouseDown ===
650 this.timeline.timeContext.offset;
651 if (hasSameZoom && hasSameOffset) {
646 this.seek(x); 652 this.seek(x);
647 } 653 }
648 } 654 }
649 655
650 seek(x: number): void { 656 seek(x: number): void {