howler.js
howler.js copied to clipboard
Canceling a running (slow) fade operation
While https://github.com/goldfire/howler.js/issues/363 addresses the situation of a fade-in after a fade-out I still would like to have the possibility to cancel a current fade operation.
My scenario is this: I have a running, slow fade-out, but then, after a user input, I would like to stop the sound altogether.
Now this works, the sound is silent, but the fade operation is still running. When, after a short time, the sound should play again, before the fade operation actually ends, the incoming play operation is then immediately fading with the "old" fade.
There should be a possibility to cancel all pending fade operation, either as separate call or as (optional) part of the existing stop operation.
I have found out, that starting a new fade operation cancels the previous one, so I can do:
const currentVolume = this.sound.volume();
this.sound.fade(currentVolume, 0, 0);
to immediately fade to zero, effectively cancel any previous fade.
This possibility should be better addressed in the docs or even offered as it's own method.