Skip to content

Commit c37975a

Browse files
authored
volume() is wrong after fade
After fade complete volume() returns 0 or 1 on short fades. And not strict value at long fades.
1 parent 8362b75 commit c37975a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/howler.core.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,8 +1216,11 @@
12161216
vol += diff * tick;
12171217

12181218
// Make sure the volume is in the right bounds.
1219-
vol = Math.max(0, vol);
1220-
vol = Math.min(1, vol);
1219+
if(diff < 0) {
1220+
vol = Math.max(to, vol);
1221+
} else {
1222+
vol = Math.min(to, vol);
1223+
}
12211224

12221225
// Round to within 2 decimal points.
12231226
vol = Math.round(vol * 100) / 100;
@@ -1239,7 +1242,7 @@
12391242
clearInterval(sound._interval);
12401243
sound._interval = null;
12411244
sound._fadeTo = null;
1242-
self.volume(to, sound._id);
1245+
self.volume(to, sound._id); //does this line has a sense now?
12431246
self._emit('fade', sound._id);
12441247
}
12451248
}, stepLen);

0 commit comments

Comments
 (0)