Skip to content

Commit

Permalink
timeline: re-render on zoom; resolve #825
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Dec 3, 2016
1 parent 0699fc7 commit 210f93f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example/zoom/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<script src="../../dist/wavesurfer.min.js"></script>

<script src="../../plugin/wavesurfer.regions.js"></script>
<script src="../../plugin/wavesurfer.timeline.js"></script>

<!-- Demo -->
<script src="main.js"></script>
Expand All @@ -37,6 +38,8 @@ <h1 itemprop="name">Zooming Feature Example</h1>
<!-- Here be the waveform -->
</div>

<div id="timeline"></div>

<div class="controls">
<div class="row">
<div class="col-sm-7">
Expand Down
4 changes: 4 additions & 0 deletions example/zoom/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ document.addEventListener('DOMContentLoaded', function () {
end: 100,
color: 'hsla(200, 50%, 70%, 0.1)'
});

// Init Timeline plugin
var timeline = Object.create(WaveSurfer.Timeline);
timeline.init({ wavesurfer: wavesurfer, container: '#timeline' });
});

// Zoom slider
Expand Down
2 changes: 2 additions & 0 deletions plugin/wavesurfer.timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ WaveSurfer.Timeline = {
}.bind(this));

this._onRedraw = wavesurfer.on('redraw', this.render.bind(this));
this._onZoom = wavesurfer.on('zoom', this.render.bind(this));
this._onDestroy = wavesurfer.on('destroy', this.destroy.bind(this));
},

destroy: function () {
// Unsubscribe from internal wavesurfer events
this._onRedraw.un();
this._onZoom.un();
this._onDestroy.un();

// Unsubscribe from external timeline events
Expand Down

0 comments on commit 210f93f

Please sign in to comment.