Skip to content

Commit eac6f97

Browse files
committed
Improve fading when short times are used
Fixes #621
1 parent f899ca9 commit eac6f97

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/howler.core.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,12 @@
10151015
var steps = diff / 0.01;
10161016
var stepLen = (steps > 0) ? len / steps : len;
10171017

1018+
// Since browsers clamp timeouts to 4ms, we need to clamp our steps to that too.
1019+
if (stepLen < 4) {
1020+
steps = Math.ceil(steps / (4 / stepLen));
1021+
stepLen = 4;
1022+
}
1023+
10181024
// If the sound hasn't loaded, add it to the load queue to fade when capable.
10191025
if (self._state !== 'loaded') {
10201026
self._queue.push({

0 commit comments

Comments
 (0)