# HG changeset patch # User Lucas Thompson # Date 1487864756 0 # Node ID a335107e5246d8453012e3d8daf106c9ab20554a # Parent 57d8600f86aba8453bddd00810778acbd4df50de Add tapping gesture for seeking diff -r 57d8600f86ab -r a335107e5246 src/app/waveform/waveform.component.ts --- a/src/app/waveform/waveform.component.ts Thu Feb 23 15:44:47 2017 +0000 +++ b/src/app/waveform/waveform.component.ts Thu Feb 23 15:45:56 2017 +0000 @@ -164,6 +164,7 @@ if ('ontouchstart' in window) { console.log('TOUCH!'); + const hammertime = new Hammer(this.trackDiv.nativeElement); const scroll = (ev) => { const sign = ev.direction === Hammer.DIRECTION_LEFT ? -1 : 1; let delta = this.timeline.timeContext.timeToPixel.invert(sign * ev.distance); @@ -173,6 +174,7 @@ this.timeline.timeContext.offset += delta; this.timeline.tracks.update(); }; + const zoom = (ev) => { const minZoom = this.timeline.state.minZoom; const maxZoom = this.timeline.state.maxZoom; @@ -181,11 +183,16 @@ this.timeline.timeContext.zoom = Math.min(Math.max(targetZoom, minZoom), maxZoom); this.timeline.tracks.update(); }; - const hammertime = new Hammer(this.trackDiv.nativeElement); + 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('panleft', scroll); hammertime.on('panright', scroll); hammertime.on('pinch', zoom); + hammertime.on('tap', seek); } this.animate();