diff src/app/waveform/waveform.component.ts @ 83:57d8600f86ab

Fix initial offset waveform when loading audio file, having it start in the centre of the layer
author Lucas Thompson <dev@lucas.im>
date Thu, 23 Feb 2017 15:44:47 +0000
parents 13955649f5af
children a335107e5246
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts	Thu Feb 23 15:42:59 2017 +0000
+++ b/src/app/waveform/waveform.component.ts	Thu Feb 23 15:44:47 2017 +0000
@@ -107,7 +107,6 @@
     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');
     return timeline;
   }
@@ -139,6 +138,7 @@
     } else {
       this.timeline = this.renderTimeline(buffer.duration)
     }
+    this.timeline.timeContext.offset = 0.5 * this.timeline.timeContext.visibleDuration;
     // time axis
     const timeAxis = new wavesUI.helpers.TimeAxisLayer({
       height: height,