howler.js icon indicating copy to clipboard operation
howler.js copied to clipboard

[2.0 Beta] Attempting to fade out sound while fading in the sound fails

Open DFortun81 opened this issue 10 years ago • 1 comments

If you attempt to fade out a sound that is still fading in, the operation will enter an infinite callback loop and fail to fade in or out from that point forward until the page is reloaded.

To fix this, inside of the 'fade' method, check to see if sound._interval exists already, if it does, I clear it out prior to reassigning the value. For best performance, do not delete the _interval element under this condition as removing elements from a dynamic object table can be slow especially if they immediately get reassigned afterwards.

          var vol = from;
          if(sound._interval) clearInterval(sound._interval); // added this
          sound._interval = setInterval(function(id, sound) {

DFortun81 avatar Dec 14 '15 17:12 DFortun81

The interval already gets cleared whens tarting a new fade and I'm unable to reproduce any issues with this. If you can create a reproducible test case I'll reopen this.

goldfire avatar Dec 21 '15 22:12 goldfire