Skip to content

Commit

Permalink
add debounce to resize/orientationchange event for minimap plugin (#987)
Browse files Browse the repository at this point in the history
* add debounce to resize event
* add orientationchange event
  • Loading branch information
entonbiba authored and thijstriemstra committed Feb 12, 2017
1 parent 02b8a7d commit 1f0887e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugin/wavesurfer.minimap.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ WaveSurfer.Minimap = WaveSurfer.util.extend({}, WaveSurfer.Drawer, WaveSurfer.Dr
}

var prevWidth = 0;
var onResize = function () {
var onResize = this.wavesurfer.util.debounce(function () {
if (prevWidth != my.wrapper.clientWidth) {
prevWidth = my.wrapper.clientWidth;
my.render();
my.progress(my.wavesurfer.backend.getPlayedPercents());
}
};
}, 100);
window.addEventListener('resize', onResize, true);
window.addEventListener('orientationchange', onResize, true);

this.wavesurfer.on('destroy', function () {
my.destroy.bind(this);
Expand Down

0 comments on commit 1f0887e

Please sign in to comment.