# HG changeset patch # User Lucas Thompson # Date 1480506088 0 # Node ID 7e155ee93db3e75c1eb258f02dfd0cf0c5f85637 # Parent 6fb6c04878ecec536204da7184470a2027a6c750 Quick and dirty page scrolling. diff -r 6fb6c04878ec -r 7e155ee93db3 src/app/waveform/waveform.component.ts --- 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();