Skip to content

Commit e580f8e

Browse files
committed
Make sure fade to/from are within 0-1 bounds
1 parent f58dab1 commit e580f8e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/howler.core.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,8 +1290,8 @@
12901290
}
12911291

12921292
// Make sure the to/from/len values are numbers.
1293-
from = parseFloat(from);
1294-
to = parseFloat(to);
1293+
from = Math.min(Math.max(0, parseFloat(from)), 1);
1294+
to = Math.min(Math.max(0, parseFloat(to)), 1);
12951295
len = parseFloat(len);
12961296

12971297
// Set the volume to the start position.
@@ -1354,7 +1354,7 @@
13541354
vol += diff * tick;
13551355

13561356
// Make sure the volume is in the right bounds.
1357-
if(diff < 0) {
1357+
if (diff < 0) {
13581358
vol = Math.max(to, vol);
13591359
} else {
13601360
vol = Math.min(to, vol);
@@ -1380,7 +1380,7 @@
13801380
clearInterval(sound._interval);
13811381
sound._interval = null;
13821382
sound._fadeTo = null;
1383-
self.volume(to, sound._id); //does this line has a sense now?
1383+
self.volume(to, sound._id);
13841384
self._emit('fade', sound._id);
13851385
}
13861386
}, stepLen);

0 commit comments

Comments
 (0)