Skip to content

Commit

Permalink
Make sure fade to/from are within 0-1 bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed May 17, 2020
1 parent f58dab1 commit e580f8e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/howler.core.js
Expand Up @@ -1290,8 +1290,8 @@
}

// Make sure the to/from/len values are numbers.
from = parseFloat(from);
to = parseFloat(to);
from = Math.min(Math.max(0, parseFloat(from)), 1);
to = Math.min(Math.max(0, parseFloat(to)), 1);
len = parseFloat(len);

// Set the volume to the start position.
Expand Down Expand Up @@ -1354,7 +1354,7 @@
vol += diff * tick;

// Make sure the volume is in the right bounds.
if(diff < 0) {
if (diff < 0) {
vol = Math.max(to, vol);
} else {
vol = Math.min(to, vol);
Expand All @@ -1380,7 +1380,7 @@
clearInterval(sound._interval);
sound._interval = null;
sound._fadeTo = null;
self.volume(to, sound._id); //does this line has a sense now?
self.volume(to, sound._id);
self._emit('fade', sound._id);
}
}, stepLen);
Expand Down

0 comments on commit e580f8e

Please sign in to comment.