diff src/app/waveform/waveform.component.ts @ 113:d43e2392193c

Basic attempt at correcting disorientating behaviour when concluding a pinch gesture, causing the timeline to jump to the position of a remaining finger. Untested on device yet.
author Lucas Thompson <dev@lucas.im>
date Mon, 13 Mar 2017 14:49:04 +0000
parents 689c1bfe8e68
children b8627a18c72d
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts	Sun Mar 12 23:10:05 2017 +0000
+++ b/src/app/waveform/waveform.component.ts	Mon Mar 13 14:49:04 2017 +0000
@@ -261,6 +261,8 @@
         y: number;
       }
 
+      let zoomGestureJustEnded: boolean = false;
+
       const pixelToExponent: Function = wavesUI.utils.scales.linear()
         .domain([0, 100]) // 100px => factor 2
         .range([0, 1]);
@@ -273,6 +275,11 @@
 
       const hammertime = new Hammer(this.trackDiv.nativeElement);
       const scroll = (ev) => {
+        if (zoomGestureJustEnded) {
+          zoomGestureJustEnded = false;
+          console.log("Skip this event: likely a single touch dangling from pinch");
+          return;
+        }
         this.timeline.timeContext.offset = this.offsetAtPanStart +
           this.timeline.timeContext.timeToPixel.invert(ev.deltaX);
         this.timeline.tracks.update();
@@ -327,6 +334,9 @@
         });
       });
       hammertime.on('pinch', zoom);
+      hammertime.on('pinchend', () => {
+        zoomGestureJustEnded = true;
+      });
       hammertime.on('tap', seek);
     }