Skip to content

Commit

Permalink
Callbacks will no longer accidentally trigger on steps when animating…
Browse files Browse the repository at this point in the history
… past them
  • Loading branch information
JoelBesada committed Feb 19, 2012
1 parent 6e9724a commit 210b86f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions script/jquery.scrollpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
name: settings.name
});
}
return;
return this;
}

for( ; i <= steps; i++ ) {
Expand Down Expand Up @@ -456,9 +456,10 @@
startStep = step,
currentFrame = 0,
easedSteps,
nextStep,
interval = setInterval(function() {
easedSteps = Math.round( ($.easing[easing] || $.easing.swing)( ++currentFrame / frames, duration / frames * currentFrame, 0, steps, duration) );
scrollToStep( wrapStep( startStep + easedSteps ), true );
nextStep = wrapStep( startStep + easedSteps);
if (currentFrame === frames) {
clearInterval( interval );
if ( typeof easing === "function" ) {
Expand All @@ -468,6 +469,7 @@
}
isAnimating = false;
}
scrollToStep( nextStep, true );
}, duration / frames);
}

Expand All @@ -478,7 +480,7 @@

element.css( makeCSS( pathList[ stepParam ] ) );
if( scrollHandle ) scrollHandle.css( "top", stepParam / (pathList.length - 1 ) * ( scrollBar.height() - scrollHandle.height() ) + "px" );
if ( cb && stepParam !== step ) cb();
if ( cb && stepParam !== step && !isAnimating ) cb();
step = stepParam;
}

Expand Down

0 comments on commit 210b86f

Please sign in to comment.