UNPKG

@helpwave/hightide

Version:

helpwave's component and theming library

62 lines (59 loc) 1.94 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/util/easeFunctions.ts var easeFunctions_exports = {}; __export(easeFunctions_exports, { EaseFunctions: () => EaseFunctions }); module.exports = __toCommonJS(easeFunctions_exports); // 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); } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { EaseFunctions }); //# sourceMappingURL=easeFunctions.js.map