Skip to content

Instantly share code, notes, and snippets.

@tbusser
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbusser/4a72cb3976c729606083 to your computer and use it in GitHub Desktop.
Save tbusser/4a72cb3976c729606083 to your computer and use it in GitHub Desktop.
JavaScript method, sans jQuery, for a cubic ease-out function
/*
* Robert Penner's algorithm for an cubic ease out function
* @param {Number} currentIteration The current iteration of the animation, on each subsequent
* call this should be increased by 1
* @param {Number} startValue The start value, this should be a constant throughout the
* animation.
* @param {Number} changeInValue The difference between the start value and the desired end value
* @param {Number} totalIterations The number of iterations over which we want to go from start
* to end
* @return {Number} The value for the current step in the animation
*/
function easeOutCubic (currentIteration, startValue, changeInValue, totalIterations) {
return changeInValue * (Math.pow(currentIteration / totalIterations - 1, 3) + 1) + startValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment