Created
December 8, 2017 09:01
-
-
Save wakamsha/67e7f8102e41a799ce5eb20a706608c5 to your computer and use it in GitHub Desktop.
Easing 関数
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
// Predefine list of available timing functions | |
// If you need more, tween js is full of great examples | |
// https://github.com/tweenjs/tween.js/blob/master/src/Tween.js#L421-L737 | |
const easings = { | |
linear(t) { | |
return t; | |
}, | |
easeInQuad(t) { | |
return t * t; | |
}, | |
easeOutQuad(t) { | |
return t * (2 - t); | |
}, | |
easeInOutQuad(t) { | |
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t; | |
}, | |
easeInCubic(t) { | |
return t * t * t; | |
}, | |
easeOutCubic(t) { | |
return (--t) * t * t + 1; | |
}, | |
easeInOutCubic(t) { | |
return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1; | |
}, | |
easeInQuart(t) { | |
return t * t * t * t; | |
}, | |
easeOutQuart(t) { | |
return 1 - (--t) * t * t * t; | |
}, | |
easeInOutQuart(t) { | |
return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t; | |
}, | |
easeInQuint(t) { | |
return t * t * t * t * t; | |
}, | |
easeOutQuint(t) { | |
return 1 + (--t) * t * t * t * t; | |
}, | |
easeInOutQuint(t) { | |
return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment