Removing touche events when unlocking only after promise returned from resume method gets resolved

This commit is contained in:
Pavle Goloskokovic 2017-11-30 14:41:46 +01:00
parent 5f21646e6c
commit 9ec1fb4cd1

View file

@ -67,9 +67,10 @@ var WebAudioSoundManager = new Class({
var _this = this;
if (this.context.state === 'suspended') {
var unlock_1 = function () {
document.body.removeEventListener('touchstart', unlock_1);
document.body.removeEventListener('touchend', unlock_1);
_this.context.resume();
_this.context.resume().then(function () {
document.body.removeEventListener('touchstart', unlock_1);
document.body.removeEventListener('touchend', unlock_1);
});
};
document.body.addEventListener('touchstart', unlock_1, false);
document.body.addEventListener('touchend', unlock_1, false);