Wavesurfer.js: Temporarily disable region-click events

Created on 30 Mar 2017  路  2Comments  路  Source: katspaugh/wavesurfer.js

Thanks for this great library. I'm using the regions plugin, and I've added a button on the region itself to play it, however, immediately after my callback, the callback of 'region-click' is fired. Is there a way to temporarily disable click events on a region?
```
wavesurfer.on('region-created', function(reg) {
const regElem = $('region[data-id="' + reg['id'] + '"]')[0];
const playRegion = regElem.appendChild(document.createElement('i'));
playRegion.className = "glyphicon glyphicon-play";
playRegion.addEventListener('click', function() {
wavesurfer.play(reg['start'], reg['end']);
});
}

question

Most helpful comment

@dimidd you can do the following

wavesurfer.on('region-click', function(e) {
    e.stopImmediatePropagation();
    // other code here
});

All 2 comments

@dimidd you can do the following

wavesurfer.on('region-click', function(e) {
    e.stopImmediatePropagation();
    // other code here
});

Works great, thanks!

Was this page helpful?
0 / 5 - 0 ratings