changeset 33:7e155ee93db3

Quick and dirty page scrolling.
author Lucas Thompson <dev@lucas.im>
date Wed, 30 Nov 2016 11:41:28 +0000
parents 6fb6c04878ec
children 35350929f23b
files src/app/waveform/waveform.component.ts
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts	Wed Nov 30 10:21:49 2016 +0000
+++ b/src/app/waveform/waveform.component.ts	Wed Nov 30 11:41:28 2016 +0000
@@ -3,7 +3,7 @@
 } from '@angular/core';
 import {AudioPlayerService} from "../services/audio-player.service";
 
-declare var wavesUI: any; // TODO non-global app scope import
+declare let wavesUI: any; // TODO non-global app scope import
 type Timeline = any; // TODO what type actually is it.. start a .d.ts for waves-ui?
 
 @Component({
@@ -43,6 +43,7 @@
     const width: number = track.getBoundingClientRect().width;
     const pixelsPerSecond = width / duration;
     const timeline = new wavesUI.core.Timeline(pixelsPerSecond, width);
+    timeline.timeContext.offset = 0.5 * timeline.timeContext.visibleDuration;
     timeline.createTrack(track, height, 'main');
 
     // time axis
@@ -77,6 +78,11 @@
       const updateSeekingCursor = () => {
         cursorLayer.currentPosition = this.audioService.getCurrentTime();
         cursorLayer.update();
+        if (timeline.timeContext.offset + this.audioService.getCurrentTime() >= timeline.timeContext.visibleDuration)
+          timeline.timeContext.offset -= timeline.timeContext.visibleDuration;
+        if (-this.audioService.getCurrentTime() > timeline.timeContext.offset)
+          timeline.timeContext.offset += timeline.timeContext.visibleDuration;
+        timeline.tracks.update();
         requestAnimationFrame(updateSeekingCursor);
       };
       updateSeekingCursor();