File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 1170
1170
var diff = Math . abs ( from - to ) ;
1171
1171
var steps = diff / 0.01 ;
1172
1172
var stepLen = ( steps > 0 ) ? len / steps : len ;
1173
+ var stepVol = diff / steps ;
1173
1174
1174
1175
// Since browsers clamp timeouts to 4ms, we need to clamp our steps to that too.
1175
1176
if ( stepLen < 4 ) {
1176
- steps = Math . ceil ( steps / ( 4 / stepLen ) ) ;
1177
+ steps = Math . ceil ( steps * stepLen * 0.25 ) ;
1177
1178
stepLen = 4 ;
1179
+ stepVol = diff / steps ;
1178
1180
}
1179
1181
1180
1182
// Store the value being faded to.
1184
1186
sound . _interval = setInterval ( function ( ) {
1185
1187
// Update the volume amount, but only if the volume should change.
1186
1188
if ( steps > 0 ) {
1187
- vol += ( dir === 'in' ? 0.01 : - 0.01 ) ;
1189
+ vol += ( dir === 'in' ? stepVol : - stepVol ) ;
1188
1190
}
1189
1191
1190
1192
// Make sure the volume is in the right bounds.
You can’t perform that action at this time.
0 commit comments