Last active
August 29, 2015 14:07
-
-
Save tbusser/4a72cb3976c729606083 to your computer and use it in GitHub Desktop.
JavaScript method, sans jQuery, for a cubic ease-out function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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