Skip to content

Instantly share code, notes, and snippets.

@stephanbogner
Created February 17, 2019 20:30
Show Gist options
  • Save stephanbogner/782c63a2c714db6cd005d9e354633aa6 to your computer and use it in GitHub Desktop.
Save stephanbogner/782c63a2c714db6cd005d9e354633aa6 to your computer and use it in GitHub Desktop.
Easing function
// Different structure of an easing formula from https://github.com/danro/jquery-easing/blob/master/jquery.easing.js for better understanding
function easeInOutQuad (currentTime, duration, fromValue, toValue) {
var t = currentTime;
var b = fromValue;
var c = toValue - fromValue;
var d = duration;
if ((t/=d/2) < 1) return c/2*t*t + b;
return -c/2 * ((--t)*(t-2) - 1) + b;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment