Mercurial > hg > ugly-duckling
changeset 84:a335107e5246
Add tapping gesture for seeking
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Thu, 23 Feb 2017 15:45:56 +0000 |
parents | 57d8600f86ab |
children | 55fd4d504105 80b98dd50c88 |
files | src/app/waveform/waveform.component.ts |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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();