Created
August 3, 2017 03:37
-
-
Save iccir/0c880192128c91f7cfed29129dea8a3d to your computer and use it in GitHub Desktop.
easing.js
This file contains hidden or 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
function ease(p) { | |
p *= 5; | |
if (p < 1) { | |
return (-0.9 * Math.cos(p * (Math.PI / 2)) + 0.9 + (0.1 * p)) * 0.3; | |
} else { | |
p = ((p - 1) / 4); | |
var p1 = p - 1; | |
return (((p1 * p1 * p1 + 1) * 0.9) + p * 0.1) * 0.7 + 0.3; | |
} | |
} | |
$.ease = ease; | |
// Approximate to cubic-bezier(0.42, 0.0, 1.0, 1.0) | |
function easeIn(p) | |
{ | |
return -0.9 * Math.cos(p * (Math.PI / 2)) + 0.9 + (0.1 * p); | |
} | |
$.easeIn = easeIn; | |
// Approximate to cubic-bezier(0.0, 0.0, 0.58, 1.0). | |
function easeOut(p) | |
{ | |
return (Math.sin(p * (Math.PI / 2)) * 0.9) + (0.1 * p); | |
} | |
$.easeOut = easeOut; | |
// Approximate to cubic-bezier(0.42, 0.0, 0.58, 1.0) | |
function easeInOut(p) | |
{ | |
return -0.5 * (Math.cos(Math.PI * p) - 1); | |
} | |
$.easeInOut = easeInOut; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment