UNPKG

@helpwave/hightide

Version:

helpwave's component and theming library

36 lines (35 loc) 889 B
// src/util/math.ts var clamp = (value, min = 0, max = 1) => { return Math.min(Math.max(value, min), max); }; // src/util/easeFunctions.ts var EaseFunctions = class _EaseFunctions { static cubicBezierGeneric(x1, y1, x2, y2) { const cx = 3 * x1; const bx = 3 * (x2 - x1) - cx; const ax = 1 - cx - bx; const cy = 3 * y1; const by = 3 * (y2 - y1) - cy; const ay = 1 - cy - by; const x = (t) => ((ax * t + bx) * t + cx) * t; const y = (t) => ((ay * t + by) * t + cy) * t; return { x, y }; } static cubicBezier(x1, y1, x2, y2) { const { y } = _EaseFunctions.cubicBezierGeneric(x1, y1, x2, y2); return (t) => { t = clamp(t); return y(t); }; } static easeInEaseOut(t) { return _EaseFunctions.cubicBezier(0.65, 0, 0.35, 1)(t); } }; export { EaseFunctions }; //# sourceMappingURL=easeFunctions.mjs.map