changeset 154:0b1743589281

Seeking with click on desktop. Remove old tap gesture code for mobile, as this should provide the same functionality.
author Lucas Thompson <dev@lucas.im>
date Tue, 21 Mar 2017 14:01:28 +0000
parents dd02ef0d3c93
children 53ddfd792844
files src/app/waveform/waveform.component.html src/app/waveform/waveform.component.ts
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.html	Tue Mar 21 13:57:08 2017 +0000
+++ b/src/app/waveform/waveform.component.html	Tue Mar 21 14:01:28 2017 +0000
@@ -1,1 +1,1 @@
-<div #track class="track"></div>
+<div #track class="track" (click)="seek($event.clientX)"></div>
--- a/src/app/waveform/waveform.component.ts	Tue Mar 21 13:57:08 2017 +0000
+++ b/src/app/waveform/waveform.component.ts	Tue Mar 21 14:01:28 2017 +0000
@@ -344,11 +344,6 @@
         this.timeline.timeContext.offset += newCenterTime - lastCenterTime;
         this.timeline.tracks.update();
       };
-      const seek = (ev) => {
-        this.audioService.seekTo(
-          this.timeline.timeContext.timeToPixel.invert(ev.center.x) - this.timeline.timeContext.offset
-        );
-      };
       hammertime.get('pinch').set({ enable: true });
       hammertime.on('panstart', () => {
         this.offsetAtPanStart = this.timeline.timeContext.offset;
@@ -370,7 +365,6 @@
       hammertime.on('pinchend', () => {
         zoomGestureJustEnded = true;
       });
-      hammertime.on('tap', seek);
     }
 
     this.animate();
@@ -641,4 +635,13 @@
     this.playingStateSubscription.unsubscribe();
     this.seekedSubscription.unsubscribe();
   }
+
+  seek(x: number): void {
+    if (this.timeline) {
+      const timeContext: any = this.timeline.timeContext;
+      this.audioService.seekTo(
+        timeContext.timeToPixel.invert(x)- timeContext.offset
+      );
+    }
+  }
 }