@compositive/foundation
Version:
Compositive framework foundation package.
32 lines (30 loc) • 1.57 kB
JavaScript
/** No easing, no acceleration */
const linear = (t) => t;
/** Accelerating from zero velocity */
const easeInQuad = (t) => t * t;
/** Decelerating to zero velocity */
const easeOutQuad = (t) => t * (2 - t);
/** Acceleration until halfway, then deceleration */
const easeInOutQuad = (t) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
/** Accelerating from zero velocity */
const easeInCubic = (t) => t ** 3;
/** Decelerating to zero velocity */
const easeOutCubic = (t) => (t - 1) ** 3 + 1;
/** Acceleration until halfway, then deceleration */
const easeInOutCubic = (t) => t < 0.5 ? 4 * t ** 3 : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
/** Accelerating from zero velocity */
const easeInQuart = (t) => t ** 4;
/** Decelerating to zero velocity */
const easeOutQuart = (t) => 1 - (t - 1) ** 4;
/** Acceleration until halfway, then deceleration */
const easeInOutQuart = (t) => t < 0.5 ? 8 * t ** 4 : 1 - 8 * (t - 1) ** 4;
/** Accelerating from zero velocity */
const easeInQuint = (t) => t ** 5;
/** Decelerating to zero velocity */
const easeOutQuint = (t) => 1 + (t - 1) ** 5;
/** Acceleration until halfway, then deceleration */
const easeInOutQuint = (t) => t < 0.5 ? 16 * t ** 5 : 1 + 16 * (t - 1) ** 5;
/** Hyperbolic tangent, normalized to be bounded in the interval [0, 1] */
const tanh = (t) => Math.tanh(t * 8 - 4) / 2 + 0.5;
export { easeInCubic, easeInOutCubic, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInQuad, easeInQuart, easeInQuint, easeOutCubic, easeOutQuad, easeOutQuart, easeOutQuint, linear, tanh };
//# sourceMappingURL=index.js.map