Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

v4.2.0

Julian Garnier00106bec37f8
diff --git a/README.md b/README.md
index 527a2622..029ae2d5 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,12 @@
<img alt="GitHub Sponsors" src="https://img.shields.io/github/sponsors/juliangarnier?style=flat-square&logo=github">
</p>
+## Private Anime.js Discord
+
+Join us on Discord by following this link https://discord.gg/N2vjsQsq9w
+
+Please don't forget to **share your GitHub username** and **your Discord username** to [email protected] so I can give you the sponsor role!!
+
## Sponsors
Anime.js is 100% free and is only made possible with the help of our sponsors.
@@ -35,6 +41,12 @@ Help the project become sustainable by sponsoring us on <a target="_blank" href=
<img align="center" src="./assets/sponsors/ice-open-network-logomark-dark.png" width="250">
</picture>
</a>
+<a target="_blank" href="https://go.warp.dev/anime">
+ <picture>
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/sponsors/wrap-logomark.png">
+ <img align="center" src="./assets/sponsors/wrap-logomark-dark.png" width="250">
+ </picture>
+</a>
</p>
### Silver sponsors
@@ -46,7 +58,6 @@ Help the project become sustainable by sponsoring us on <a target="_blank" href=
<img align="center" src="./assets/sponsors/lambdatest-logomark-dark.png" width="150">
</picture>
</a>
-
<a target="_blank" href="https://inspatialapp.com/?ref=animejs">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./assets/sponsors/inspatial-logomark.png">
diff --git a/assets/sponsors/warp-logomark-dark.png b/assets/sponsors/warp-logomark-dark.png
new file mode 100644
index 00000000..65afe196
Binary files /dev/null and b/assets/sponsors/warp-logomark-dark.png differ
diff --git a/assets/sponsors/warp-logomark.png b/assets/sponsors/warp-logomark.png
new file mode 100644
index 00000000..f360fbe9
Binary files /dev/null and b/assets/sponsors/warp-logomark.png differ
diff --git a/babel.config.json b/babel.config.json
deleted file mode 100644
index 4bf4de14..00000000
--- a/babel.config.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "presets": [
- [
- "@babel/preset-env"
- // {
- // "browserslist": {
- // "safari": "9"
- // },
- // }
- ]
- ]
-}
diff --git a/dist/bundles/anime.esm.js b/dist/bundles/anime.esm.js
index f713d730..c9d9e038 100644
--- a/dist/bundles/anime.esm.js
+++ b/dist/bundles/anime.esm.js
@@ -17,6 +17,7 @@
* @property {Number|Boolean} [loop]
* @property {Boolean} [reversed]
* @property {Boolean} [alternate]
+ * @property {Boolean} [persist]
* @property {Boolean|ScrollObserver} [autoplay]
* @property {Number|FunctionValue} [duration]
* @property {Number|FunctionValue} [delay]
@@ -24,13 +25,13 @@
* @property {EasingParam} [ease]
* @property {'none'|'replace'|'blend'|compositionTypes} [composition]
* @property {(v: any) => any} [modifier]
- * @property {(tickable: Tickable) => void} [onBegin]
- * @property {(tickable: Tickable) => void} [onBeforeUpdate]
- * @property {(tickable: Tickable) => void} [onUpdate]
- * @property {(tickable: Tickable) => void} [onLoop]
- * @property {(tickable: Tickable) => void} [onPause]
- * @property {(tickable: Tickable) => void} [onComplete]
- * @property {(renderable: Renderable) => void} [onRender]
+ * @property {Callback<Tickable>} [onBegin]
+ * @property {Callback<Tickable>} [onBeforeUpdate]
+ * @property {Callback<Tickable>} [onUpdate]
+ * @property {Callback<Tickable>} [onLoop]
+ * @property {Callback<Tickable>} [onPause]
+ * @property {Callback<Tickable>} [onComplete]
+ * @property {Callback<Renderable>} [onRender]
*/
/** @typedef {JSAnimation|Timeline} Renderable */
@@ -86,7 +87,11 @@
*/
/**
- * @typedef {('linear'|'linear(x1, x2 25%, x3)'|'in'|'out'|'inOut'|'inQuad'|'outQuad'|'inOutQuad'|'inCubic'|'outCubic'|'inOutCubic'|'inQuart'|'outQuart'|'inOutQuart'|'inQuint'|'outQuint'|'inOutQuint'|'inSine'|'outSine'|'inOutSine'|'inCirc'|'outCirc'|'inOutCirc'|'inExpo'|'outExpo'|'inOutExpo'|'inBounce'|'outBounce'|'inOutBounce'|'inBack'|'outBack'|'inOutBack'|'inElastic'|'outElastic'|'inOutElastic'|'irregular'|'cubicBezier'|'steps'|'in(p = 1.675)'|'out(p = 1.675)'|'inOut(p = 1.675)'|'inBack(overshoot = 1.70158)'|'outBack(overshoot = 1.70158)'|'inOutBack(overshoot = 1.70158)'|'inElastic(amplitude = 1, period = .3)'|'outElastic(amplitude = 1, period = .3)'|'inOutElastic(amplitude = 1, period = .3)'|'irregular(length = 10, randomness = 1)'|'cubicBezier(x1, y1, x2, y2)'|'steps(steps = 10)')} EaseStringParamNames
+ * @typedef {('linear'|'none'|'in'|'out'|'inOut'|'inQuad'|'outQuad'|'inOutQuad'|'inCubic'|'outCubic'|'inOutCubic'|'inQuart'|'outQuart'|'inOutQuart'|'inQuint'|'outQuint'|'inOutQuint'|'inSine'|'outSine'|'inOutSine'|'inCirc'|'outCirc'|'inOutCirc'|'inExpo'|'outExpo'|'inOutExpo'|'inBounce'|'outBounce'|'inOutBounce'|'inBack'|'outBack'|'inOutBack'|'inElastic'|'outElastic'|'inOutElastic'|'out(p = 1.675)'|'inOut(p = 1.675)'|'inBack(overshoot = 1.7)'|'outBack(overshoot = 1.7)'|'inOutBack(overshoot = 1.7)'|'inElastic(amplitude = 1, period = .3)'|'outElastic(amplitude = 1, period = .3)'|'inOutElastic(amplitude = 1, period = .3)')} EaseStringParamNames
+ */
+
+/**
+ * @typedef {('ease'|'ease-in'|'ease-out'|'ease-in-out'|'linear(0, 0.25, 1)'|'steps'|'steps(6, start)'|'step-start'|'step-end'|'cubic-bezier(0.42, 0, 1, 1)') } WAAPIEaseStringParamNames
*/
/**
@@ -97,7 +102,7 @@
/**
* @callback BackEasing
- * @param {Number|String} [overshoot=1.70158]
+ * @param {Number|String} [overshoot=1.7]
* @return {EasingFunction}
*/
@@ -113,6 +118,7 @@
// A hack to get both ease names suggestions AND allow any strings
// https://github.com/microsoft/TypeScript/issues/29729#issuecomment-460346421
/** @typedef {(String & {})|EaseStringParamNames|EasingFunction|Spring} EasingParam */
+/** @typedef {(String & {})|EaseStringParamNames|WAAPIEaseStringParamNames|EasingFunction|Spring} WAAPIEasingParam */
// Spring types
@@ -122,6 +128,9 @@
* @property {Number} [stiffness=100] - Stiffness, default 100
* @property {Number} [damping=10] - Damping, default 10
* @property {Number} [velocity=0] - Initial velocity, default 0
+ * @property {Number} [bounce=0] - Initial bounce, default 0
+ * @property {Number} [duration=0] - The perceived duration, default 0
+ * @property {Callback<JSAnimation>} [onComplete] - Callback function called when the spring currentTime hits the perceived duration
*/
// Callback types
@@ -219,6 +228,7 @@
* @property {Number} _isOverlapped
* @property {Number} _isOverridden
* @property {Number} _renderTransforms
+ * @property {String} _inlineValue
* @property {Tween} _prevRep
* @property {Tween} _nextRep
* @property {Tween} _prevAdd
@@ -376,7 +386,7 @@
*/
/**
- * @typedef {(animation: WAAPIAnimation) => void} WAAPICallback
+ * @typedef {Callback<WAAPIAnimation>} WAAPICallback
*/
/**
@@ -385,7 +395,7 @@
* @property {WAAPIKeyframeValue} [from]
* @property {Number|WAAPIFunctionValue} [duration]
* @property {Number|WAAPIFunctionValue} [delay]
- * @property {EasingParam} [ease]
+ * @property {WAAPIEasingParam} [ease]
* @property {CompositeOperation} [composition]
*/
@@ -398,13 +408,14 @@
* @property {Number} [playbackRate]
* @property {Number|WAAPIFunctionValue} [duration]
* @property {Number|WAAPIFunctionValue} [delay]
- * @property {EasingParam} [ease]
+ * @property {WAAPIEasingParam} [ease]
* @property {CompositeOperation} [composition]
+ * @property {Boolean} [persist]
* @property {WAAPICallback} [onComplete]
*/
/**
- * @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | WAAPICallback | EasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams
+ * @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | WAAPICallback | WAAPIEasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams
*/
// Animatable types
@@ -682,6 +693,8 @@ const maxFps = 120;
// Strings
const emptyString = '';
+const cssVarPrefix = 'var(';
+
const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -705,9 +718,9 @@ const validTransforms = [
'skew',
'skewX',
'skewY',
- 'perspective',
'matrix',
'matrix3d',
+ 'perspective',
];
const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) => ({...a, [v]: v + '('}), {});
@@ -731,6 +744,7 @@ const unitsExecRgx = /^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i;
const lowerCaseRgx = /([a-z])([A-Z])/g;
const transformsExecRgx = /(\w+)(\([^)]+\)+)/g; // Match inline transforms with cacl() values, returns the value wrapped in ()
const relativeValuesExecRgx = /(\*=|\+=|-=)/;
+const cssVariableMatchRgx = /var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/;
@@ -745,6 +759,7 @@ const defaults = {
reversed: false,
alternate: false,
autoplay: true,
+ persist: false,
duration: K,
delay: 0,
loopDelay: 0,
@@ -1168,19 +1183,30 @@ const setValue = (targetValue, defaultValue) => {
* @return {any}
*/
const getFunctionValue = (value, target, index, total, store) => {
+ let func;
if (isFnc(value)) {
- const func = () => {
+ func = () => {
const computed = /** @type {Function} */(value)(target, index, total);
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed || 0;
};
- if (store) {
- store.func = func;
- }
- return func();
+ } else if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
+ func = () => {
+ const match = value.match(cssVariableMatchRgx);
+ const cssVarName = match[1];
+ const fallbackValue = match[2];
+ let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
+ // Use fallback if CSS variable is not set or empty
+ if ((!computed || computed.trim() === emptyString) && fallbackValue) {
+ computed = fallbackValue.trim();
+ }
+ return computed || 0;
+ };
} else {
return value;
}
+ if (store) store.func = func;
+ return func();
};
/**
@@ -1587,7 +1613,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
// Handle setters on timeline differently and allow re-trigering the onComplete callback when seeking backwards
if (parent && isSetter) {
if (!muteCallbacks && (
- (parent.began && !isRunningBackwards && tickableAbsoluteTime >= duration && !completed) ||
+ // (tickableAbsoluteTime > 0 instead) of (tickableAbsoluteTime >= duration) to prevent floating point precision issues
+ // see: https://github.com/juliangarnier/anime/issues/1088
+ (parent.began && !isRunningBackwards && tickableAbsoluteTime > 0 && !completed) ||
(isRunningBackwards && tickableAbsoluteTime <= minValue && completed)
)) {
tickable.onComplete(/** @type {CallbackArgument} */(tickable));
@@ -1689,12 +1717,11 @@ const tick = (tickable, time, muteCallbacks, internalRender, tickMode) => {
}
};
-const propertyNamesCache = {};
-
+const propertyNamesCache = {};
/**
* @param {String} propertyName
@@ -1742,10 +1769,11 @@ const cleanInlineStyles = renderable => {
const tweenTarget = tween.target;
if (tweenTarget[isDomSymbol]) {
const targetStyle = /** @type {DOMTarget} */(tweenTarget).style;
- const originalInlinedValue = animation._inlineStyles[tweenProperty];
+ const originalInlinedValue = tween._inlineValue;
+ const tweenHadNoInlineValue = isNil(originalInlinedValue) || originalInlinedValue === emptyString;
if (tween._tweenType === tweenTypes.TRANSFORM) {
const cachedTransforms = tweenTarget[transformsSymbol];
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ if (tweenHadNoInlineValue) {
delete cachedTransforms[tweenProperty];
} else {
cachedTransforms[tweenProperty] = originalInlinedValue;
@@ -1762,8 +1790,8 @@ const cleanInlineStyles = renderable => {
}
}
} else {
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
- targetStyle.removeProperty(tweenProperty);
+ if (tweenHadNoInlineValue) {
+ targetStyle.removeProperty(toLowerCase(tweenProperty));
} else {
targetStyle[tweenProperty] = originalInlinedValue;
}
@@ -3048,6 +3076,7 @@ const none = t => t;
+
/** @type {PowerEasing} */
const easeInPower = (p = 1.68) => t => pow(t, +p);
@@ -3065,154 +3094,6 @@ const easeTypes = {
outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
};
-/**
- * @param {String} string
- * @param {Record<String, EasingFunctionWithParams|EasingFunction>} easesFunctions
- * @param {Object} easesLookups
- * @return {EasingFunction}
- */
-const parseEaseString = (string, easesFunctions, easesLookups) => {
- if (easesLookups[string]) return easesLookups[string];
- if (string.indexOf('(') <= -1) {
- const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
- const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(easesFunctions[string])() : easesFunctions[string]);
- return parsedFn ? easesLookups[string] = parsedFn : none;
- } else {
- const split = string.slice(0, -1).split('(');
- const parsedFn = /** @type {EasingFunctionWithParams} */(easesFunctions[split[0]]);
- return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
- }
-};
-
-
-
-/**
- * Cubic Bezier solver adapted from https://github.com/gre/bezier-easing
- * (c) 2014 Gaëtan Renaudeau
- */
-
-/**
- * @param {Number} aT
- * @param {Number} aA1
- * @param {Number} aA2
- * @return {Number}
- */
-const calcBezier = (aT, aA1, aA2) => (((1 - 3 * aA2 + 3 * aA1) * aT + (3 * aA2 - 6 * aA1)) * aT + (3 * aA1)) * aT;
-
-/**
- * @param {Number} aX
- * @param {Number} mX1
- * @param {Number} mX2
- * @return {Number}
- */
-const binarySubdivide = (aX, mX1, mX2) => {
- let aA = 0, aB = 1, currentX, currentT, i = 0;
- do {
- currentT = aA + (aB - aA) / 2;
- currentX = calcBezier(currentT, mX1, mX2) - aX;
- if (currentX > 0) {
- aB = currentT;
- } else {
- aA = currentT;
- }
- } while (abs(currentX) > .0000001 && ++i < 100);
- return currentT;
-};
-
-/**
- * @param {Number} [mX1] The x coordinate of the first point
- * @param {Number} [mY1] The y coordinate of the first point
- * @param {Number} [mX2] The x coordinate of the second point
- * @param {Number} [mY2] The y coordinate of the second point
- * @return {EasingFunction}
- */
-
-const cubicBezier = (mX1 = 0.5, mY1 = 0.0, mX2 = 0.5, mY2 = 1.0) => (mX1 === mY1 && mX2 === mY2) ? none :
- t => t === 0 || t === 1 ? t :
- calcBezier(binarySubdivide(t, mX1, mX2), mY1, mY2);
-
-
-
-/**
- * Steps ease implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
- * Only covers 'end' and 'start' jumpterms
- * @param {Number} steps
- * @param {Boolean} [fromStart]
- * @return {EasingFunction}
- */
-const steps = (steps = 10, fromStart) => {
- const roundMethod = fromStart ? ceil : floor;
- return t => roundMethod(clamp$1(t, 0, 1) * steps) * (1 / steps);
-};
-
-
-
-/**
- * Without parameters, the linear function creates a non-eased transition.
- * Parameters, if used, creates a piecewise linear easing by interpolating linearly between the specified points.
- *
- * @param {...(String|Number)} args - Points
- * @return {EasingFunction}
- */
-const linear = (...args) => {
- const argsLength = args.length;
- if (!argsLength) return none;
- const totalPoints = argsLength - 1;
- const firstArg = args[0];
- const lastArg = args[totalPoints];
- const xPoints = [0];
- const yPoints = [parseNumber(firstArg)];
- for (let i = 1; i < totalPoints; i++) {
- const arg = args[i];
- const splitValue = isStr(arg) ?
- /** @type {String} */(arg).trim().split(' ') :
- [arg];
- const value = splitValue[0];
- const percent = splitValue[1];
- xPoints.push(!isUnd(percent) ? parseNumber(percent) / 100 : i / totalPoints);
- yPoints.push(parseNumber(value));
- }
- yPoints.push(parseNumber(lastArg));
- xPoints.push(1);
- return function easeLinear(t) {
- for (let i = 1, l = xPoints.length; i < l; i++) {
- const currentX = xPoints[i];
- if (t <= currentX) {
- const prevX = xPoints[i - 1];
- const prevY = yPoints[i - 1];
- return prevY + (yPoints[i] - prevY) * (t - prevX) / (currentX - prevX);
- }
- }
- return yPoints[yPoints.length - 1];
- }
-};
-
-
-
-/**
- * Generate random steps
- * @param {Number} [length] - The number of steps
- * @param {Number} [randomness] - How strong the randomness is
- * @return {EasingFunction}
- */
-const irregular = (length = 10, randomness = 1) => {
- const values = [0];
- const total = length - 1;
- for (let i = 1; i < total; i++) {
- const previousValue = values[i - 1];
- const spacing = i / total;
- const segmentEnd = (i + 1) / total;
- const randomVariation = spacing + (segmentEnd - spacing) * Math.random();
- // Mix the even spacing and random variation based on the randomness parameter
- const randomValue = spacing * (1 - randomness) + randomVariation * randomness;
- values.push(clamp$1(randomValue, previousValue, 1));
- }
- values.push(1);
- return linear(...values);
-};
-
-
-
/**
* Easing functions adapted and simplified from https://robertpenner.com/easing/
* (c) 2001 Robert Penner
@@ -3241,7 +3122,7 @@ const easeInFunctions = {
return 1 / pow(4, 3 - b) - 7.5625 * pow((pow2 * 3 - 2) / 22 - t, 2);
},
/** @type {BackEasing} */
- Back: (overshoot = 1.70158) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
+ Back: (overshoot = 1.7) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
/** @type {ElasticEasing} */
Elastic: (amplitude = 1, period = .3) => {
const a = clamp$1(+amplitude, 1, 10);
@@ -3254,10 +3135,8 @@ const easeInFunctions = {
/**
* @typedef {Object} EasesFunctions
- * @property {typeof linear} linear
- * @property {typeof irregular} irregular
- * @property {typeof steps} steps
- * @property {typeof cubicBezier} cubicBezier
+ * @property {typeof none} linear
+ * @property {typeof none} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
@@ -3305,7 +3184,7 @@ const easeInFunctions = {
*/
const eases = (/*#__PURE__ */ (() => {
- const list = { linear, irregular, steps, cubicBezier };
+ const list = { linear: none, none: none };
for (let type in easeTypes) {
for (let name in easeInFunctions) {
const easeIn = easeInFunctions[name];
@@ -3321,15 +3200,43 @@ const eases = (/*#__PURE__ */ (() => {
})());
/** @type {Record<String, EasingFunction>} */
-const JSEasesLookups = { linear: none };
+const easesLookups = { linear: none, none: none };
+
+/**
+ * @param {String} string
+ * @return {EasingFunction}
+ */
+const parseEaseString = (string) => {
+ if (easesLookups[string]) return easesLookups[string];
+ if (string.indexOf('(') <= -1) {
+ const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
+ const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(eases[string])() : eases[string]);
+ return parsedFn ? easesLookups[string] = parsedFn : none;
+ } else {
+ const split = string.slice(0, -1).split('(');
+ const parsedFn = /** @type {EasingFunctionWithParams} */(eases[split[0]]);
+ return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
+ }
+};
+
+const deprecated = ['steps(', 'irregular(', 'linear(', 'cubicBezier('];
/**
* @param {EasingParam} ease
* @return {EasingFunction}
*/
-const parseEase = ease => isFnc(ease) ? ease :
- isStr(ease) ? parseEaseString(/** @type {String} */(ease), eases, JSEasesLookups) :
- none;
+const parseEase = ease => {
+ if (isStr(ease)) {
+ for (let i = 0, l = deprecated.length; i < l; i++) {
+ if (stringStartsWith(ease, deprecated[i])) {
+ console.warn(`String syntax for \`ease: "${ease}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${ease}\``);
+ return none;
+ }
+ }
+ }
+ const easeFunc = isFnc(ease) ? ease : isStr(ease) ? parseEaseString(/** @type {String} */(ease)) : none;
+ return easeFunc;
+};
@@ -3337,6 +3244,7 @@ const parseEase = ease => isFnc(ease) ? ease :
// TODO: Maybe move the objects creation to values.js and use the decompose function to create the base object
const fromTargetObject = createDecomposedValueTargetObject();
const toTargetObject = createDecomposedValueTargetObject();
+const inlineStylesStore = {};
const toFunctionStore = { func: null };
const keyframesTargetArray = [null];
const fastSetValuesArray = [null, null];
@@ -3481,15 +3389,15 @@ class JSAnimation extends Timer {
const animEase = animaPlaybackEase ? parseEase(animaPlaybackEase) : null;
const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */(ease).ease);
const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */(ease).duration : setValue(duration, animDefaults.duration);
+ const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : setValue(duration, animDefaults.duration);
const tDelay = setValue(delay, animDefaults.delay);
const tModifier = modifier || animDefaults.modifier;
// If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
const tComposition = isUnd(composition) && targetsLength >= K ? compositionTypes.none : !isUnd(composition) ? composition : animDefaults.composition;
- // TODO: Do not create an empty object until we know the animation will generate inline styles
- const animInlineStyles = {};
// const absoluteOffsetTime = this._offset;
const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
+ // This allows targeting the current animation in the spring onComplete callback
+ if (hasSpring) /** @type {Spring} */(ease).parent = this;
let iterationDuration = NaN;
let iterationDelay = NaN;
@@ -3591,7 +3499,7 @@ class JSAnimation extends Timer {
// Easing are treated differently and don't accept function based value to prevent having to pass a function wrapper that returns an other function all the time
const tweenEasing = hasSpring ? /** @type {Spring} */(keyEasing).ease : keyEasing || tEasing;
// Calculate default individual keyframe duration by dividing the tl of keyframes
- const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).duration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
+ const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).settlingDuration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
// Default delay value should only be applied to the first tween
const tweenDelay = getFunctionValue(setValue(key.delay, (!tweenIndex ? tDelay : 0)), target, ti, tl);
const computedComposition = getFunctionValue(setValue(key.composition, tComposition), target, ti, tl);
@@ -3641,7 +3549,7 @@ class JSAnimation extends Timer {
}
} else {
decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
decomposedOriginalValue
);
if (decomposedOriginalValue.t === valueTypes.UNIT) {
@@ -3659,7 +3567,7 @@ class JSAnimation extends Timer {
} else {
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), toTargetObject);
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), toTargetObject);
}
}
if (hasFromvalue) {
@@ -3670,7 +3578,7 @@ class JSAnimation extends Timer {
} else {
decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), fromTargetObject);
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
}
@@ -3679,7 +3587,7 @@ class JSAnimation extends Timer {
if (fromTargetObject.o) {
fromTargetObject.n = getRelativeValue(
!prevSibling ? decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
decomposedOriginalValue
).n : prevSibling._toNumber,
fromTargetObject.n,
@@ -3735,6 +3643,10 @@ class JSAnimation extends Timer {
// Rounding is necessary here to minimize floating point errors when working in seconds
const tweenUpdateDuration = round$1(+tweenDuration || minValue, 12);
+ // Copy the value of the iniline style if it exist and imediatly nullify it to prevents false positive on other targets
+ let inlineValue = inlineStylesStore[propName];
+ if (!isNil(inlineValue)) inlineStylesStore[propName] = null;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -3766,6 +3678,7 @@ class JSAnimation extends Timer {
_isOverlapped: 0,
_isOverridden: 0,
_renderTransforms: 0,
+ _inlineValue: inlineValue,
_prevRep: null, // For replaced tween
_nextRep: null, // For replaced tween
_prevAdd: null, // For additive tween
@@ -3868,8 +3781,6 @@ class JSAnimation extends Timer {
// this._offset += parent ? iterationDelay : 0;
/** @type {Number} */
this.iterationDuration = iterationDuration;
- /** @type {{}} */
- this._inlineStyles = animInlineStyles;
if (!this._autoplay && shouldTriggerRender) this.onRender(this);
}
@@ -3903,6 +3814,7 @@ class JSAnimation extends Timer {
if (tweenFunc) {
const ogValue = getOriginalAnimatableValue(tween.target, tween.property, tween._tweenType);
decomposeRawValue(ogValue, decomposedOriginalValue);
+ // TODO: Check for from / to Array based values here,
decomposeRawValue(tweenFunc(), toTargetObject);
tween._fromNumbers = cloneArray(decomposedOriginalValue.d);
tween._fromNumber = decomposedOriginalValue.n;
@@ -3912,6 +3824,8 @@ class JSAnimation extends Timer {
tween._toNumber = toTargetObject.o ? getRelativeValue(decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
}
});
+ // This forces setter animations to render once
+ if (this.duration === minValue) this.restart();
return this;
}
@@ -3954,16 +3868,18 @@ const WAAPIAnimationsLookups = {
* @param {DOMTarget} $el
* @param {String} [property]
* @param {WAAPIAnimation} [parent]
+ * @return {globalThis.Animation}
*/
const removeWAAPIAnimation = ($el, property, parent) => {
let nextLookup = WAAPIAnimationsLookups._head;
+ let anim;
while (nextLookup) {
const next = nextLookup._next;
const matchTarget = nextLookup.$el === $el;
const matchProperty = !property || nextLookup.property === property;
const matchParent = !parent || nextLookup.parent === parent;
if (matchTarget && matchProperty && matchParent) {
- const anim = nextLookup.animation;
+ anim = nextLookup.animation;
try { anim.commitStyles(); } catch {} anim.cancel();
removeChild(WAAPIAnimationsLookups, nextLookup);
const lookupParent = nextLookup.parent;
@@ -3971,8 +3887,8 @@ const removeWAAPIAnimation = ($el, property, parent) => {
lookupParent._completed++;
if (lookupParent.animations.length === lookupParent._completed) {
lookupParent.completed = true;
+ lookupParent.paused = true;
if (!lookupParent.muteCallbacks) {
- lookupParent.paused = true;
lookupParent.onComplete(lookupParent);
lookupParent._resolve(lookupParent);
}
@@ -3981,6 +3897,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
}
nextLookup = next;
}
+ return anim;
};
/**
@@ -3989,7 +3906,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
* @param {String} property
* @param {PropertyIndexedKeyframes} keyframes
* @param {KeyframeAnimationOptions} params
- * @retun {Animation}
+ * @retun {globalThis.Animation}
*/
const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
const animation = $el.animate(keyframes, params);
@@ -4004,8 +3921,11 @@ const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
removeWAAPIAnimation($el, property);
addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
+ animation.oncancel = handleRemove;
animation.onremove = handleRemove;
- animation.onfinish = handleRemove;
+ if (!parent.persist) {
+ animation.onfinish = handleRemove;
+ }
return animation;
};
@@ -4633,8 +4553,10 @@ var numberImports = /*#__PURE__*/Object.freeze({
+
+
/*
- * Spring ease solver adapted from https://webkit.org/demos/spring/spring.js
+ * Spring easing solver adapted from https://webkit.org/demos/spring/spring.js
* (c) 2016 Webkit - Apple Inc
*/
@@ -4645,25 +4567,46 @@ class Spring {
* @param {SpringParams} [parameters]
*/
constructor(parameters = {}) {
+ const hasBounceOrDuration = !isUnd(parameters.bounce) || !isUnd(parameters.duration);
this.timeStep = .02; // Interval fed to the solver to calculate duration
this.restThreshold = .0005; // Values below this threshold are considered resting position
this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
this.maxRestSteps = this.restDuration / this.timeStep / K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
this.maxIterations = this.maxDuration / this.timeStep / K; // Calculate the maximum iterations allowed based on maxDuration
- this.m = clamp$1(setValue(parameters.mass, 1), 0, maxSpringParamValue);
- this.s = clamp$1(setValue(parameters.stiffness, 100), 1, maxSpringParamValue);
- this.d = clamp$1(setValue(parameters.damping, 10), .1, maxSpringParamValue);
+ this.bn = clamp$1(setValue(parameters.bounce, .5), -1, 1); // The bounce percentage between -1 and 1.
+ this.pd = clamp$1(setValue(parameters.duration, 628), 10 * globals.timeScale, maxSpringParamValue * globals.timeScale); // The perceived duration
+ this.m = clamp$1(setValue(parameters.mass, 1), 1, maxSpringParamValue);
+ this.s = clamp$1(setValue(parameters.stiffness, 100), minValue, maxSpringParamValue);
+ this.d = clamp$1(setValue(parameters.damping, 10), minValue, maxSpringParamValue);
this.v = clamp$1(setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
this.w0 = 0;
this.zeta = 0;
this.wd = 0;
this.b = 0;
+ this.completed = false;
this.solverDuration = 0;
- this.duration = 0;
+ this.settlingDuration = 0;
+ /** @type {JSAnimation} */
+ this.parent = null;
+ /** @type {Callback<JSAnimation>} */
+ this.onComplete = parameters.onComplete || noop;
+ if (hasBounceOrDuration) this.calculateSDFromBD();
this.compute();
/** @type {EasingFunction} */
- this.ease = t => t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
+ this.ease = t => {
+ const currentTime = t * this.settlingDuration;
+ const completed = this.completed;
+ const perceivedTime = this.pd;
+ if (currentTime >= perceivedTime && !completed) {
+ this.completed = true;
+ this.onComplete(this.parent);
+ }
+ if (currentTime < perceivedTime && completed) {
+ this.completed = false;
+ }
+ return t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
+ };
}
/** @type {EasingFunction} */
@@ -4671,23 +4614,83 @@ class Spring {
const { zeta, w0, wd, b } = this;
let t = time;
if (zeta < 1) {
+ // Underdamped
t = exp(-t * zeta * w0) * (1 * cos(wd * t) + b * sin(wd * t));
- } else {
+ } else if (zeta === 1) {
+ // Critically damped
t = (1 + b * t) * exp(-t * w0);
+ } else {
+ // Overdamped
+ // Using exponential instead of cosh and sinh functions to prevent Infinity
+ // Original exp(-zeta * w0 * t) * (cosh(wd * t) + b * sinh(wd * t))
+ t = ((1 + b) * exp((-zeta * w0 + wd) * t) + (1 - b) * exp((-zeta * w0 - wd) * t)) / 2;
}
return 1 - t;
}
+ calculateSDFromBD() {
+ // Apple's SwiftUI perceived spring duration implementation https://developer.apple.com/videos/play/wwdc2023/10158/?time=1010
+ // Equations taken from Kevin Grajeda's article https://www.kvin.me/posts/effortless-ui-spring-animations
+ const pds = globals.timeScale === 1 ? this.pd / K : this.pd;
+ // Mass and velocity should be set to their default values
+ this.m = 1;
+ this.v = 0;
+ // Stiffness = (2π ÷ perceptualDuration)²
+ this.s = pow((2 * PI) / pds, 2);
+ if (this.bn >= 0) {
+ // For bounce ≥ 0 (critically damped to underdamped)
+ // damping = ((1 - bounce) × 4π) ÷ perceptualDuration
+ this.d = ((1 - this.bn) * 4 * PI) / pds;
+ } else {
+ // For bounce < 0 (overdamped)
+ // damping = 4π ÷ (perceptualDuration × (1 + bounce))
+ // Note: (1 + bounce) is positive since bounce is negative
+ this.d = (4 * PI) / (pds * (1 + this.bn));
+ }
+ this.s = round$1(clamp$1(this.s, minValue, maxSpringParamValue), 3);
+ this.d = round$1(clamp$1(this.d, minValue, 300), 3); // Clamping to 300 is needed to prevent insane values in the solver
+ }
+
+ calculateBDFromSD() {
+ // Calculate perceived duration and bounce from stiffness and damping
+ // Note: We assumes m = 1 and v = 0 for these calculations
+ const pds = (2 * PI) / sqrt(this.s);
+ this.pd = pds * (globals.timeScale === 1 ? K : 1);
+ const zeta = this.d / (2 * sqrt(this.s));
+ if (zeta <= 1) {
+ // Critically damped to underdamped
+ this.bn = 1 - (this.d * pds) / (4 * PI);
+ } else {
+ // Overdamped
+ this.bn = (4 * PI) / (this.d * pds) - 1;
+ }
+ this.bn = round$1(clamp$1(this.bn, -1, 1), 3);
+ this.pd = round$1(clamp$1(this.pd, 10 * globals.timeScale, maxSpringParamValue * globals.timeScale), 3);
+ }
+
compute() {
const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
const w0 = this.w0 = clamp$1(sqrt(s / m), minValue, K);
- const zeta = this.zeta = d / (2 * sqrt(s * m));
- const wd = this.wd = zeta < 1 ? w0 * sqrt(1 - zeta * zeta) : 0;
- this.b = zeta < 1 ? (zeta * w0 + -v) / wd : -v + w0;
+ const bouncedZeta = this.zeta = d / (2 * sqrt(s * m));
+ // Calculate wd based on damping type
+ if (bouncedZeta < 1) {
+ // Underdamped
+ this.wd = w0 * sqrt(1 - bouncedZeta * bouncedZeta);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ } else if (bouncedZeta === 1) {
+ // Critically damped
+ this.wd = 0;
+ this.b = -v + w0;
+ } else {
+ // Overdamped
+ this.wd = w0 * sqrt(bouncedZeta * bouncedZeta - 1);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ }
+
let solverTime = 0;
let restSteps = 0;
let iterations = 0;
- while (restSteps < maxRestSteps && iterations < maxIterations) {
+ while (restSteps <= maxRestSteps && iterations <= maxIterations) {
if (abs(1 - this.solve(solverTime)) < restThreshold) {
restSteps++;
} else {
@@ -4697,15 +4700,26 @@ class Spring {
solverTime += timeStep;
iterations++;
}
- this.duration = round$1(this.solverDuration * K, 0) * globals.timeScale;
+ this.settlingDuration = round$1(this.solverDuration * K, 0) * globals.timeScale;
}
- get mass() {
- return this.m;
+ get bounce() {
+ return this.bn;
}
- set mass(v) {
- this.m = clamp$1(setValue(v, 1), 0, maxSpringParamValue);
+ set bounce(v) {
+ this.bn = clamp$1(setValue(v, 1), -1, 1);
+ this.calculateSDFromBD();
+ this.compute();
+ }
+
+ get duration() {
+ return this.pd;
+ }
+
+ set duration(v) {
+ this.pd = clamp$1(setValue(v, 1), 10 * globals.timeScale, maxSpringParamValue * globals.timeScale);
+ this.calculateSDFromBD();
this.compute();
}
@@ -4714,7 +4728,8 @@ class Spring {
}
set stiffness(v) {
- this.s = clamp$1(setValue(v, 100), 1, maxSpringParamValue);
+ this.s = clamp$1(setValue(v, 100), minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
this.compute();
}
@@ -4723,7 +4738,17 @@ class Spring {
}
set damping(v) {
- this.d = clamp$1(setValue(v, 10), .1, maxSpringParamValue);
+ this.d = clamp$1(setValue(v, 10), minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
+ this.compute();
+ }
+
+ get mass() {
+ return this.m;
+ }
+
+ set mass(v) {
+ this.m = clamp$1(setValue(v, 1), 1, maxSpringParamValue);
this.compute();
}
@@ -4741,7 +4766,18 @@ class Spring {
* @param {SpringParams} [parameters]
* @returns {Spring}
*/
-const createSpring = (parameters) => new Spring(parameters);
+const spring = (parameters) => new Spring(parameters);
+
+/**
+ * @deprecated createSpring() is deprecated use spring() instead
+ *
+ * @param {SpringParams} [parameters]
+ * @returns {Spring}
+ */
+const createSpring = (parameters) => {
+ console.warn('createSpring() is deprecated use spring() instead');
+ return new Spring(parameters);
+};
@@ -4922,13 +4958,13 @@ class Draggable {
/** @type {Boolean|DraggableCursorParams} */
this.cursor = false;
/** @type {Spring} */
- this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : createSpring({
+ this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
mass: setValue(parameters.releaseMass, 1),
stiffness: setValue(parameters.releaseStiffness, 80),
damping: setValue(parameters.releaseDamping, 20),
});
/** @type {Spring} */
- this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : createSpring({
+ this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
mass: setValue(parameters.releaseMass, 1),
stiffness: setValue(parameters.releaseStiffness, 80),
damping: setValue(parameters.releaseDamping, 20),
@@ -5645,8 +5681,8 @@ class Draggable {
this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
this.$trigger.addEventListener('touchend', preventDefault);
-
- if ((!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
+ // Don't check for a miminim distance move if already dragging
+ if (this.dragged || (!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
this.updateTicker.resume();
this.pointer[2] = this.pointer[0];
@@ -5712,8 +5748,8 @@ class Draggable {
const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
const distanceX = round$1(cx - dx, 0);
springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / abs(distanceX) : 0 : pv;
- const { ease, duration, restDuration } = springX;
- durationX = cx === dx ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springX;
+ durationX = cx === dx ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
if (hasReleaseSpring) easeX = ease;
if (durationX > longestReleaseDuration) longestReleaseDuration = durationX;
}
@@ -5722,8 +5758,8 @@ class Draggable {
const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
const distanceY = round$1(cy - dy, 0);
springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / abs(distanceY) : 0 : pv;
- const { ease, duration, restDuration } = springY;
- durationY = cy === dy ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springY;
+ durationY = cy === dy ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
if (hasReleaseSpring) easeY = ease;
if (durationY > longestReleaseDuration) longestReleaseDuration = durationY;
}
@@ -6576,6 +6612,8 @@ class ScrollObserver {
/** @type {Boolean} */
this.reverted = false;
/** @type {Boolean} */
+ this.ready = false;
+ /** @type {Boolean} */
this.completed = false;
/** @type {Boolean} */
this.began = false;
@@ -6585,8 +6623,6 @@ class ScrollObserver {
this.forceEnter = false;
/** @type {Boolean} */
this.hasEntered = false;
- // /** @type {Array.<Number>} */
- // this.offsets = [];
/** @type {Number} */
this.offset = 0;
/** @type {Number} */
@@ -6634,6 +6670,8 @@ class ScrollObserver {
// Make sure to pause the linked object in case it's added later
linked.pause();
this.linked = linked;
+ // Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
+ if (!isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
// Try to use a target of the linked object if no target parameters specified
if (!this._params.target) {
/** @type {HTMLElement} */
@@ -6673,6 +6711,8 @@ class ScrollObserver {
}
refresh() {
+ // This flag is used to prevent running handleScroll() outside of this.refresh() with values not yet calculated
+ this.ready = true;
this.reverted = false;
const params = this._params;
this.repeat = setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
@@ -6918,8 +6958,6 @@ class ScrollObserver {
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
const scrollDelta = offsetEnd - offsetStart;
- // this.offsets[0] = offsetX;
- // this.offsets[1] = offsetY;
this.offset = offset;
this.offsetStart = offsetStart;
this.offsetEnd = offsetEnd;
@@ -6938,6 +6976,7 @@ class ScrollObserver {
}
handleScroll() {
+ if (!this.ready) return;
const linked = this.linked;
const sync = this.sync;
const syncEase = this.syncEase;
@@ -7061,6 +7100,7 @@ class ScrollObserver {
this.removeDebug();
}
this.reverted = true;
+ this.ready = false;
return this;
}
@@ -7072,13 +7112,142 @@ class ScrollObserver {
*/
const onScroll = (parameters = {}) => new ScrollObserver(parameters);
+
+
+/**
+ * Cubic Bezier solver adapted from https://github.com/gre/bezier-easing
+ * (c) 2014 Gaëtan Renaudeau
+ */
+
+/**
+ * @param {Number} aT
+ * @param {Number} aA1
+ * @param {Number} aA2
+ * @return {Number}
+ */
+const calcBezier = (aT, aA1, aA2) => (((1 - 3 * aA2 + 3 * aA1) * aT + (3 * aA2 - 6 * aA1)) * aT + (3 * aA1)) * aT;
+
+/**
+ * @param {Number} aX
+ * @param {Number} mX1
+ * @param {Number} mX2
+ * @return {Number}
+ */
+const binarySubdivide = (aX, mX1, mX2) => {
+ let aA = 0, aB = 1, currentX, currentT, i = 0;
+ do {
+ currentT = aA + (aB - aA) / 2;
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
+ if (currentX > 0) {
+ aB = currentT;
+ } else {
+ aA = currentT;
+ }
+ } while (abs(currentX) > .0000001 && ++i < 100);
+ return currentT;
+};
+
+/**
+ * @param {Number} [mX1] The x coordinate of the first point
+ * @param {Number} [mY1] The y coordinate of the first point
+ * @param {Number} [mX2] The x coordinate of the second point
+ * @param {Number} [mY2] The y coordinate of the second point
+ * @return {EasingFunction}
+ */
+
+const cubicBezier = (mX1 = 0.5, mY1 = 0.0, mX2 = 0.5, mY2 = 1.0) => (mX1 === mY1 && mX2 === mY2) ? none :
+ t => t === 0 || t === 1 ? t :
+ calcBezier(binarySubdivide(t, mX1, mX2), mY1, mY2);
+
+
+
+/**
+ * Steps ease implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
+ * Only covers 'end' and 'start' jumpterms
+ * @param {Number} steps
+ * @param {Boolean} [fromStart]
+ * @return {EasingFunction}
+ */
+const steps = (steps = 10, fromStart) => {
+ const roundMethod = fromStart ? ceil : floor;
+ return t => roundMethod(clamp$1(t, 0, 1) * steps) * (1 / steps);
+};
+
+
+
+/**
+ * Without parameters, the linear function creates a non-eased transition.
+ * Parameters, if used, creates a piecewise linear easing by interpolating linearly between the specified points.
+ *
+ * @param {...(String|Number)} args - Points
+ * @return {EasingFunction}
+ */
+const linear = (...args) => {
+ const argsLength = args.length;
+ if (!argsLength) return none;
+ const totalPoints = argsLength - 1;
+ const firstArg = args[0];
+ const lastArg = args[totalPoints];
+ const xPoints = [0];
+ const yPoints = [parseNumber(firstArg)];
+ for (let i = 1; i < totalPoints; i++) {
+ const arg = args[i];
+ const splitValue = isStr(arg) ?
+ /** @type {String} */(arg).trim().split(' ') :
+ [arg];
+ const value = splitValue[0];
+ const percent = splitValue[1];
+ xPoints.push(!isUnd(percent) ? parseNumber(percent) / 100 : i / totalPoints);
+ yPoints.push(parseNumber(value));
+ }
+ yPoints.push(parseNumber(lastArg));
+ xPoints.push(1);
+ return function easeLinear(t) {
+ for (let i = 1, l = xPoints.length; i < l; i++) {
+ const currentX = xPoints[i];
+ if (t <= currentX) {
+ const prevX = xPoints[i - 1];
+ const prevY = yPoints[i - 1];
+ return prevY + (yPoints[i] - prevY) * (t - prevX) / (currentX - prevX);
+ }
+ }
+ return yPoints[yPoints.length - 1];
+ }
+};
+
+
+
+/**
+ * Generate random steps
+ * @param {Number} [length] - The number of steps
+ * @param {Number} [randomness] - How strong the randomness is
+ * @return {EasingFunction}
+ */
+const irregular = (length = 10, randomness = 1) => {
+ const values = [0];
+ const total = length - 1;
+ for (let i = 1; i < total; i++) {
+ const previousValue = values[i - 1];
+ const spacing = i / total;
+ const segmentEnd = (i + 1) / total;
+ const randomVariation = spacing + (segmentEnd - spacing) * Math.random();
+ // Mix the even spacing and random variation based on the randomness parameter
+ const randomValue = spacing * (1 - randomness) + randomVariation * randomness;
+ values.push(clamp$1(randomValue, previousValue, 1));
+ }
+ values.push(1);
+ return linear(...values);
+};
+
var index$3 = /*#__PURE__*/Object.freeze({
__proto__: null,
+ Spring: Spring,
+ createSpring: createSpring,
cubicBezier: cubicBezier,
eases: eases,
irregular: irregular,
linear: linear,
- none: none,
+ spring: spring,
steps: steps
});
@@ -8134,21 +8303,11 @@ var index = /*#__PURE__*/Object.freeze({
*/
const easingToLinear = (fn, samples = 100) => {
const points = [];
- for (let i = 0; i <= samples; i++) points.push(fn(i / samples));
+ for (let i = 0; i <= samples; i++) points.push(round$1(fn(i / samples), 4));
return `linear(${points.join(', ')})`;
};
-const WAAPIEasesLookups = {
- in: 'ease-in',
- out: 'ease-out',
- inOut: 'ease-in-out',
-};
-
-const WAAPIeases = /*#__PURE__*/(() => {
- const list = {};
- for (let type in easeTypes) list[type] = (/** @type {String|Number} */p) => easeTypes[type](easeInPower(p));
- return /** @type {Record<String, EasingFunction>} */(list);
-})();
+const WAAPIEasesLookups = {};
/**
* @param {EasingParam} ease
@@ -8169,9 +8328,10 @@ const parseWAAPIEasing = (ease) => {
} else if (stringStartsWith(ease, 'cubicB')) {
parsedEase = toLowerCase(ease);
} else {
- const parsed = parseEaseString(ease, WAAPIeases, WAAPIEasesLookups);
+ const parsed = parseEaseString(ease);
if (isFnc(parsed)) parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
}
+ // Only cache string based easing name, otherwise function arguments get lost
WAAPIEasesLookups[ease] = parsedEase;
} else if (isFnc(ease)) {
const easing = easingToLinear(ease);
@@ -8212,7 +8372,8 @@ let transformsPropertiesRegistered = null;
* @return {String}
*/
const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
- let v = getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
+ // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
+ let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
if (!isNum(v)) return v;
if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
@@ -8292,7 +8453,7 @@ class WAAPIAnimation {
/** @type {PlaybackDirection} */
const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
/** @type {FillMode} */
- const fill = 'forwards';
+ const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
/** @type {String} */
const easing = parseWAAPIEasing(ease);
const timeScale = (globals.timeScale === 1 ? 1 : K);
@@ -8304,7 +8465,7 @@ class WAAPIAnimation {
/** @type {globalThis.Animation}] */
this.controlAnimation = null;
/** @type {Callback<this>} */
- this.onComplete = params.onComplete || noop;
+ this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.defaults.onComplete));
/** @type {Number} */
this.duration = 0;
/** @type {Boolean} */
@@ -8315,6 +8476,8 @@ class WAAPIAnimation {
this.paused = !autoplay || scroll !== false;
/** @type {Boolean} */
this.reversed = reversed;
+ /** @type {Boolean} */
+ this.persist = setValue(params.persist, globals.defaults.persist);
/** @type {Boolean|ScrollObserver} */
this.autoplay = autoplay;
/** @type {Number} */
@@ -8323,17 +8486,18 @@ class WAAPIAnimation {
this._resolve = noop; // Used by .then()
/** @type {Number} */
this._completed = 0;
- /** @type {Array<Object>}] */
- this._inlineStyles = parsedTargets.map($el => $el.getAttribute('style'));
+ /** @type {Array.<Object>} */
+ this._inlineStyles = [];
parsedTargets.forEach(($el, i) => {
const cachedTransforms = $el[transformsSymbol];
-
const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
+ const elStyle = $el.style;
+ const inlineStyles = this._inlineStyles[i] = {};
/** @type {Number} */
- const duration = (spring ? /** @type {Spring} */(spring).duration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
+ const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -8347,6 +8511,12 @@ class WAAPIAnimation {
const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
const propertyValue = params[name];
const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
+
+ const styleName = individualTransformProperty ? 'transform' : name;
+ if (!inlineStyles[styleName]) {
+ inlineStyles[styleName] = elStyle[styleName];
+ }
+
let parsedPropertyValue;
if (isObj(propertyValue)) {
const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
@@ -8355,7 +8525,7 @@ class WAAPIAnimation {
const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
/** @type {Number} */
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).duration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
+ tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -8372,10 +8542,10 @@ class WAAPIAnimation {
addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
if (!isUnd(from)) {
if (!individualTransformProperty) {
- $el.style[name] = keyframes[name][0];
+ elStyle[name] = keyframes[name][0];
} else {
const key = `--${individualTransformProperty}`;
- $el.style.setProperty(key, keyframes[key][0]);
+ elStyle.setProperty(key, keyframes[key][0]);
}
}
} else {
@@ -8396,7 +8566,7 @@ class WAAPIAnimation {
for (let t in cachedTransforms) {
transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
}
- $el.style.transform = transforms;
+ elStyle.transform = transforms;
}
});
@@ -8441,7 +8611,8 @@ class WAAPIAnimation {
// Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
// The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
// https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
- if (t >= this.duration) anim.play();
+ // This is not needed for persisting animations since they never finish.
+ if (!this.persist && t >= this.duration) anim.play();
anim.currentTime = t;
});
}
@@ -8511,13 +8682,30 @@ class WAAPIAnimation {
}
cancel() {
- this.forEach('cancel');
- return this.pause();
+ this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
+ return this.commitStyles().forEach('cancel');
}
revert() {
- this.cancel();
- this.targets.forEach(($el, i) => $el.setAttribute('style', this._inlineStyles[i]) );
+ // NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
+ // This means if you have multiple animations animating different transforms on the same target,
+ // reverting one of them will also override the transform property of the other animations.
+ // A better approach would be to store the original custom property values is they exist instead of the entire transform value,
+ // and update the CSS variables with the orignal value
+ this.cancel().targets.forEach(($el, i) => {
+ const targetStyle = $el.style;
+ const targetInlineStyles = this._inlineStyles[i];
+ for (let name in targetInlineStyles) {
+ const originalInlinedValue = targetInlineStyles[name];
+ if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ targetStyle.removeProperty(toLowerCase(name));
+ } else {
+ targetStyle[name] = originalInlinedValue;
+ }
+ }
+ // Remove style attribute if empty
+ if ($el.getAttribute('style') === emptyString) $el.removeAttribute('style');
+ });
return this;
}
@@ -8551,4 +8739,4 @@ const waapi = {
convertEase: easingToLinear
};
-export { registerTargets as $, Animatable, Draggable, JSAnimation, Scope, ScrollObserver, Spring, TextSplitter, Timeline, Timer, WAAPIAnimation, animate, clamp, cleanInlineStyles, createAnimatable, createDraggable, createDrawable, createMotionPath, createScope, createSeededRandom, createSpring, createTimeline, createTimer, cubicBezier, damp, degToRad, eases, index$3 as easings, engine, get, irregular, keepTime, lerp, linear, mapRange, morphTo, none, onScroll, padEnd, padStart, radToDeg, random, randomPick, remove, round, roundPad, scrollContainers, set, shuffle, snap, split, splitText, stagger, steps, index$1 as svg, sync, index as text, index$2 as utils, waapi, wrap };
+export { registerTargets as $, Animatable, Draggable, JSAnimation, Scope, ScrollObserver, Spring, TextSplitter, Timeline, Timer, WAAPIAnimation, animate, clamp, cleanInlineStyles, createAnimatable, createDraggable, createDrawable, createMotionPath, createScope, createSeededRandom, createSpring, createTimeline, createTimer, cubicBezier, damp, degToRad, eases, index$3 as easings, engine, get, irregular, keepTime, lerp, linear, mapRange, morphTo, onScroll, padEnd, padStart, radToDeg, random, randomPick, remove, round, roundPad, scrollContainers, set, shuffle, snap, split, splitText, spring, stagger, steps, index$1 as svg, sync, index as text, index$2 as utils, waapi, wrap };
diff --git a/dist/bundles/anime.esm.min.js b/dist/bundles/anime.esm.min.js
index 7294cd59..0871bd4c 100644
--- a/dist/bundles/anime.esm.min.js
+++ b/dist/bundles/anime.esm.min.js
@@ -4,4 +4,4 @@
* @license MIT
* @copyright 2025 - Julian Garnier
*/
-const t="undefined"!=typeof window,e=t?window:null,s=t?document:null,i={OBJECT:0,ATTRIBUTE:1,CSS:2,TRANSFORM:3,CSS_VAR:4},r={NUMBER:0,UNIT:1,COLOR:2,COMPLEX:3},n={NONE:0,AUTO:1,FORCE:2},o={replace:0,none:1,blend:2},a=Symbol(),h=Symbol(),l=Symbol(),c=Symbol(),d=Symbol(),u=Symbol(),p=1e-11,m=1e12,f=1e3,g=120,_="",y=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),v=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],b=v.reduce((t,e)=>({...t,[e]:e+"("}),{}),T=()=>{},S=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,w=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,x=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,E=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,C=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,k=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,$=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,O=/([a-z])([A-Z])/g,B=/(\w+)(\([^)]+\)+)/g,N=/(\*=|\+=|-=)/,R={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:g,loop:0,reversed:!1,alternate:!1,autoplay:!0,duration:f,delay:0,loopDelay:0,ease:"out(2)",composition:o.replace,modifier:t=>t,onBegin:T,onBeforeUpdate:T,onUpdate:T,onLoop:T,onPause:T,onComplete:T,onRender:T},L={current:null,root:s},A={defaults:R,precision:4,timeScale:1,tickThreshold:200},D={version:"4.2.0",engine:null};t&&(e.AnimeJS||(e.AnimeJS=[]),e.AnimeJS.push(D));const M=t=>t.replace(O,"$1-$2").toLowerCase(),F=(t,e)=>0===t.indexOf(e),I=Date.now,P=Array.isArray,z=t=>t&&t.constructor===Object,X=t=>"number"==typeof t&&!isNaN(t),U=t=>"string"==typeof t,Y=t=>"function"==typeof t,W=t=>void 0===t,V=t=>W(t)||null===t,H=e=>t&&e instanceof SVGElement,q=t=>S.test(t),j=t=>F(t,"rgb"),Q=t=>F(t,"hsl"),G=t=>q(t)||j(t)||Q(t),J=t=>!A.defaults.hasOwnProperty(t),Z=["opacity","rotate","overflow","color"],K=(t,e)=>{if(Z.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}},tt=t=>U(t)?parseFloat(t):t,et=Math.pow,st=Math.sqrt,it=Math.sin,rt=Math.cos,nt=Math.abs,ot=Math.exp,at=Math.ceil,ht=Math.floor,lt=Math.asin,ct=Math.max,dt=Math.atan2,ut=Math.PI,pt=Math.round,mt=(t,e,s)=>t<e?e:t>s?s:t,ft={},gt=(t,e)=>{if(e<0)return t;if(!e)return pt(t);let s=ft[e];return s||(s=ft[e]=10**e),pt(t*s)/s},_t=(t,e)=>P(e)?e.reduce((e,s)=>nt(s-t)<nt(e-t)?s:e):e?pt(t/e)*e:t,yt=(t,e,s)=>t+(e-t)*s,vt=t=>t===1/0?m:t===-1/0?-m:t,bt=t=>t<=p?p:vt(gt(t,11)),Tt=t=>P(t)?[...t]:t,St=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=W(r)?e[i]:r}return s},wt=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},xt=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},Et=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},Ct=(t,e,s)=>{const i=t.style.transform;let r;if(i){const n=t[c];let o;for(;o=B.exec(i);){const t=o[1],i=o[2].slice(1,-1);n[t]=i,t===e&&(r=i,s&&(s[e]=i))}}return i&&!W(r)?r:F(e,"scale")?"1":F(e,"rotate")||F(e,"skew")?"0deg":"0px"},kt=t=>{const e=w.exec(t)||x.exec(t),s=W(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]},$t=t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]},Ot=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),Bt=t=>{const e=E.exec(t)||C.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=W(e[4])?1:+e[4];let o,a,h;if(0===i)o=a=h=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=gt(255*Ot(e,t,s+1/3),0),a=gt(255*Ot(e,t,s),0),h=gt(255*Ot(e,t,s-1/3),0)}return[o,a,h,n]},Nt=t=>j(t)?kt(t):q(t)?$t(t):Q(t)?Bt(t):[0,0,0,1],Rt=(t,e)=>W(t)?e:t,Lt=(t,e,s,i,r)=>{if(Y(t)){const n=()=>{const r=t(e,s,i);return isNaN(+r)?r||0:+r};return r&&(r.func=n),n()}return t},At=(t,e)=>t[h]?t[l]&&K(t,e)?i.ATTRIBUTE:v.includes(e)||y.get(e)?i.TRANSFORM:F(e,"--")?i.CSS_VAR:e in t.style?i.CSS:e in t?i.OBJECT:i.ATTRIBUTE:i.OBJECT,Dt=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[u]||t).getPropertyValue(e);return"auto"===r?"0":r},Mt=(t,e,s,r)=>{const n=W(s)?At(t,e):s;return n===i.OBJECT?t[e]||0:n===i.ATTRIBUTE?t.getAttribute(e):n===i.TRANSFORM?Ct(t,e,r):n===i.CSS_VAR?Dt(t,e,r).trimStart():Dt(t,e,r)},Ft=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,It=()=>({t:r.NUMBER,n:0,u:null,o:null,d:null,s:null}),Pt=(t,e)=>{if(e.t=r.NUMBER,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const i=!s.includes(" ")&&$.exec(s);if(i)return e.t=r.UNIT,e.n=+i[1],e.u=i[2],e;if(e.o)return e.n=+s,e;if(G(s))return e.t=r.COLOR,e.d=Nt(s),e;{const t=s.match(k);return e.t=r.COMPLEX,e.d=t?t.map(Number):[],e.s=s.split(k)||[],e}}return e.n=s,e},zt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=Tt(t._toNumbers),e.s=Tt(t._strings),e),Xt=It(),Ut=(t,e,s,a,h)=>{const l=t.parent,d=t.duration,u=t.completed,m=t.iterationDuration,f=t.iterationCount,g=t._currentIteration,y=t._loopDelay,v=t._reversed,T=t._alternate,S=t._hasChildren,w=t._delay,x=t._currentTime,E=w+m,C=e-w,k=mt(x,-w,d),$=mt(C,-w,d),O=C-x,B=$>0,N=$>=d,R=d<=p,L=h===n.FORCE;let D=0,M=C,F=0;if(f>1){const e=~~($/(m+(N?0:y)));t._currentIteration=mt(e,0,f),N&&t._currentIteration--,D=t._currentIteration%2,M=$%(m+y)||0}const I=v^(T&&D),P=t._ease;let z=N?I?0:d:I?m-M:M;P&&(z=m*P(z/m)||0);const X=(l?l.backwards:C<x)?!I:!!I;if(t._currentTime=C,t._iterationTime=z,t.backwards=X,B&&!t.began?(t.began=!0,s||l&&(X||!l.began)||t.onBegin(t)):C<=0&&(t.began=!1),s||S||!B||t._currentIteration===g||t.onLoop(t),L||h===n.AUTO&&(e>=w&&e<=E||e<=w&&k>w||e>=E&&k!==d)||z>=E&&k!==d||z<=w&&k>0||e<=k&&k===d&&u||N&&!u&&R){if(B&&(t.computeDeltaTime(k),s||t.onBeforeUpdate(t)),!S){const e=L||(X?-1*O:O)>=A.tickThreshold,n=t._offset+(l?l._offset:0)+w+z;let h,d,u,p,m=t._head,f=0;for(;m;){const t=m._composition,s=m._currentTime,l=m._changeDuration,g=m._absoluteStartTime+m._changeDuration,y=m._nextRep,v=m._prevRep,T=t!==o.none;if((e||(s!==l||n<=g+(y?y._delay:0))&&(0!==s||n>=m._absoluteStartTime))&&(!T||!m._isOverridden&&(!m._isOverlapped||n<=g)&&(!y||y._isOverridden||n<=y._absoluteStartTime)&&(!v||v._isOverridden||n>=v._absoluteStartTime+v._changeDuration+m._delay))){const e=m._currentTime=mt(z-m._startTime,0,l),s=m._ease(e/m._updateDuration),n=m._modifier,g=m._valueType,_=m._tweenType,y=_===i.OBJECT,v=g===r.NUMBER,b=v&&y||0===s||1===s?-1:A.precision;let S,w;if(v)S=w=n(gt(yt(m._fromNumber,m._toNumber,s),b));else if(g===r.UNIT)w=n(gt(yt(m._fromNumber,m._toNumber,s),b)),S=`${w}${m._unit}`;else if(g===r.COLOR){const t=m._fromNumbers,e=m._toNumbers,i=gt(mt(n(yt(t[0],e[0],s)),0,255),0),r=gt(mt(n(yt(t[1],e[1],s)),0,255),0),o=gt(mt(n(yt(t[2],e[2],s)),0,255),0),a=mt(n(gt(yt(t[3],e[3],s),b)),0,1);if(S=`rgba(${i},${r},${o},${a})`,T){const t=m._numbers;t[0]=i,t[1]=r,t[2]=o,t[3]=a}}else if(g===r.COMPLEX){S=m._strings[0];for(let t=0,e=m._toNumbers.length;t<e;t++){const e=n(gt(yt(m._fromNumbers[t],m._toNumbers[t],s),b)),i=m._strings[t+1];S+=`${i?e+i:e}`,T&&(m._numbers[t]=e)}}if(T&&(m._number=w),a||t===o.blend)m._value=S;else{const t=m.property;h=m.target,y?h[t]=S:_===i.ATTRIBUTE?h.setAttribute(t,S):(d=h.style,_===i.TRANSFORM?(h!==u&&(u=h,p=h[c]),p[t]=S,f=1):_===i.CSS?d[t]=S:_===i.CSS_VAR&&d.setProperty(t,S)),B&&(F=1)}}if(f&&m._renderTransforms){let t=_;for(let e in p)t+=`${b[e]}${p[e]}) `;d.transform=t,f=0}m=m._next}!s&&F&&t.onRender(t)}!s&&B&&t.onUpdate(t)}return l&&R?!s&&(l.began&&!X&&C>=d&&!u||X&&C<=p&&u)&&(t.onComplete(t),t.completed=!X):B&&N?f===1/0?t._startTime+=t.duration:t._currentIteration>=f-1&&(t.paused=!0,u||S||(t.completed=!0,s||l&&(X||!l.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,F},Yt=(t,e,s,i,r)=>{const o=t._currentIteration;if(Ut(t,e,s,i,r),t._hasChildren){const a=t,h=a.backwards,l=i?e:a._iterationTime,c=I();let d=0,u=!0;if(!i&&a._currentIteration!==o){const t=a.iterationDuration;wt(a,e=>{if(h){const i=e.duration,r=e._offset+e._delay;s||!(i<=p)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Ut(e,t,s,1,n.FORCE),e.began=!1,e.completed=!1}),s||a.onLoop(a)}wt(a,t=>{const e=gt((l-t._offset)*t._speed,12),n=t._fps<a._fps?t.requestTick(c):r;d+=Ut(t,e,s,i,n),!t.completed&&u&&(u=!1)},h),!s&&d&&a.onRender(a),(u||h)&&a._currentTime>=a.duration&&(a.paused=!0,a.completed||(a.completed=!0,s||(a.onComplete(a),a._resolve(a))))}},Wt={},Vt=(t,e,s)=>{if(s===i.TRANSFORM)return y.get(t)||t;if(s===i.CSS||s===i.ATTRIBUTE&&H(e)&&t in e.style){const e=Wt[t];if(e)return e;{const e=t?M(t):t;return Wt[t]=e,e}}return t},Ht=t=>{if(t._hasChildren)wt(t,Ht,!0);else{const e=t;e.pause(),wt(e,t=>{const s=t.property,r=t.target;if(r[h]){const n=r.style,o=e._inlineStyles[s];if(t._tweenType===i.TRANSFORM){const e=r[c];if(W(o)||o===_?delete e[s]:e[s]=o,t._renderTransforms)if(Object.keys(e).length){let t=_;for(let s in e)t+=b[s]+e[s]+") ";n.transform=t}else n.removeProperty("transform")}else W(o)||o===_?n.removeProperty(s):n[s]=o;e._tail===t&&e.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===_&&t.removeAttribute("style")})}})}return t};class qt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._elapsedTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=gt(f/g,0),this._fps=g,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<p?p:s,r=gt(f/i,0);this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<p?p:e}requestTick(t){const e=this._scheduledTime,s=this._elapsedTime;if(this._elapsedTime+=t-s,s<e)return n.NONE;const i=this._frameDuration,r=s-e;return this._scheduledTime+=r<i?i:r,n.AUTO}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const jt={animation:null,update:T},Qt=t=>{let e=jt.animation;return e||(e={duration:p,computeDeltaTime:T,_offset:0,_delay:0,_head:null,_tail:null},jt.animation=e,jt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=t===r.COMPLEX||t===r.COLOR?Tt(i._fromNumbers):null;let n=i._fromNumber,o=s._tail;for(;o&&o!==i;){if(e)for(let t=0,s=o._numbers.length;t<s;t++)e[t]+=o._numbers[t];else n+=o._number;o=o._prevAdd}i._toNumber=n,i._toNumbers=e}}}),Ut(e,1,1,0,n.FORCE)}),e},Gt=(()=>t?requestAnimationFrame:setImmediate)(),Jt=(()=>t?cancelAnimationFrame:clearImmediate)();class Zt extends qt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=R,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=I();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(xt(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Yt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):n.AUTO),i=r}jt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(I()),this.reqId=Gt(te)),this}pause(){if(this.reqId)return this.paused=!0,ee()}resume(){if(this.paused)return this.paused=!1,wt(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===A.timeScale?1:f)}set speed(t){this._speed=t*A.timeScale,wt(this,t=>t.speed=t._speed)}get timeUnit(){return 1===A.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(A.timeScale!==s){A.timeScale=s,A.tickThreshold=200*s;const t=e?.001:f;this.defaults.duration*=t,this._speed*=t}}get precision(){return A.precision}set precision(t){A.precision=t}}const Kt=(()=>{const e=new Zt(I());return t&&(D.engine=e,s.addEventListener("visibilitychange",()=>{e.pauseOnDocumentHidden&&(s.hidden?e.pause():e.resume())})),e})(),te=()=>{Kt._head?(Kt.reqId=Gt(te),Kt.update()):Kt.reqId=0},ee=()=>(Jt(Kt.reqId),Kt.reqId=0,Kt),se={_rep:new WeakMap,_add:new Map},ie=(t,e,s="_rep")=>{const i=se[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},re=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,ne=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=p,t._currentTime=p},oe=(t,e)=>{const s=t._composition;if(s===o.replace){const s=t._absoluteStartTime;Et(e,t,re,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){ne(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)ne(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=gt(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<p&&ne(i)}let o=!0;if(wt(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;wt(t,t=>{t!==e&&wt(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===o.blend){const e=ie(t.target,t.property,"_add"),s=Qt(se._add);let i=e._head;i||(i={...t},i._composition=o.replace,i._updateDuration=p,i._startTime=0,i._numbers=Tt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,Et(e,i),Et(s,i));const r=t._toNumber;if(t._fromNumber=i._fromNumber-r,t._toNumber=0,t._numbers=Tt(t._fromNumbers),t._number=0,i._fromNumber=r,t._toNumbers){const e=Tt(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}Et(e,t,null,"_prevAdd","_nextAdd")}return t},ae=t=>{const e=t._composition;if(e!==o.none){const s=t.target,i=t.property,r=se._rep.get(s)[i];if(xt(r,t,"_prevRep","_nextRep"),e===o.blend){const e=se._add,r=e.get(s);if(!r)return;const n=r[i],o=jt.animation;xt(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){xt(n,a,"_prevAdd","_nextAdd"),xt(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},he=(t,e,s)=>{let r=!1;return wt(e,n=>{const o=n.target;if(t.includes(o)){const t=n.property,a=n._tweenType,h=Vt(s,o,a);(!h||h&&h===t)&&(n.parent._tail===n&&n._tweenType===i.TRANSFORM&&n._prev&&n._prev._tweenType===i.TRANSFORM&&(n._prev._renderTransforms=1),xt(e,n),ae(n),r=!0)}},!0),r},le=(t,e,s)=>{const i=e||Kt;let r;if(i._hasChildren){let e=0;wt(i,n=>{if(!n._hasChildren)if(r=he(t,n,s),r&&!n._head)n.cancel(),xt(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?le(t,n,s):n._hasChildren=!1},!0),W(i.iterationDuration)||(i.iterationDuration=e)}else r=he(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},ce=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),de=t=>t._cancelled?(t._hasChildren?wt(t,de):wt(t,t=>{t._composition!==o.none&&oe(t,ie(t.target,t.property))}),t._cancelled=0,t):t;let ue=0;class pe extends qt{constructor(t={},e=null,s=0){super(0);const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:h,loopDelay:l,autoplay:c,frameRate:d,playbackRate:u,onComplete:m,onLoop:f,onPause:g,onBegin:_,onBeforeUpdate:y,onUpdate:v}=t;L.current&&L.current.register(this);const b=e?0:Kt._elapsedTime,S=e?e.defaults:A.defaults,w=Y(r)||W(r)?S.delay:+r,x=Y(n)||W(n)?1/0:+n,E=Rt(h,S.loop),C=Rt(l,S.loopDelay),k=!0===E||E===1/0||E<0?1/0:E+1;let $=0;e?$=s:(Kt.reqId||Kt.requestTick(I()),$=(Kt._elapsedTime-Kt._startTime)*A.timeScale),this.id=W(i)?++ue:i,this.parent=e,this.duration=vt((x+C)*k-C)||p,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=_||S.onBegin,this.onBeforeUpdate=y||S.onBeforeUpdate,this.onUpdate=v||S.onUpdate,this.onLoop=f||S.onLoop,this.onPause=g||S.onPause,this.onComplete=m||S.onComplete,this.iterationDuration=x,this.iterationCount=k,this._autoplay=!e&&Rt(c,S.autoplay),this._offset=$,this._delay=w,this._loopDelay=C,this._iterationTime=0,this._currentIteration=0,this._resolve=T,this._running=!1,this._reversed=+Rt(o,S.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=Rt(a,S.alternate),this._prev=null,this._next=null,this._elapsedTime=b,this._startTime=b,this._lastTime=b,this._fps=Rt(d,S.frameRate),this._speed=Rt(u,S.playbackRate)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(1).play()}get currentTime(){return mt(gt(this._currentTime,A.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return gt(this._iterationTime,A.precision)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return mt(gt(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return mt(gt(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*mt(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=0){return de(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Yt(this,0,1,t,n.FORCE),ce(this),this._hasChildren&&wt(this,ce),this}init(t=0){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Yt(this,this.duration,1,t,n.FORCE),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!W(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*Kt._speed);return this._startTime=I()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=p&&!this._hasChildren?Yt(this,p,0,0,n.FORCE):(this._running||(Et(Kt,this),Kt._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,Kt.wake()),this):this}restart(){return this.reset(0).resume()}seek(t,e=0,s=0){de(this),this.completed=!1;const i=this.paused;return this.paused=!0,Yt(this,t+this._delay,~~e,~~s,n.AUTO),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?ht(m/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?wt(this,t=>t.cancel(),!0):wt(this,ae),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=bt(t);if(e===s)return this;const i=t/e,r=t<=p;return this.duration=r?p:s,this.iterationDuration=r?p:bt(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Yt(this,0,1,0,n.AUTO);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(){return this.seek(this.duration).cancel()}then(t=T){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=T};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const me=t=>new pe(t,null,0).init();function fe(t){const e=U(t)?L.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function ge(e){if(V(e))return[];if(!t)return P(e)&&e.flat(1/0)||[e];if(P(e)){const t=e.flat(1/0),s=[];for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!V(i)){const t=fe(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!V(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=fe(e);return s?Array.from(s):[e]}function _e(t){const e=ge(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[a]){s[a]=!0;const t=H(s);(s.nodeType||t)&&(s[h]=!0,s[l]=t,s[c]={})}}return e}const ye={deg:1,rad:180/ut,turn:360},ve={},be=(t,e,i,n=!1)=>{const o=e.u,a=e.n;if(e.t===r.UNIT&&o===i)return e;const h=a+o+i,l=ve[h];if(W(l)||n){let r;if(o in ye)r=a*ye[o]/ye[i];else{const e=100,n=t.cloneNode(),h=t.parentNode,l=h&&h!==s?h:s.body;l.appendChild(n);const c=n.style;c.width=e+o;const d=n.offsetWidth||e;c.width=e+i;const u=d/(n.offsetWidth||e);l.removeChild(n),r=u*a}e.n=r,ve[h]=r}else e.n=l;return e.t,e.u=i,e},Te=t=>t,Se=(t=1.68)=>e=>et(e,+t),we={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},xe=(t,e,s)=>{if(s[t])return s[t];if(t.indexOf("(")<=-1){const i=we[t]||t.includes("Back")||t.includes("Elastic")?e[t]():e[t];return i?s[t]=i:Te}{const i=t.slice(0,-1).split("("),r=e[i[0]];return r?s[t]=r(...i[1].split(",")):Te}},Ee=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,Ce=(t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=Ee(r,e,s)-t,i>0?o=r:n=r}while(nt(i)>1e-7&&++a<100);return r},ke=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?Te:r=>0===r||1===r?r:Ee(Ce(r,t,s),e,i),$e=(t=10,e)=>{const s=e?at:ht;return e=>s(mt(e,0,1)*t)*(1/t)},Oe=(...t)=>{const e=t.length;if(!e)return Te;const s=e-1,i=t[0],r=t[s],n=[0],o=[tt(i)];for(let e=1;e<s;e++){const i=t[e],r=U(i)?i.trim().split(" "):[i],a=r[0],h=r[1];n.push(W(h)?e/s:tt(h)/100),o.push(tt(a))}return o.push(tt(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},Be=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(mt(o,r,1))}return s.push(1),Oe(...s)},Ne=ut/2,Re=2*ut,Le={[_]:Se,Quad:Se(2),Cubic:Se(3),Quart:Se(4),Quint:Se(5),Sine:t=>1-rt(t*Ne),Circ:t=>1-st(1-t*t),Expo:t=>t?et(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=et(2,--s))-1)/11;);return 1/et(4,3-s)-7.5625*et((3*e-2)/22-t,2)},Back:(t=1.70158)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=mt(+t,1,10),i=mt(+e,p,2),r=i/Re*lt(1/s),n=Re/i;return t=>0===t||1===t?t:-s*et(2,-10*(1-t))*it((1-t-r)*n)}},Ae=(()=>{const t={linear:Oe,irregular:Be,steps:$e,cubicBezier:ke};for(let e in we)for(let s in Le){const i=Le[s],r=we[e];t[e+s]=s===_||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),De={linear:Te},Me=t=>Y(t)?t:U(t)?xe(t,Ae,De):Te,Fe=It(),Ie=It(),Pe={func:null},ze=[null],Xe=[null,null],Ue={to:null};let Ye,We,Ve=0;const He=(t,e)=>{const s={};if(P(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(J);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];J(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=Rt(e.duration,A.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(J(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,h=n[a-1];const l={to:r[t]};let c=0;for(let t=0;t<a;t++)c+=n[t].duration;1===a&&(l.from=h.to),r.ease&&(l.ease=r.ease),l.duration=o-(a?c:0),n.push(l)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s};class qe extends pe{constructor(t,e,s,n,a=!1,h=0,l=0){super(e,s,n);const c=_e(t),d=c.length,u=e.keyframes,m=u?St(He(u,e),e):e,{delay:g,duration:_,ease:y,playbackEase:v,modifier:b,composition:T,onRender:S}=m,w=s?s.defaults:A.defaults,x=Rt(v,w.playbackEase),E=x?Me(x):null,C=!W(y)&&!W(y.ease),k=C?y.ease:Rt(y,E?"linear":w.ease),$=C?y.duration:Rt(_,w.duration),O=Rt(g,w.delay),B=b||w.modifier,N=W(T)&&d>=f?o.none:W(T)?w.composition:T,R={},L=this._offset+(s?s._offset:0);let D=NaN,M=NaN,F=0,I=0;for(let t=0;t<d;t++){const e=c[t],n=h||t,u=l||d;let f=NaN,g=NaN;for(let t in m)if(J(t)){const h=At(e,t),l=Vt(t,e,h);let c=m[t];const d=P(c);if(a&&!d&&(Xe[0]=c,Xe[1]=c,c=Xe),d){const t=c.length,e=!z(c[0]);2===t&&e?(Ue.to=c,ze[0]=Ue,Ye=ze):t>2&&e?(Ye=[],c.forEach((t,e)=>{e?1===e?(Xe[1]=t,Ye.push(Xe)):Ye.push(t):Xe[0]=t})):Ye=c}else ze[0]=c,Ye=ze;let _=null,y=null,v=NaN,b=0,T=0;for(let t=Ye.length;T<t;T++){const i=Ye[T];z(i)?We=i:(Ue.to=i,We=Ue),Pe.func=null;const a=Lt(We.to,e,n,u,Pe);let c;z(a)&&!W(a.to)?(We=a,c=a.to):c=a;const d=Lt(We.from,e,n,u),m=We.ease,f=!W(m)&&!W(m.ease),g=f?m.ease:m||k,S=f?m.duration:Lt(Rt(We.duration,t>1?Lt($,e,n,u)/t:$),e,n,u),w=Lt(Rt(We.delay,T?0:O),e,n,u),x=Lt(Rt(We.composition,N),e,n,u),E=X(x)?x:o[x],C=We.modifier||B,A=!W(d),D=!W(c),M=P(c),U=M||A&&D,Y=y?b+w:w,V=gt(L+Y,12);I||!A&&!M||(I=1);let H=y;if(E!==o.none){_||(_=ie(e,l));let t=_._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=V;)if(H=t,t=t._nextRep,t&&t._absoluteStartTime>=V)for(;t;)ne(t),t=t._nextRep}if(U?(Pt(M?Lt(c[0],e,n,u):d,Fe),Pt(M?Lt(c[1],e,n,u,Pe):c,Ie),Fe.t===r.NUMBER&&(H?H._valueType===r.UNIT&&(Fe.t=r.UNIT,Fe.u=H._unit):(Pt(Mt(e,l,h,R),Xt),Xt.t===r.UNIT&&(Fe.t=r.UNIT,Fe.u=Xt.u)))):(D?Pt(c,Ie):y?zt(y,Ie):Pt(s&&H&&H.parent.parent===s?H._value:Mt(e,l,h,R),Ie),A?Pt(d,Fe):y?zt(y,Fe):Pt(s&&H&&H.parent.parent===s?H._value:Mt(e,l,h,R),Fe)),Fe.o&&(Fe.n=Ft(H?H._toNumber:Pt(Mt(e,l,h,R),Xt).n,Fe.n,Fe.o)),Ie.o&&(Ie.n=Ft(Fe.n,Ie.n,Ie.o)),Fe.t!==Ie.t)if(Fe.t===r.COMPLEX||Ie.t===r.COMPLEX){const t=Fe.t===r.COMPLEX?Fe:Ie,e=Fe.t===r.COMPLEX?Ie:Fe;e.t=r.COMPLEX,e.s=Tt(t.s),e.d=t.d.map(()=>e.n)}else if(Fe.t===r.UNIT||Ie.t===r.UNIT){const t=Fe.t===r.UNIT?Fe:Ie,e=Fe.t===r.UNIT?Ie:Fe;e.t=r.UNIT,e.u=t.u}else if(Fe.t===r.COLOR||Ie.t===r.COLOR){const t=Fe.t===r.COLOR?Fe:Ie,e=Fe.t===r.COLOR?Ie:Fe;e.t=r.COLOR,e.s=t.s,e.d=[0,0,0,1]}if(Fe.u!==Ie.u){let t=Ie.u?Fe:Ie;t=be(e,t,Ie.u?Ie.u:Fe.u,!1)}if(Ie.d&&Fe.d&&Ie.d.length!==Fe.d.length){const t=Fe.d.length>Ie.d.length?Fe:Ie,e=t===Fe?Ie:Fe;e.d=t.d.map((t,s)=>W(e.d[s])?0:e.d[s]),e.s=Tt(t.s)}const q=gt(+S||p,12),j={parent:this,id:Ve++,property:l,target:e,_value:null,_func:Pe.func,_ease:Me(g),_fromNumbers:Tt(Fe.d),_toNumbers:Tt(Ie.d),_strings:Tt(Ie.s),_fromNumber:Fe.n,_toNumber:Ie.n,_numbers:Tt(Fe.d),_number:Fe.n,_unit:Ie.u,_modifier:C,_currentTime:0,_startTime:Y,_delay:+w,_updateDuration:q,_changeDuration:q,_absoluteStartTime:V,_tweenType:h,_valueType:Ie.t,_composition:E,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};E!==o.none&&oe(j,_),isNaN(v)&&(v=j._startTime),b=gt(Y+q,12),y=j,F++,Et(this,j)}(isNaN(M)||v<M)&&(M=v),(isNaN(D)||b>D)&&(D=b),h===i.TRANSFORM&&(f=F-T,g=F)}if(!isNaN(f)){let t=0;wt(this,e=>{t>=f&&t<g&&(e._renderTransforms=1,e._composition===o.blend&&wt(jt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}d||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),M?(wt(this,t=>{t._startTime-t._delay||(t._delay-=M),t._startTime-=M}),D-=M):M=0,D||(D=p,this.iterationCount=0),this.targets=c,this.duration=D===p?p:vt((D+this._loopDelay)*this.iterationCount-this._loopDelay)||p,this.onRender=S||w.onRender,this._ease=E,this._delay=M,this.iterationDuration=D,this._inlineStyles=R,!this._autoplay&&I&&this.onRender(this)}stretch(t){const e=this.duration;if(e===bt(t))return this;const s=t/e;return wt(this,t=>{t._updateDuration=bt(t._updateDuration*s),t._changeDuration=bt(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return wt(this,t=>{const e=t._func;if(e){const s=Mt(t.target,t.property,t._tweenType);Pt(s,Xt),Pt(e(),Ie),t._fromNumbers=Tt(Xt.d),t._fromNumber=Xt.n,t._toNumbers=Tt(Ie.d),t._strings=Tt(Ie.s),t._toNumber=Ie.o?Ft(Xt.n,Ie.n,Ie.o):Ie.n}}),this}revert(){return super.revert(),Ht(this)}then(t){return super.then(t)}}const je=(t,e)=>new qe(t,e,null,0,!1).init(),Qe={_head:null,_tail:null},Ge=(t,e,s)=>{let i=Qe._head;for(;i;){const r=i._next,n=i.$el===t,o=!e||i.property===e,a=!s||i.parent===s;if(n&&o&&a){const t=i.animation;try{t.commitStyles()}catch{}t.cancel(),xt(Qe,i);const e=i.parent;e&&(e._completed++,e.animations.length===e._completed&&(e.completed=!0,e.muteCallbacks||(e.paused=!0,e.onComplete(e),e._resolve(e))))}i=r}},Je=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Ge(e,s),Et(Qe,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>{Ge(e,s,t)};return n.onremove=a,n.onfinish=a,n};function Ze(t,e,s){const i=_e(t);if(!i.length)return;const[n]=i,o=At(n,e),a=Vt(e,n,o);let h=Mt(n,a);if(W(s))return h;if(Pt(h,Xt),Xt.t===r.NUMBER||Xt.t===r.UNIT){if(!1===s)return Xt.n;{const t=be(n,Xt,s,!1);return`${gt(t.n,A.precision)}${t.u}`}}}const Ke=(t,e)=>{if(!W(e))return e.duration=p,e.composition=Rt(e.composition,o.none),new qe(t,e,null,0,!0).resume()},ts=(t,e,s)=>{const i=ge(t);for(let t=0,r=i.length;t<r;t++)Ge(i[t],s,e&&e.controlAnimation&&e);return le(i,e,s),i},es=(t,e)=>{if(F(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}},ss=(t,e)=>{let s=t.iterationDuration;if(s===p&&(s=0),W(e))return s;if(X(+e))return+e;const i=e,r=t?t.labels:null,n=!V(r),o=es(t,i),a=!W(o),h=N.exec(i);if(h){const t=h[0],e=i.split(t),l=n&&e[0]?r[e[0]]:s,c=a?o:n?l:s,d=+e[1];return Ft(c,d,t[0])}return a?o:n?W(r[i])?s:r[i]:s};function is(t){return vt((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||p}function rs(t,e,s,i,r,o){const a=X(t.duration)&&t.duration<=p?s-p:s;Yt(e,a,1,1,n.AUTO);const h=i?new qe(i,t,e,a,!1,r,o):new pe(t,e,a);return h.init(1),Et(e,h),wt(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=is(e),e}class ns extends pe{constructor(t={}){super(t,null,0),this.duration=0,this.labels={};const e=t.defaults,s=A.defaults;this.defaults=e?St(e,s):s,this.onRender=t.onRender||s.onRender;const i=Rt(t.playbackEase,s.playbackEase);this._ease=i?Me(i):null,this.iterationDuration=0}add(t,e,s){const i=z(e),r=z(t);if(i||r){if(this._hasChildren=!0,i){const i=e;if(Y(s)){const e=s,r=ge(t),n=this.duration,o=this.iterationDuration,a=i.id;let h=0;const l=r.length;r.forEach(t=>{const s={...i};this.duration=n,this.iterationDuration=o,W(a)||(s.id=a+"-"+h),rs(s,this,ss(this,e(t,h,l,this)),t,h,l),h++})}else rs(i,this,ss(this,s),t)}else rs(t,this,ss(this,e));return this.init(1)}}sync(t,e){if(W(t)||t&&W(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return this.add(t,{currentTime:[0,s],duration:s,ease:"linear"},e)}set(t,e,s){return W(e)?this:(e.duration=p,e.composition=o.replace,this.add(t,e,s))}call(t,e){return W(t)||t&&!Y(t)?this:this.add({duration:0,onComplete:()=>t(this)},e)}label(t,e){return W(t)||t&&!U(t)||(this.labels[t]=ss(this,e)),this}remove(t,e){return le(ge(t),this,e),this}stretch(t){const e=this.duration;if(e===bt(t))return this;const s=t/e,i=this.labels;wt(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return wt(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),wt(this,t=>t.revert,!0),Ht(this)}then(t){return super.then(t)}}const os=t=>new ns(t).init();class as{constructor(t,e){L.current&&L.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},r={v:1,autoplay:!1},n={};if(this.targets=[],this.animations={},this.callbacks=null,!W(t)&&!W(e)){for(let t in e){const s=e[t];J(t)?n[t]=s:F(t,"on")?r[t]=s:i[t]=s}this.callbacks=new qe({v:0},r);for(let e in n){const s=n[e],r=z(s);let a={},h="+=0";if(r){const t=s.unit;U(t)&&(h+=t)}else a.duration=s;a[e]=r?St({to:h},s):h;const l=St(i,a);l.composition=o.replace,l.autoplay=!1;const c=this.animations[e]=new qe(t,l,null,0,!1).init();this.targets.length||this.targets.push(...c.targets),this[e]=(t,e,s)=>{const i=c._head;if(W(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return wt(c,e=>{if(P(t))for(let s=0,i=t.length;s<i;s++)W(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;W(s)||(e._ease=Me(s)),e._currentTime=0}),W(e)||c.stretch(e),c.reset(1).resume(),this}}}}revert(){for(let t in this.animations)this[t]=T,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const hs=(t,e)=>new as(t,e),ls=(t,e)=>(+t).toFixed(e),cs=(t,e,s)=>`${t}`.padStart(e,s),ds=(t,e,s)=>`${t}`.padEnd(e,s),us=(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e,ps=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i),ms=t=>t*Math.PI/180,fs=t=>180*t/Math.PI,gs=(t,e,s,i)=>i?1===i?e:yt(t,e,1-Math.exp(-i*s*.1)):t;var _s=Object.freeze({__proto__:null,clamp:mt,damp:gs,degToRad:ms,lerp:yt,mapRange:ps,padEnd:ds,padStart:cs,radToDeg:fs,round:gt,roundPad:ls,snap:_t,wrap:us});const ys=10*f;class vs{constructor(t={}){this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/f,this.maxIterations=this.maxDuration/this.timeStep/f,this.m=mt(Rt(t.mass,1),0,ys),this.s=mt(Rt(t.stiffness,100),1,ys),this.d=mt(Rt(t.damping,10),.1,ys),this.v=mt(Rt(t.velocity,0),-1e4,ys),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.solverDuration=0,this.duration=0,this.compute(),this.ease=t=>0===t||1===t?t:this.solve(t*this.solverDuration)}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?ot(-n*e*s)*(1*rt(i*n)+r*it(i*n)):(1+r*n)*ot(-n*s),1-n}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,h=this.w0=mt(st(o/r),p,f),l=this.zeta=n/(2*st(o*r)),c=this.wd=l<1?h*st(1-l*l):0;this.b=l<1?(l*h-a)/c:-a+h;let d=0,u=0,m=0;for(;u<t&&m<e;)nt(1-this.solve(d))<s?u++:u=0,this.solverDuration=d,d+=i,m++;this.duration=gt(this.solverDuration*f,0)*A.timeScale}get mass(){return this.m}set mass(t){this.m=mt(Rt(t,1),0,ys),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=mt(Rt(t,100),1,ys),this.compute()}get damping(){return this.d}set damping(t){this.d=mt(Rt(t,10),.1,ys),this.compute()}get velocity(){return this.v}set velocity(t){this.v=mt(Rt(t,0),-1e4,ys),this.compute()}}const bs=t=>new vs(t),Ts=t=>{t.cancelable&&t.preventDefault()};class Ss{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:T,remove:T}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class ws{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,i=0;for(;e&&e!==s;)t(e,i),e=e.parentElement,i++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const xs=(t,e)=>t&&Y(t)?t(e):t;let Es=0;class Cs{constructor(t,i={}){if(!t)return;L.current&&L.current.register(this);const r=i.x,n=i.y,o=i.trigger,a=i.modifier,h=i.releaseEase,l=h&&Me(h),c=!W(h)&&!W(h.ease),d=z(r)&&!W(r.mapTo)?r.mapTo:"translateX",u=z(n)&&!W(n.mapTo)?n.mapTo:"translateY",p=xs(i.container,this);this.containerArray=P(p)?p:null,this.$container=p&&!this.containerArray?ge(p)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.$target=z(t)?new Ss(t):ge(t)[0],this.$trigger=ge(o||t)[0],this.fixed="fixed"===Ze(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=c?h:bs({mass:Rt(i.releaseMass,1),stiffness:Rt(i.releaseStiffness,80),damping:Rt(i.releaseDamping,20)}),this.releaseYSpring=c?h:bs({mass:Rt(i.releaseMass,1),stiffness:Rt(i.releaseStiffness,80),damping:Rt(i.releaseDamping,20)}),this.releaseEase=l||Ae.outQuint,this.hasReleaseSpring=c,this.onGrab=i.onGrab||T,this.onDrag=i.onDrag||T,this.onRelease=i.onRelease||T,this.onUpdate=i.onUpdate||T,this.onSettle=i.onSettle||T,this.onSnap=i.onSnap||T,this.onResize=i.onResize||T,this.onAfterResize=i.onAfterResize||T,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),W(r)||!0===r)f[d]=0;else if(z(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[d]=e}else!1===r&&(f[d]=0,this.disabled[0]=1);if(W(n)||!0===n)f[u]=0;else if(z(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[u]=e}else!1===n&&(f[u]=0,this.disabled[1]=1);this.animate=new as(this.$target,f),this.xProp=d,this.yProp=u,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-m,m,m,-m],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=I(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new ws(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new pe({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new pe({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!W(p),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?d:u,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=dt(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new pe({autoplay:!1,duration:150*A.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=i,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),z(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=I(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,h=this.maxVelocity,l=this.velocityStackIndex;n[l]=gt(mt(st(t*t+e*e)/r*o,a,h),5);const c=ct(n[0],n[1],n[2]);return this.velocity=c,this.velocityStackIndex=(l+1)%3,c}setX(t,e=!1){if(this.disabled[0])return;const s=gt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=_t(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=gt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=_t(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return gt(this.animate[this.xProp](),A.precision)}set x(t){this.setX(t,!1)}get y(){return gt(this.animate[this.yProp](),A.precision)}set y(t){this.setY(t,!1)}get progressX(){return ps(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(ps(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return ps(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(ps(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=gt(this.useWin?e.scrollX:this.$container.scrollLeft,0),s=gt(this.useWin?e.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=s,this.scrollBounds[0]=s-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=s-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const i=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=e.innerWidth,h=this.window[1]=e.innerHeight,l=this.useWin,c=t.scrollWidth,d=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,_]=this.containerPadding;this.dragArea[0]=l?0:p.left,this.dragArea[1]=l?0:p.top,this.scrollView[0]=l?mt(c,a,c):c,this.scrollView[1]=l?mt(d,h,d):d,this.updateScrollCoords();const{width:y,height:v,left:b,top:T,right:S,bottom:w}=t.getBoundingClientRect();this.dragArea[2]=gt(l?mt(y,a,a):y,0),this.dragArea[3]=gt(l?mt(v,h,h):v,0);const x=Ze(t,"overflow"),E="visible"===x,C="hidden"===x;if(this.canScroll=!u&&this.contained&&(t===s.body&&E||!C&&!E)&&(c>this.dragArea[2]+_-f||d>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!P(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?l?0:t.scrollLeft:0,o=i?l?0:t.scrollTop:0,c=i?this.scrollView[0]-n-y:0,d=i?this.scrollView[1]-o-v:0;this.targetBounds[0]=gt(r.top+s-(l?0:T),0),this.targetBounds[1]=gt(r.right+e-(l?a:S),0),this.targetBounds[2]=gt(r.bottom+s-(l?h:w),0),this.targetBounds[3]=gt(r.left+e-(l?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+_):(this.containerBounds[0]=-gt(r.top-(u?mt(T,0,h):T)+o-m,0),this.containerBounds[1]=-gt(r.right-(u?mt(S,0,a):S)-c+f,0),this.containerBounds[2]=-gt(r.bottom-(u?mt(w,0,h):w)-d+g,0),this.containerBounds[3]=-gt(r.left-(u?mt(b,0,a):b)+n-_,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(i,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,h]=this.disabled,l=!a&&e<o||!a&&e>r,c=!h&&s<i||!h&&s>n;return l&&!c?1:!l&&c?2:l&&c?3:0}refresh(){const t=this.parameters,i=t.x,r=t.y,n=xs(t.container,this),o=xs(t.containerPadding,this)||0,a=P(o)?o:[o,o,o,o],h=this.x,l=this.y,c=xs(t.cursor,this),d={onHover:"grab",onGrab:"grabbing"};if(c){const{onHover:t,onGrab:e}=c;t&&(d.onHover=t),e&&(d.onGrab=e)}this.containerArray=P(n)?n:null,this.$container=n&&!this.containerArray?ge(n)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=Rt(a,[0,0,0,0]),this.containerFriction=mt(Rt(xs(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=mt(Rt(xs(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=xs(z(i)&&!W(i.snap)?i.snap:t.snap,this),this.snapY=xs(z(r)&&!W(r.snap)?r.snap:t.snap,this),this.scrollSpeed=Rt(xs(t.scrollSpeed,this),1.5),this.scrollThreshold=Rt(xs(t.scrollThreshold,this),20),this.dragSpeed=Rt(xs(t.dragSpeed,this),1),this.minVelocity=Rt(xs(t.minVelocity,this),0),this.maxVelocity=Rt(xs(t.maxVelocity,this),50),this.velocityMultiplier=Rt(xs(t.velocityMultiplier,this),1),this.cursor=!1!==c&&d,this.updateBoundingValues();const[u,p,m,f]=this.containerBounds;this.setX(mt(h,f,p),!0),this.setY(mt(l,u,m),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],h=this.scroll.x,l=this.scroll.y,c=this.$container.scrollWidth,d=this.$container.scrollHeight,u=this.useWin?mt(c,this.window[0],c):c,p=this.useWin?mt(d,this.window[1],d):d,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,_=this.scrollThreshold,[y,v]=this.coords,[b,T,S,w]=this.scrollBounds,x=gt(mt((v-b+t)/_,-1,0)*g,0),E=gt(mt((y-T-e)/_,0,1)*g,0),C=gt(mt((v-S-s)/_,0,1)*g,0),k=gt(mt((y-w+i)/_,-1,0)*g,0);if(x||C||k||E){const[t,e]=this.disabled;let s=h,i=l;t||(s=gt(mt(h+(k||E),0,r-o),0),this.coords[0]-=h-s),e||(i=gt(mt(l+(x||C),0,n-a),0),this.coords[1]-=l-i),this.useWin?this.$scrollContainer.scrollBy(-(h-s),-(l-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,h,l]=this.pointer;this.coords[0]+=(r-h)*this.dragSpeed,this.coords[1]+=(n-l)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[c,d]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(c>e?e+(c-e)*m:c<i?i+(c-i)*m:c,!1),this.setY(d>s?s+(d-s)*m:d<t?t+(d-t)*m:d,!1),this.computeVelocity(r-h,n-l),this.angle=dt(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return le([this],null,"x"),le([this],null,"y"),le([this],null,"progressX"),le([this],null,"progressY"),le([this.scroll]),le([this.overshootCoords]),this}scrollInView(t,e=0,s=Ae.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[h,l,c,d]=o,u=gt(mt(r-h,-m,0),0),p=gt(mt(i-l,0,m),0),f=gt(mt(r-c,0,m),0),g=gt(mt(i-d,-m,0),0);new qe(n,{x:gt(n.x+(g?g-e:p?p+e:0),0),y:gt(n.y+(u?u-e:f?f+e:0),0),duration:W(t)?350*A.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Ke(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=Ae.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,h]=this.containerPadding,l=this.scroll.y-this.targetBounds[0]+n+e,c=this.scroll.x-this.targetBounds[1]-o-e,d=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+h+e,p=this.isOutOfBounds([l,c,d,u],i,r);if(p){const[e,n]=this.disabled,o=mt(_t(i,this.snapX),u,c),a=mt(_t(r,this.snapY),l,d),h=W(t)?350*A.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,h,s),n||2!==p&&3!==p||this.animate[this.yProp](a,h,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const i=t.changedTouches,r=i?i[0].clientX:t.clientX,n=i?i[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[h,l,c,d]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>l?l+(p-l)/u:p<d?d+(p-d)/u:p:p,this.coords[1]=this.coords[3]=u?m>c?c+(m-c)/u:m<h?h+(m-h)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Ze(this.$target,"zIndex",!1);Es=(f>Es?f:Es)+1,this.targetStyles=Ke(this.$target,{zIndex:Es}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Ke(s.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,Ae.out(3)),this.onGrab(this),s.addEventListener("touchmove",this),s.addEventListener("touchend",this),s.addEventListener("touchcancel",this),s.addEventListener("mousemove",this),s.addEventListener("mouseup",this),s.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let h=t.target,l=!1,c=!1,d=!1;for(;e&&h&&h!==this.$trigger;){const t=Ze(h,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=h;if(e>s){d=!0,l=t<=3,c=t>=e-s-3;break}}h=h.parentElement}d&&(!l&&!c||l&&a<0||c&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(Ts(t),this.triggerStyles||(this.triggerStyles=Ke(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",Ts,{passive:!1}),this.$trigger.addEventListener("touchmove",Ts,{passive:!1}),this.$trigger.addEventListener("touchend",Ts),(!this.disabled[0]&&nt(o)>3||!this.disabled[1]&&nt(a)>3)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[i,r,n,a,h,l]=this.pointer,[c,d,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,_=this.releaseYSpring,y=this.releaseEase,v=this.hasReleaseSpring,b=this.overshootCoords,T=this.x,S=this.y,w=this.computeVelocity(i-h,r-l),x=this.angle=dt(r-a,i-n),E=150*w,C=(1-this.releaseContainerFriction)*this.dragSpeed,k=T+rt(x)*E,$=S+it(x)*E,O=k>d?d+(k-d)*C:k<p?p+(k-p)*C:k,B=$>u?u+($-u)*C:$<c?c+($-c)*C:$,N=this.destX=mt(gt(_t(O,this.snapX),5),p,d),R=this.destY=mt(gt(_t(B,this.snapY),5),c,u),L=this.isOutOfBounds(this.containerBounds,k,$);let D=0,M=0,F=y,I=y,P=0;if(b.x=T,b.y=S,!t){const t=N===d?T>d?-1:1:T<p?-1:1,s=gt(T-N,0);g.velocity=e&&v?s?E*t/nt(s):0:w;const{ease:i,duration:r,restDuration:n}=g;D=T===N?0:v?r:r-n*A.timeScale,v&&(F=i),D>P&&(P=D)}if(!e){const e=R===u?S>u?-1:1:S<c?-1:1,s=gt(S-R,0);_.velocity=t&&v?s?E*e/nt(s):0:w;const{ease:i,duration:r,restDuration:n}=_;M=S===R?0:v?r:r-n*A.timeScale,v&&(I=i),M>P&&(P=M)}if(!v&&L&&C&&(D||M)){const t=o.blend;new qe(b,{x:{to:O,duration:.65*D},y:{to:B,duration:.65*M},ease:y,composition:t}).init(),new qe(b,{x:{to:N,duration:D},y:{to:R,duration:M},ease:y,composition:t}).init(),this.overshootTicker.stretch(ct(D,M)).restart()}else t||this.animate[this.xProp](N,D,F),e||this.animate[this.yProp](R,M,I);this.scrollInView(P,this.scrollThreshold,y);let z=!1;N!==m&&(this.snapped[0]=N,this.snapX&&(z=!0)),R!==f&&this.snapY&&(this.snapped[1]=R,this.snapY&&(z=!0)),z&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",Ts),this.$trigger.removeEventListener("touchmove",Ts),this.$trigger.removeEventListener("touchend",Ts),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Ke(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":Ts(t)}}}const ks=(t,e)=>new Cs(t,e),$s=(t=T)=>new pe({duration:1*A.timeScale,onComplete:t},null,0).resume(),Os=t=>{let e;return(...s)=>{let i,r,n,o;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,e.revert());const a=t(...s);return a&&!Y(a)&&a.revert&&(e=a),W(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r),a||T}};class Bs{constructor(t={}){L.current&&L.current.register(this);const i=t.root;let r=s;i&&(r=i.current||i.nativeElement||ge(i)[0]||s);const n=t.defaults,o=A.defaults,a=t.mediaQueries;if(this.defaults=n?St(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const s=e.matchMedia(a[t]);this.mediaQueryLists[t]=s,s.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=L.current,s=L.root,i=A.defaults;L.current=this,L.root=this.root,A.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return L.current=e,L.root=s,A.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);Y(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,Y(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);Y(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,Y(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);Y(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(Y(s))return s(this);const i=Os(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,h=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;h--;)i[h](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const Ns=t=>new Bs(t),Rs=()=>{const t=s.createElement("div");s.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return s.body.removeChild(t),e},Ls=(t,e)=>t&&Y(t)?t(e):t,As=new Map;class Ds{constructor(t){this.element=t,this.useWin=this.element===s.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new pe({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;wt(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new pe({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=gt(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new pe({autoplay:!1,duration:250*A.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new pe({autoplay:!1,duration:500*A.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?e:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,s=this.element;this.scrollX=gt(t?e.scrollX:s.scrollLeft,0),this.scrollY=gt(t?e.scrollY:s.scrollTop,0)}updateWindowBounds(){this.winWidth=e.innerWidth,this.winHeight=Rs()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left}this.width=s,this.height=i}refreshScrollObservers(){wt(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),wt(this,t=>{t.refresh(),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?e:this.element).removeEventListener("scroll",this),As.delete(this.element)}}const Ms=t=>{const e=t&&ge(t)[0]||s.body;let i=As.get(e);return i||(i=new Ds(e),As.set(e,i)),i},Fs=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:h,u:l}=Pt(a,Xt);let c=h;return"%"===l?c=h/100*s:l&&(c=be(t,Xt,"px",!0).n),o&&i<0&&(c+=i),n&&r>0&&(c+=r),c},Is=(t,e,s,i,r)=>{let n;if(U(e)){const o=N.exec(e);if(o){const a=o[0],h=a[0],l=e.split(a),c="min"===l[0],d="max"===l[0],u=Fs(t,l[0],s,i,r),p=Fs(t,l[1],s,i,r);if(c){const e=Ft(Fs(t,"min",s),p,h);n=e<u?u:e}else if(d){const e=Ft(Fs(t,"max",s),p,h);n=e>u?u:e}else n=Ft(u,p,h)}else n=Fs(t,e,s,i,r)}else n=e;return gt(n,0)},Ps=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[h]){e=i;break}}return e};let zs=0;const Xs=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class Us{constructor(t={}){L.current&&L.current.register(this);const e=Rt(t.sync,"play pause"),i=e?Me(e):null,r=e&&("linear"===e||e===Te),n=e&&!(i===Te&&!r),o=e&&(X(e)||!0===e||r),a=e&&U(e)&&!n&&!o,h=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,l=a&&h.length>2;this.index=zs++,this.id=W(t.id)?this.index:t.id,this.container=Ms(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!h,this.syncEase=n?i:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=h&&!l&&h[0]?h[0]:T,this.onSyncLeave=h&&!l&&h[1]?h[1]:T,this.onSyncEnterForward=h&&l&&h[0]?h[0]:T,this.onSyncLeaveForward=h&&l&&h[1]?h[1]:T,this.onSyncEnterBackward=h&&l&&h[2]?h[2]:T,this.onSyncLeaveBackward=h&&l&&h[3]?h[3]:T,this.onEnter=t.onEnter||T,this.onLeave=t.onLeave||T,this.onEnterForward=t.onEnterForward||T,this.onLeaveForward=t.onLeaveForward||T,this.onEnterBackward=t.onEnterBackward||T,this.onLeaveBackward=t.onLeaveBackward||T,this.onUpdate=t.onUpdate||T,this.onSyncComplete=t.onSyncComplete||T,this.reverted=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=Rt(t.debug,!1),this._next=null,this._prev=null,Et(this.container,this),$s(()=>{if(!this.reverted){if(!this.target){const e=ge(t.target)[0];this.target=e||s.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,!this._params.target)){let e;W(t.targets)?wt(t,t=>{t.targets&&!e&&(e=Ps(t))}):e=Ps(t),this.target=e||s.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:gt(mt(t,0,1),6)}refresh(){this.reverted=!1;const t=this._params;return this.repeat=Rt(Ls(t.repeat,this),!0),this.horizontal="x"===Rt(Ls(t.axis,this),"y"),this.enter=Rt(Ls(t.enter,this),"end start"),this.leave=Rt(Ls(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,i=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=s.createElement("div"),n=s.createElement("div"),o=s.createElement("div"),a=Xs[this.index%Xs.length],h=t.useWin,l=h?t.winWidth:t.width,c=h?t.winHeight:t.height,d=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,_=e?g:15,y=e?60:g,v=e?y:_,b=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",S=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,w=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${w("absolute",m,f,e?d:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${w("sticky",0,0,e?l:g,e?g:c)}`,i||(n.style.cssText+=`background:\n ${S("#FFFF")}${T(g-10)} / 100px 100px ${b},\n ${S("#FFF8")}${T(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${w("relative",0,0,e?d:g,e?g:u)}`,i||(o.style.cssText+=`background:\n ${S("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${S("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const x=[" enter: "," leave: "];this.coords.forEach((t,i)=>{const r=i>1,h=(r?0:this.offset)+t,m=i%2,f=h<v,g=h>(r?e?l:c:e?d:u)-v,b=(r?m&&!f:!m&&!f)||g,T=s.createElement("div"),S=s.createElement("div"),E=e?b?"right":"left":b?"bottom":"top",C=b?(e?y:_)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;S.innerHTML=`${this.id}${x[m]}${this.thresholds[i]}`,T.style.cssText=`${w("absolute",0,0,y,_)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${E}: 2px solid ${a};\n `,S.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${_};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(S);let k=h-C+(e?1:0);T.style[e?"left":"top"]=`${k}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),i||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Ze(t.element,"position")&&(this.debugStyles=Ke(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,i=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0)),a.parentElement;a&&a!==i.element&&a!==s.body;){const e="sticky"===Ze(a,"position")&&Ke(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const h=e.getBoundingClientRect(),l=r?h.left+i.scrollX-i.left:h.top+i.scrollY-i.top,c=r?h.width:h.height,d=r?i.width:i.height,u=(r?i.scrollWidth:i.scrollHeight)-d,p=this.enter,m=this.leave;let f="start",g="end",_="end",y="start";if(U(p)){const t=p.split(" ");_=t[0],f=t.length>1?t[1]:f}else if(z(p)){const t=p;W(t.container)||(_=t.container),W(t.target)||(f=t.target)}else X(p)&&(_=p);if(U(m)){const t=m.split(" ");y=t[0],g=t.length>1?t[1]:g}else if(z(m)){const t=m;W(t.container)||(y=t.container),W(t.target)||(g=t.target)}else X(m)&&(y=m);const v=Is(e,f,c),b=Is(e,g,c),T=v+l-d,S=b+l-u,w=Is(e,_,d,T,S),x=Is(e,y,d,T,S),E=v+l-w,C=b+l-x,k=C-E;this.offset=l,this.offsetStart=E,this.offsetEnd=C,this.distance=k<=0?0:k,this.thresholds=[f,g,_,y],this.coords=[v,b,w,x],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,h=a<=this.offsetStart,l=a>=this.offsetEnd,c=!h&&!l,d=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&d,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(h&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&X(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=gt(yt(e,g,yt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(c&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(c&&(this.isInView=!0),this.forceEnter&&this.hasEntered?c&&(this.forceEnter=!1):(p&&c&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(c||!c&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!c&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return xt(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this}}const Ys=(t={})=>new Us(t);var Ws=Object.freeze({__proto__:null,cubicBezier:ke,eases:Ae,irregular:Be,linear:Oe,none:Te,steps:$e});const Vs=_s,Hs={},qs=(t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s),js=t=>(...e)=>{const s=t(...e);return new Proxy(T,{apply:(t,e,[i])=>s(i),get:(t,e)=>js((...t)=>{const i=Hs[e](...t);return t=>i(s(t))})})},Qs=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?js(qs(e,s)):e)(...t);return Hs[t]||(Hs[t]=i),i},Gs=Qs("roundPad",Vs.roundPad),Js=Qs("padStart",Vs.padStart),Zs=Qs("padEnd",Vs.padEnd),Ks=Qs("wrap",Vs.wrap),ti=Qs("mapRange",Vs.mapRange),ei=Qs("degToRad",Vs.degToRad),si=Qs("radToDeg",Vs.radToDeg),ii=Qs("snap",Vs.snap),ri=Qs("clamp",Vs.clamp),ni=Qs("round",Vs.round),oi=Qs("lerp",Vs.lerp,1),ai=Qs("damp",Vs.damp,1),hi=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let li=0;const ci=(t,e=0,s=1,i=0)=>{let r=void 0===t?li++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},di=t=>t[hi(0,t.length-1)],ui=t=>{let e,s,i=t.length;for(;i;)s=hi(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},pi=(t,e={})=>{let s=[],i=0;const r=e.from,n=e.reversed,o=e.ease,a=!W(o),h=a&&!W(o.ease)?o.ease:a?Me(o):null,l=e.grid,c=e.axis,d=e.total,u=W(r)||0===r||"first"===r,p="center"===r,m="last"===r,f="random"===r,g=P(t),y=e.use,v=tt(g?t[0]:t),b=g?tt(t[1]):0,T=$.exec((g?t[1]:t)+_),S=e.start||0+(g?v:0);let w=u?0:X(r)?r:0;return(t,r,o,a)=>{const[u]=_e(t),_=W(d)?o:d,x=!W(y)&&(Y(y)?y(u,r,_):Mt(u,y)),E=X(x)||U(x)&&X(+x)?+x:r;if(p&&(w=(_-1)/2),m&&(w=_-1),!s.length){for(let t=0;t<_;t++){if(l){const e=p?(l[0]-1)/2:w%l[0],i=p?(l[1]-1)/2:ht(w/l[0]),r=e-t%l[0],n=i-ht(t/l[0]);let o=st(r*r+n*n);"x"===c&&(o=-r),"y"===c&&(o=-n),s.push(o)}else s.push(nt(w-t));i=ct(...s)}h&&(s=s.map(t=>h(t/i)*i)),n&&(s=s.map(t=>c?t<0?-1*t:-t:nt(i-t))),f&&(s=ui(s))}const C=g?(b-v)/i:v;let k=(a?ss(a,W(e.start)?a.iterationDuration:S):S)+(C*gt(s[E],2)||0);return e.modifier&&(k=e.modifier(k)),T&&(k=`${k}${T[2]}`),k}};var mi=Object.freeze({__proto__:null,$:_e,clamp:ri,cleanInlineStyles:Ht,createSeededRandom:ci,damp:ai,degToRad:ei,get:Ze,keepTime:Os,lerp:oi,mapRange:ti,padEnd:Zs,padStart:Js,radToDeg:si,random:hi,randomPick:di,remove:ts,round:ni,roundPad:Gs,set:Ke,shuffle:ui,snap:ii,stagger:pi,sync:$s,wrap:Ks});const fi=t=>{const e=ge(t)[0];return e&&H(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},gi=(t,e,s=0)=>t.getPointAtLength(e+s>=1?e+s:0),_i=(t,e)=>s=>{const i=+t.getTotalLength(),r=s[l],n=t.getCTM();return{from:0,to:i,modifier:s=>{if("a"===e){const e=gi(t,s,-1),i=gi(t,s,1);return 180*dt(i.y-e.y,i.x-e.x)/ut}{const i=gi(t,s,0);return"x"===e?r||!n?i.x:i.x*n.a+i.y*n.c+n.e:r||!n?i.y:i.x*n.b+i.y*n.d+n.f}}}},yi=t=>{const e=fi(t);if(e)return{translateX:_i(e,"x"),translateY:_i(e,"y"),rotate:_i(e,"a")}},vi=t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(st(s.a*s.a+s.b*s.b)+st(s.c*s.c+s.d*s.d))/2)}return e},bi=(t,e,s)=>{const i=f,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const h=new Proxy(t,{get(t,e){const s=t[e];return e===u?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],h=+s[1],l=vi(o),c=-1e3*r*l,d=h*i*l+c,u=i*l+(0===r&&1===h||1===r&&0===h?0:10*l)-d;if("butt"!==n){const e=r===h?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${c}`),t.setAttribute("stroke-dasharray",`${d} ${u}`)}return Reflect.apply(s,t,e)}:Y(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),h.setAttribute("draw",`${e} ${s}`)),h},Ti=(t,e=0,s=0)=>ge(t).map(t=>bi(t,e,s)),Si=(t,e=.33)=>s=>{const i=fi(t);if(!i)return;const r="path"===s.tagName,n=r?" ":",",o=s[d];o&&s.setAttribute(r?"d":"points",o);let a="",h="";if(e){const t=s.getTotalLength(),o=i.getTotalLength(),l=Math.max(Math.ceil(t*e),Math.ceil(o*e));for(let e=0;e<l;e++){const c=e/(l-1),d=s.getPointAtLength(t*c),u=i.getPointAtLength(o*c),p=r?0===e?"M":"L":"";a+=p+gt(d.x,3)+n+d.y+" ",h+=p+gt(u.x,3)+n+u.y+" "}}else a=s.getAttribute(r?"d":"points"),h=i.getAttribute(r?"d":"points");return s[d]=h,[a,h]};var wi=Object.freeze({__proto__:null,createDrawable:Ti,createMotionPath:yi,morphTo:Si});const xi="undefined"!=typeof Intl&&Intl.Segmenter,Ei=/\{value\}/g,Ci=/\{i\}/g,ki=/(\s+)/,$i=/^\s+$/,Oi="line",Bi="word",Ni="char",Ri="data-line";let Li=null,Ai=null,Di=null;const Mi=t=>t.isWordLike||" "===t.segment||X(+t.segment),Fi=t=>t.setAttribute("aria-hidden","true"),Ii=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],Pi={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},zi=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&zi(e)}},Xi=(t,e,s)=>{const i=t.getAttribute(Ri);(null!==i&&+i!==e||"BR"===t.tagName)&&s.add(t);let r=t.childElementCount;for(;r--;)Xi(t.children[r],e,s);return s},Ui=(t,e={})=>{let s="";const i=U(e.class)?` class="${e.class}"`:"",r=Rt(e.clone,!1),n=Rt(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},Yi=(t,e,s,i,r,n,o,a,h)=>{const l=r===Oi,c=r===Ni,d=`_${r}_`,u=Y(t)?t(s):t,p=l?"block":"inline-block";Di.innerHTML=u.replace(Ei,`<i class="${d}"></i>`).replace(Ci,`${c?h:l?o:a}`);const m=Di.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,_=m.querySelectorAll(`i.${d}`),y=_.length;if(y){f.style.display=p,g.style.display=p,g.setAttribute(Ri,`${o}`),l||(g.setAttribute("data-word",`${a}`),c&&g.setAttribute("data-char",`${h}`));let t=y;for(;t--;){const e=_[t],i=e.parentElement;i.style.display=p,l?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${Pi[r]}`),f};class Wi{constructor(e,i={}){Li||(Li=xi?new xi([],{granularity:Bi}):{segment:t=>{const e=[],s=t.split(ki);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!$i.test(i)})}return e}}),Ai||(Ai=xi?new xi([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!Di&&t&&(Di=s.createElement("template")),L.current&&L.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:h,debug:l}=i,c=(e=P(e)?e[0]:e)&&e.nodeType?e:(fe(e)||[])[0],d=!0===o?{}:o,u=!0===r||W(r)?{}:r,p=!0===n?{}:n;this.debug=Rt(l,!1),this.includeSpaces=Rt(h,!1),this.accessible=Rt(a,!0),this.linesOnly=d&&!u&&!p,this.lineTemplate=z(d)?Ui(Oi,d):d,this.wordTemplate=z(u)||this.linesOnly?Ui(Bi,u):u,this.charTemplate=z(p)?Ui(Ni,p):p,this.$target=c,this.html=c&&c.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(d||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=c.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?s.fonts.ready.then(m):m(),c?this.resizeObserver.observe(c):console.warn("No Text Splitter target found.")}addEffect(t){if(!Y(t))return console.warn("Effect must return a function.");const e=Os(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>Y(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,i=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],h=this.words,l=this.chars,c=Li.segment(o),d=s.createDocumentFragment();let u=null;for(const t of c){const e=t.segment,s=Mi(t);if(!u||s&&u&&Mi(u))a.push(e);else{const t=a.length-1;a[t].includes(" ")||e.includes(" ")?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const c=a[t+1],u=r&&c&&!c.trim(),p=o,m=i?Ai.segment(p):null,f=i?s.createDocumentFragment():s.createTextNode(u?o+" ":o);if(i){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,c=s.createTextNode(a);Yi(i,l,c,f,Ni,n,-1,h.length,l.length)}}e?Yi(e,h,f,d,Bi,n,-1,h.length,l.length):i?d.appendChild(f):d.appendChild(s.createTextNode(o)),u&&t++}else{if(t&&r)continue;d.appendChild(s.createTextNode(o))}}t.parentNode.replaceChild(d,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,i=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==s.fonts.status,h=r&&a;this.ready=!r||a,(h||t)&&this.effectsCleanups.forEach(t=>Y(t)&&t(this)),i||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),h&&(i&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=Ii(e,Bi))),o&&(h||n)&&(this.chars=Ii(e,Ni));const l=this.words.length?this.words:this.chars;let c,d=0;for(let t=0,e=l.length;t<e;t++){const e=l[t],{top:s,height:i}=e.getBoundingClientRect();c&&s-c>.5*i&&d++,e.setAttribute(Ri,`${d}`);const r=e.querySelectorAll(`[${Ri}]`);let n=r.length;for(;n--;)r[n].setAttribute(Ri,`${d}`);c=s}if(h){const t=s.createDocumentFragment(),i=new Set,a=[];for(let t=0;t<d+1;t++){const s=e.cloneNode(!0);Xi(s,t,new Set).forEach(t=>{const e=t.parentElement;e&&i.add(e),t.remove()}),a.push(s)}i.forEach(zi);for(let e=0,s=a.length;e<s;e++)Yi(r,this.lines,a[e],t,Oi,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=Ii(e,Bi)),o&&(this.chars=Ii(e,Ni))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(h||!i)){const t=s.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(Fi),this.words.forEach(Fi),this.chars.forEach(Fi)}return this.width=e.offsetWidth,(h||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const Vi=(t,e)=>new Wi(t,e),Hi=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new Wi(t,e));var qi=Object.freeze({__proto__:null,TextSplitter:Wi,split:Hi,splitText:Vi});const ji=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(t(i/e));return`linear(${s.join(", ")})`},Qi={in:"ease-in",out:"ease-out",inOut:"ease-in-out"},Gi=(()=>{const t={};for(let e in we)t[e]=t=>we[e](Se(t));return t})(),Ji=t=>{let e=Qi[t];if(e)return e;if(e="linear",U(t)){if(F(t,"linear")||F(t,"cubic-")||F(t,"steps")||F(t,"ease"))e=t;else if(F(t,"cubicB"))e=M(t);else{const s=xe(t,Gi,Qi);Y(s)&&(e=s===Te?"linear":ji(s))}Qi[t]=e}else if(Y(t)){const s=ji(t);s&&(e=s)}else t.ease&&(e=ji(t.ease));return e},Zi=["x","y","z"],Ki=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...Zi],tr=(()=>[...Zi,...v.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let er=null;const sr=(t,e,s,i,r)=>{let n=Lt(e,s,i,r);return X(n)?Ki.includes(t)||F(t,"translate")?`${n}px`:F(t,"rotate")||F(t,"skew")?`${n}deg`:`${n}`:n},ir=(t,e,s,i,r,n)=>{let o="0";const a=W(i)?getComputedStyle(t)[e]:sr(e,i,t,r,n);return o=W(s)?P(i)?i.map(s=>sr(e,s,t,r,n)):a:[sr(e,s,t,r,n),a],o};class rr{constructor(e,s){L.current&&L.current.register(this),V(er)&&(!t||!W(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(v.forEach(t=>{const e=F(t,"skew"),s=F(t,"scale"),i=F(t,"rotate"),r=F(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),er=!0):er=!1);const i=_e(e),r=i.length;r||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const n=Rt(s.ease,Ji(A.defaults.ease)),o=n.ease&&n,a=Rt(s.autoplay,A.defaults.autoplay),h=!(!a||!a.link)&&a,l=s.alternate&&!0===s.alternate,d=s.reversed&&!0===s.reversed,u=Rt(s.loop,A.defaults.loop),p=!0===u||u===1/0?1/0:X(u)?u+1:1,m=l?d?"alternate-reverse":"alternate":d?"reverse":"normal",g=Ji(n),S=1===A.timeScale?1:f;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||T,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!a||!1!==h,this.reversed=d,this.autoplay=a,this._speed=Rt(s.playbackRate,A.defaults.playbackRate),this._resolve=T,this._completed=0,this._inlineStyles=i.map(t=>t.getAttribute("style")),i.forEach((t,e)=>{const i=t[c],a=tr.some(t=>s.hasOwnProperty(t)),h=(o?o.duration:Lt(Rt(s.duration,A.defaults.duration),t,e,r))*S,l=Lt(Rt(s.delay,A.defaults.delay),t,e,r)*S,d=Rt(s.composition,"replace");for(let o in s){if(!J(o))continue;const c={},u={iterations:p,direction:m,fill:"forwards",easing:g,duration:h,delay:l,composite:d},f=s[o],_=!!a&&(v.includes(o)?o:y.get(o));let b;if(z(f)){const s=f,a=Rt(s.ease,n),p=a.ease&&a,m=s.to,g=s.from;if(u.duration=(p?p.duration:Lt(Rt(s.duration,h),t,e,r))*S,u.delay=Lt(Rt(s.delay,l),t,e,r)*S,u.composite=Rt(s.composition,d),u.easing=Ji(a),b=ir(t,o,g,m,e,r),_?(c[`--${_}`]=b,i[_]=b):c[o]=ir(t,o,g,m,e,r),Je(this,t,o,c,u),!W(g))if(_){const e=`--${_}`;t.style.setProperty(e,c[e][0])}else t.style[o]=c[o][0]}else b=P(f)?f.map(s=>sr(o,s,t,e,r)):sr(o,f,t,e,r),_?(c[`--${_}`]=b,i[_]=b):c[o]=b,Je(this,t,o,c,u)}if(a){let e=_;for(let t in i)e+=`${b[t]}var(--${t})) `;t.style.transform=e}}),h&&this.autoplay.link(this)}forEach(t){const e=U(t)?e=>e[t]():t;return this.animations.forEach(e),this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=A.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===A.timeScale?1:f);this.forEach(t=>{e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.forEach("cancel"),this.pause()}revert(){return this.cancel(),this.targets.forEach((t,e)=>t.setAttribute("style",this._inlineStyles[e])),this}then(t=T){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=T};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const nr={animate:(t,e)=>new rr(t,e),convertEase:ji};export{_e as $,as as Animatable,Cs as Draggable,qe as JSAnimation,Bs as Scope,Us as ScrollObserver,vs as Spring,Wi as TextSplitter,ns as Timeline,pe as Timer,rr as WAAPIAnimation,je as animate,ri as clamp,Ht as cleanInlineStyles,hs as createAnimatable,ks as createDraggable,Ti as createDrawable,yi as createMotionPath,Ns as createScope,ci as createSeededRandom,bs as createSpring,os as createTimeline,me as createTimer,ke as cubicBezier,ai as damp,ei as degToRad,Ae as eases,Ws as easings,Kt as engine,Ze as get,Be as irregular,Os as keepTime,oi as lerp,Oe as linear,ti as mapRange,Si as morphTo,Te as none,Ys as onScroll,Zs as padEnd,Js as padStart,si as radToDeg,hi as random,di as randomPick,ts as remove,ni as round,Gs as roundPad,As as scrollContainers,Ke as set,ui as shuffle,ii as snap,Hi as split,Vi as splitText,pi as stagger,$e as steps,wi as svg,$s as sync,qi as text,mi as utils,nr as waapi,Ks as wrap};
+const t="undefined"!=typeof window,e=t?window:null,s=t?document:null,i={OBJECT:0,ATTRIBUTE:1,CSS:2,TRANSFORM:3,CSS_VAR:4},r={NUMBER:0,UNIT:1,COLOR:2,COMPLEX:3},n={NONE:0,AUTO:1,FORCE:2},o={replace:0,none:1,blend:2},a=Symbol(),h=Symbol(),l=Symbol(),c=Symbol(),d=Symbol(),u=Symbol(),p=1e-11,m=1e12,f=1e3,g=120,_="",y="var(",v=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),b=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","matrix","matrix3d","perspective"],T=b.reduce((t,e)=>({...t,[e]:e+"("}),{}),S=()=>{},w=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,x=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,C=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,E=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,k=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,$=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,B=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,O=/([a-z])([A-Z])/g,N=/(\w+)(\([^)]+\)+)/g,R=/(\*=|\+=|-=)/,D=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,L={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:g,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:f,delay:0,loopDelay:0,ease:"out(2)",composition:o.replace,modifier:t=>t,onBegin:S,onBeforeUpdate:S,onUpdate:S,onLoop:S,onPause:S,onComplete:S,onRender:S},A={current:null,root:s},F={defaults:L,precision:4,timeScale:1,tickThreshold:200},M={version:"4.2.0",engine:null};t&&(e.AnimeJS||(e.AnimeJS=[]),e.AnimeJS.push(M));const P=t=>t.replace(O,"$1-$2").toLowerCase(),I=(t,e)=>0===t.indexOf(e),z=Date.now,X=Array.isArray,U=t=>t&&t.constructor===Object,Y=t=>"number"==typeof t&&!isNaN(t),V=t=>"string"==typeof t,W=t=>"function"==typeof t,H=t=>void 0===t,q=t=>H(t)||null===t,j=e=>t&&e instanceof SVGElement,Q=t=>w.test(t),G=t=>I(t,"rgb"),J=t=>I(t,"hsl"),Z=t=>Q(t)||G(t)||J(t),K=t=>!F.defaults.hasOwnProperty(t),tt=["opacity","rotate","overflow","color"],et=(t,e)=>{if(tt.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}},st=t=>V(t)?parseFloat(t):t,it=Math.pow,rt=Math.sqrt,nt=Math.sin,ot=Math.cos,at=Math.abs,ht=Math.exp,lt=Math.ceil,ct=Math.floor,dt=Math.asin,ut=Math.max,pt=Math.atan2,mt=Math.PI,ft=Math.round,gt=(t,e,s)=>t<e?e:t>s?s:t,_t={},yt=(t,e)=>{if(e<0)return t;if(!e)return ft(t);let s=_t[e];return s||(s=_t[e]=10**e),ft(t*s)/s},vt=(t,e)=>X(e)?e.reduce((e,s)=>at(s-t)<at(e-t)?s:e):e?ft(t/e)*e:t,bt=(t,e,s)=>t+(e-t)*s,Tt=t=>t===1/0?m:t===-1/0?-m:t,St=t=>t<=p?p:Tt(yt(t,11)),wt=t=>X(t)?[...t]:t,xt=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=H(r)?e[i]:r}return s},Ct=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},Et=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},kt=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},$t=(t,e,s)=>{const i=t.style.transform;let r;if(i){const n=t[c];let o;for(;o=N.exec(i);){const t=o[1],i=o[2].slice(1,-1);n[t]=i,t===e&&(r=i,s&&(s[e]=i))}}return i&&!H(r)?r:I(e,"scale")?"1":I(e,"rotate")||I(e,"skew")?"0deg":"0px"},Bt=t=>{const e=x.exec(t)||C.exec(t),s=H(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]},Ot=t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]},Nt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),Rt=t=>{const e=E.exec(t)||k.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=H(e[4])?1:+e[4];let o,a,h;if(0===i)o=a=h=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=yt(255*Nt(e,t,s+1/3),0),a=yt(255*Nt(e,t,s),0),h=yt(255*Nt(e,t,s-1/3),0)}return[o,a,h,n]},Dt=t=>G(t)?Bt(t):Q(t)?Ot(t):J(t)?Rt(t):[0,0,0,1],Lt=(t,e)=>H(t)?e:t,At=(t,e,s,i,r)=>{let n;if(W(t))n=()=>{const r=t(e,s,i);return isNaN(+r)?r||0:+r};else{if(!V(t)||!I(t,y))return t;n=()=>{const s=t.match(D),i=s[1],r=s[2];let n=getComputedStyle(e)?.getPropertyValue(i);return n&&n.trim()!==_||!r||(n=r.trim()),n||0}}return r&&(r.func=n),n()},Ft=(t,e)=>t[h]?t[l]&&et(t,e)?i.ATTRIBUTE:b.includes(e)||v.get(e)?i.TRANSFORM:I(e,"--")?i.CSS_VAR:e in t.style?i.CSS:e in t?i.OBJECT:i.ATTRIBUTE:i.OBJECT,Mt=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[u]||t).getPropertyValue(e);return"auto"===r?"0":r},Pt=(t,e,s,r)=>{const n=H(s)?Ft(t,e):s;return n===i.OBJECT?t[e]||0:n===i.ATTRIBUTE?t.getAttribute(e):n===i.TRANSFORM?$t(t,e,r):n===i.CSS_VAR?Mt(t,e,r).trimStart():Mt(t,e,r)},It=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,zt=()=>({t:r.NUMBER,n:0,u:null,o:null,d:null,s:null}),Xt=(t,e)=>{if(e.t=r.NUMBER,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const i=!s.includes(" ")&&B.exec(s);if(i)return e.t=r.UNIT,e.n=+i[1],e.u=i[2],e;if(e.o)return e.n=+s,e;if(Z(s))return e.t=r.COLOR,e.d=Dt(s),e;{const t=s.match($);return e.t=r.COMPLEX,e.d=t?t.map(Number):[],e.s=s.split($)||[],e}}return e.n=s,e},Ut=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=wt(t._toNumbers),e.s=wt(t._strings),e),Yt=zt(),Vt=(t,e,s,a,h)=>{const l=t.parent,d=t.duration,u=t.completed,m=t.iterationDuration,f=t.iterationCount,g=t._currentIteration,y=t._loopDelay,v=t._reversed,b=t._alternate,S=t._hasChildren,w=t._delay,x=t._currentTime,C=w+m,E=e-w,k=gt(x,-w,d),$=gt(E,-w,d),B=E-x,O=$>0,N=$>=d,R=d<=p,D=h===n.FORCE;let L=0,A=E,M=0;if(f>1){const e=~~($/(m+(N?0:y)));t._currentIteration=gt(e,0,f),N&&t._currentIteration--,L=t._currentIteration%2,A=$%(m+y)||0}const P=v^(b&&L),I=t._ease;let z=N?P?0:d:P?m-A:A;I&&(z=m*I(z/m)||0);const X=(l?l.backwards:E<x)?!P:!!P;if(t._currentTime=E,t._iterationTime=z,t.backwards=X,O&&!t.began?(t.began=!0,s||l&&(X||!l.began)||t.onBegin(t)):E<=0&&(t.began=!1),s||S||!O||t._currentIteration===g||t.onLoop(t),D||h===n.AUTO&&(e>=w&&e<=C||e<=w&&k>w||e>=C&&k!==d)||z>=C&&k!==d||z<=w&&k>0||e<=k&&k===d&&u||N&&!u&&R){if(O&&(t.computeDeltaTime(k),s||t.onBeforeUpdate(t)),!S){const e=D||(X?-1*B:B)>=F.tickThreshold,n=t._offset+(l?l._offset:0)+w+z;let h,d,u,p,m=t._head,f=0;for(;m;){const t=m._composition,s=m._currentTime,l=m._changeDuration,g=m._absoluteStartTime+m._changeDuration,y=m._nextRep,v=m._prevRep,b=t!==o.none;if((e||(s!==l||n<=g+(y?y._delay:0))&&(0!==s||n>=m._absoluteStartTime))&&(!b||!m._isOverridden&&(!m._isOverlapped||n<=g)&&(!y||y._isOverridden||n<=y._absoluteStartTime)&&(!v||v._isOverridden||n>=v._absoluteStartTime+v._changeDuration+m._delay))){const e=m._currentTime=gt(z-m._startTime,0,l),s=m._ease(e/m._updateDuration),n=m._modifier,g=m._valueType,_=m._tweenType,y=_===i.OBJECT,v=g===r.NUMBER,T=v&&y||0===s||1===s?-1:F.precision;let S,w;if(v)S=w=n(yt(bt(m._fromNumber,m._toNumber,s),T));else if(g===r.UNIT)w=n(yt(bt(m._fromNumber,m._toNumber,s),T)),S=`${w}${m._unit}`;else if(g===r.COLOR){const t=m._fromNumbers,e=m._toNumbers,i=yt(gt(n(bt(t[0],e[0],s)),0,255),0),r=yt(gt(n(bt(t[1],e[1],s)),0,255),0),o=yt(gt(n(bt(t[2],e[2],s)),0,255),0),a=gt(n(yt(bt(t[3],e[3],s),T)),0,1);if(S=`rgba(${i},${r},${o},${a})`,b){const t=m._numbers;t[0]=i,t[1]=r,t[2]=o,t[3]=a}}else if(g===r.COMPLEX){S=m._strings[0];for(let t=0,e=m._toNumbers.length;t<e;t++){const e=n(yt(bt(m._fromNumbers[t],m._toNumbers[t],s),T)),i=m._strings[t+1];S+=`${i?e+i:e}`,b&&(m._numbers[t]=e)}}if(b&&(m._number=w),a||t===o.blend)m._value=S;else{const t=m.property;h=m.target,y?h[t]=S:_===i.ATTRIBUTE?h.setAttribute(t,S):(d=h.style,_===i.TRANSFORM?(h!==u&&(u=h,p=h[c]),p[t]=S,f=1):_===i.CSS?d[t]=S:_===i.CSS_VAR&&d.setProperty(t,S)),O&&(M=1)}}if(f&&m._renderTransforms){let t=_;for(let e in p)t+=`${T[e]}${p[e]}) `;d.transform=t,f=0}m=m._next}!s&&M&&t.onRender(t)}!s&&O&&t.onUpdate(t)}return l&&R?!s&&(l.began&&!X&&E>0&&!u||X&&E<=p&&u)&&(t.onComplete(t),t.completed=!X):O&&N?f===1/0?t._startTime+=t.duration:t._currentIteration>=f-1&&(t.paused=!0,u||S||(t.completed=!0,s||l&&(X||!l.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,M},Wt=(t,e,s,i,r)=>{const o=t._currentIteration;if(Vt(t,e,s,i,r),t._hasChildren){const a=t,h=a.backwards,l=i?e:a._iterationTime,c=z();let d=0,u=!0;if(!i&&a._currentIteration!==o){const t=a.iterationDuration;Ct(a,e=>{if(h){const i=e.duration,r=e._offset+e._delay;s||!(i<=p)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Vt(e,t,s,1,n.FORCE),e.began=!1,e.completed=!1}),s||a.onLoop(a)}Ct(a,t=>{const e=yt((l-t._offset)*t._speed,12),n=t._fps<a._fps?t.requestTick(c):r;d+=Vt(t,e,s,i,n),!t.completed&&u&&(u=!1)},h),!s&&d&&a.onRender(a),(u||h)&&a._currentTime>=a.duration&&(a.paused=!0,a.completed||(a.completed=!0,s||(a.onComplete(a),a._resolve(a))))}},Ht={},qt=(t,e,s)=>{if(s===i.TRANSFORM)return v.get(t)||t;if(s===i.CSS||s===i.ATTRIBUTE&&j(e)&&t in e.style){const e=Ht[t];if(e)return e;{const e=t?P(t):t;return Ht[t]=e,e}}return t},jt=t=>{if(t._hasChildren)Ct(t,jt,!0);else{const e=t;e.pause(),Ct(e,t=>{const s=t.property,r=t.target;if(r[h]){const n=r.style,o=t._inlineValue,a=q(o)||o===_;if(t._tweenType===i.TRANSFORM){const e=r[c];if(a?delete e[s]:e[s]=o,t._renderTransforms)if(Object.keys(e).length){let t=_;for(let s in e)t+=T[s]+e[s]+") ";n.transform=t}else n.removeProperty("transform")}else a?n.removeProperty(P(s)):n[s]=o;e._tail===t&&e.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===_&&t.removeAttribute("style")})}})}return t};class Qt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._elapsedTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=yt(f/g,0),this._fps=g,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<p?p:s,r=yt(f/i,0);this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<p?p:e}requestTick(t){const e=this._scheduledTime,s=this._elapsedTime;if(this._elapsedTime+=t-s,s<e)return n.NONE;const i=this._frameDuration,r=s-e;return this._scheduledTime+=r<i?i:r,n.AUTO}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Gt={animation:null,update:S},Jt=t=>{let e=Gt.animation;return e||(e={duration:p,computeDeltaTime:S,_offset:0,_delay:0,_head:null,_tail:null},Gt.animation=e,Gt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=t===r.COMPLEX||t===r.COLOR?wt(i._fromNumbers):null;let n=i._fromNumber,o=s._tail;for(;o&&o!==i;){if(e)for(let t=0,s=o._numbers.length;t<s;t++)e[t]+=o._numbers[t];else n+=o._number;o=o._prevAdd}i._toNumber=n,i._toNumbers=e}}}),Vt(e,1,1,0,n.FORCE)}),e},Zt=(()=>t?requestAnimationFrame:setImmediate)(),Kt=(()=>t?cancelAnimationFrame:clearImmediate)();class te extends Qt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=L,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=z();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(Et(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Wt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):n.AUTO),i=r}Gt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(z()),this.reqId=Zt(se)),this}pause(){if(this.reqId)return this.paused=!0,ie()}resume(){if(this.paused)return this.paused=!1,Ct(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===F.timeScale?1:f)}set speed(t){this._speed=t*F.timeScale,Ct(this,t=>t.speed=t._speed)}get timeUnit(){return 1===F.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(F.timeScale!==s){F.timeScale=s,F.tickThreshold=200*s;const t=e?.001:f;this.defaults.duration*=t,this._speed*=t}}get precision(){return F.precision}set precision(t){F.precision=t}}const ee=(()=>{const e=new te(z());return t&&(M.engine=e,s.addEventListener("visibilitychange",()=>{e.pauseOnDocumentHidden&&(s.hidden?e.pause():e.resume())})),e})(),se=()=>{ee._head?(ee.reqId=Zt(se),ee.update()):ee.reqId=0},ie=()=>(Kt(ee.reqId),ee.reqId=0,ee),re={_rep:new WeakMap,_add:new Map},ne=(t,e,s="_rep")=>{const i=re[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},oe=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,ae=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=p,t._currentTime=p},he=(t,e)=>{const s=t._composition;if(s===o.replace){const s=t._absoluteStartTime;kt(e,t,oe,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){ae(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)ae(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=yt(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<p&&ae(i)}let o=!0;if(Ct(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;Ct(t,t=>{t!==e&&Ct(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===o.blend){const e=ne(t.target,t.property,"_add"),s=Jt(re._add);let i=e._head;i||(i={...t},i._composition=o.replace,i._updateDuration=p,i._startTime=0,i._numbers=wt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,kt(e,i),kt(s,i));const r=t._toNumber;if(t._fromNumber=i._fromNumber-r,t._toNumber=0,t._numbers=wt(t._fromNumbers),t._number=0,i._fromNumber=r,t._toNumbers){const e=wt(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}kt(e,t,null,"_prevAdd","_nextAdd")}return t},le=t=>{const e=t._composition;if(e!==o.none){const s=t.target,i=t.property,r=re._rep.get(s)[i];if(Et(r,t,"_prevRep","_nextRep"),e===o.blend){const e=re._add,r=e.get(s);if(!r)return;const n=r[i],o=Gt.animation;Et(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){Et(n,a,"_prevAdd","_nextAdd"),Et(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},ce=(t,e,s)=>{let r=!1;return Ct(e,n=>{const o=n.target;if(t.includes(o)){const t=n.property,a=n._tweenType,h=qt(s,o,a);(!h||h&&h===t)&&(n.parent._tail===n&&n._tweenType===i.TRANSFORM&&n._prev&&n._prev._tweenType===i.TRANSFORM&&(n._prev._renderTransforms=1),Et(e,n),le(n),r=!0)}},!0),r},de=(t,e,s)=>{const i=e||ee;let r;if(i._hasChildren){let e=0;Ct(i,n=>{if(!n._hasChildren)if(r=ce(t,n,s),r&&!n._head)n.cancel(),Et(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?de(t,n,s):n._hasChildren=!1},!0),H(i.iterationDuration)||(i.iterationDuration=e)}else r=ce(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},ue=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),pe=t=>t._cancelled?(t._hasChildren?Ct(t,pe):Ct(t,t=>{t._composition!==o.none&&he(t,ne(t.target,t.property))}),t._cancelled=0,t):t;let me=0;class fe extends Qt{constructor(t={},e=null,s=0){super(0);const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:h,loopDelay:l,autoplay:c,frameRate:d,playbackRate:u,onComplete:m,onLoop:f,onPause:g,onBegin:_,onBeforeUpdate:y,onUpdate:v}=t;A.current&&A.current.register(this);const b=e?0:ee._elapsedTime,T=e?e.defaults:F.defaults,w=W(r)||H(r)?T.delay:+r,x=W(n)||H(n)?1/0:+n,C=Lt(h,T.loop),E=Lt(l,T.loopDelay),k=!0===C||C===1/0||C<0?1/0:C+1;let $=0;e?$=s:(ee.reqId||ee.requestTick(z()),$=(ee._elapsedTime-ee._startTime)*F.timeScale),this.id=H(i)?++me:i,this.parent=e,this.duration=Tt((x+E)*k-E)||p,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=_||T.onBegin,this.onBeforeUpdate=y||T.onBeforeUpdate,this.onUpdate=v||T.onUpdate,this.onLoop=f||T.onLoop,this.onPause=g||T.onPause,this.onComplete=m||T.onComplete,this.iterationDuration=x,this.iterationCount=k,this._autoplay=!e&&Lt(c,T.autoplay),this._offset=$,this._delay=w,this._loopDelay=E,this._iterationTime=0,this._currentIteration=0,this._resolve=S,this._running=!1,this._reversed=+Lt(o,T.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=Lt(a,T.alternate),this._prev=null,this._next=null,this._elapsedTime=b,this._startTime=b,this._lastTime=b,this._fps=Lt(d,T.frameRate),this._speed=Lt(u,T.playbackRate)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(1).play()}get currentTime(){return gt(yt(this._currentTime,F.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return yt(this._iterationTime,F.precision)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return gt(yt(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return gt(yt(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*gt(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=0){return pe(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Wt(this,0,1,t,n.FORCE),ue(this),this._hasChildren&&Ct(this,ue),this}init(t=0){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Wt(this,this.duration,1,t,n.FORCE),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!H(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*ee._speed);return this._startTime=z()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=p&&!this._hasChildren?Wt(this,p,0,0,n.FORCE):(this._running||(kt(ee,this),ee._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,ee.wake()),this):this}restart(){return this.reset(0).resume()}seek(t,e=0,s=0){pe(this),this.completed=!1;const i=this.paused;return this.paused=!0,Wt(this,t+this._delay,~~e,~~s,n.AUTO),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?ct(m/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?Ct(this,t=>t.cancel(),!0):Ct(this,le),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=St(t);if(e===s)return this;const i=t/e,r=t<=p;return this.duration=r?p:s,this.iterationDuration=r?p:St(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Wt(this,0,1,0,n.AUTO);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(){return this.seek(this.duration).cancel()}then(t=S){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=S};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const ge=t=>new fe(t,null,0).init();function _e(t){const e=V(t)?A.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function ye(e){if(q(e))return[];if(!t)return X(e)&&e.flat(1/0)||[e];if(X(e)){const t=e.flat(1/0),s=[];for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!q(i)){const t=_e(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!q(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=_e(e);return s?Array.from(s):[e]}function ve(t){const e=ye(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[a]){s[a]=!0;const t=j(s);(s.nodeType||t)&&(s[h]=!0,s[l]=t,s[c]={})}}return e}const be={deg:1,rad:180/mt,turn:360},Te={},Se=(t,e,i,n=!1)=>{const o=e.u,a=e.n;if(e.t===r.UNIT&&o===i)return e;const h=a+o+i,l=Te[h];if(H(l)||n){let r;if(o in be)r=a*be[o]/be[i];else{const e=100,n=t.cloneNode(),h=t.parentNode,l=h&&h!==s?h:s.body;l.appendChild(n);const c=n.style;c.width=e+o;const d=n.offsetWidth||e;c.width=e+i;const u=d/(n.offsetWidth||e);l.removeChild(n),r=u*a}e.n=r,Te[h]=r}else e.n=l;return e.t,e.u=i,e},we=t=>t,xe=(t=1.68)=>e=>it(e,+t),Ce={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},Ee=mt/2,ke=2*mt,$e={[_]:xe,Quad:xe(2),Cubic:xe(3),Quart:xe(4),Quint:xe(5),Sine:t=>1-ot(t*Ee),Circ:t=>1-rt(1-t*t),Expo:t=>t?it(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=it(2,--s))-1)/11;);return 1/it(4,3-s)-7.5625*it((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=gt(+t,1,10),i=gt(+e,p,2),r=i/ke*dt(1/s),n=ke/i;return t=>0===t||1===t?t:-s*it(2,-10*(1-t))*nt((1-t-r)*n)}},Be=(()=>{const t={linear:we,none:we};for(let e in Ce)for(let s in $e){const i=$e[s],r=Ce[e];t[e+s]=s===_||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),Oe={linear:we,none:we},Ne=t=>{if(Oe[t])return Oe[t];if(t.indexOf("(")<=-1){const e=Ce[t]||t.includes("Back")||t.includes("Elastic")?Be[t]():Be[t];return e?Oe[t]=e:we}{const e=t.slice(0,-1).split("("),s=Be[e[0]];return s?Oe[t]=s(...e[1].split(",")):we}},Re=["steps(","irregular(","linear(","cubicBezier("],De=t=>{if(V(t))for(let e=0,s=Re.length;e<s;e++)if(I(t,Re[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),we;return W(t)?t:V(t)?Ne(t):we},Le=zt(),Ae=zt(),Fe={},Me={func:null},Pe=[null],Ie=[null,null],ze={to:null};let Xe,Ue,Ye=0;const Ve=(t,e)=>{const s={};if(X(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(K);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];K(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=Lt(e.duration,F.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(K(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,h=n[a-1];const l={to:r[t]};let c=0;for(let t=0;t<a;t++)c+=n[t].duration;1===a&&(l.from=h.to),r.ease&&(l.ease=r.ease),l.duration=o-(a?c:0),n.push(l)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s};class We extends fe{constructor(t,e,s,n,a=!1,h=0,l=0){super(e,s,n);const c=ve(t),d=c.length,u=e.keyframes,m=u?xt(Ve(u,e),e):e,{delay:g,duration:_,ease:y,playbackEase:v,modifier:b,composition:T,onRender:S}=m,w=s?s.defaults:F.defaults,x=Lt(v,w.playbackEase),C=x?De(x):null,E=!H(y)&&!H(y.ease),k=E?y.ease:Lt(y,C?"linear":w.ease),$=E?y.settlingDuration:Lt(_,w.duration),B=Lt(g,w.delay),O=b||w.modifier,N=H(T)&&d>=f?o.none:H(T)?w.composition:T,R=this._offset+(s?s._offset:0);E&&(y.parent=this);let D=NaN,L=NaN,A=0,M=0;for(let t=0;t<d;t++){const e=c[t],n=h||t,u=l||d;let f=NaN,g=NaN;for(let t in m)if(K(t)){const h=Ft(e,t),l=qt(t,e,h);let c=m[t];const d=X(c);if(a&&!d&&(Ie[0]=c,Ie[1]=c,c=Ie),d){const t=c.length,e=!U(c[0]);2===t&&e?(ze.to=c,Pe[0]=ze,Xe=Pe):t>2&&e?(Xe=[],c.forEach((t,e)=>{e?1===e?(Ie[1]=t,Xe.push(Ie)):Xe.push(t):Ie[0]=t})):Xe=c}else Pe[0]=c,Xe=Pe;let _=null,y=null,v=NaN,b=0,T=0;for(let t=Xe.length;T<t;T++){const i=Xe[T];U(i)?Ue=i:(ze.to=i,Ue=ze),Me.func=null;const a=At(Ue.to,e,n,u,Me);let c;U(a)&&!H(a.to)?(Ue=a,c=a.to):c=a;const d=At(Ue.from,e,n,u),m=Ue.ease,f=!H(m)&&!H(m.ease),g=f?m.ease:m||k,S=f?m.settlingDuration:At(Lt(Ue.duration,t>1?At($,e,n,u)/t:$),e,n,u),w=At(Lt(Ue.delay,T?0:B),e,n,u),x=At(Lt(Ue.composition,N),e,n,u),C=Y(x)?x:o[x],E=Ue.modifier||O,D=!H(d),L=!H(c),F=X(c),P=F||D&&L,I=y?b+w:w,z=yt(R+I,12);M||!D&&!F||(M=1);let V=y;if(C!==o.none){_||(_=ne(e,l));let t=_._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=z;)if(V=t,t=t._nextRep,t&&t._absoluteStartTime>=z)for(;t;)ae(t),t=t._nextRep}if(P?(Xt(F?At(c[0],e,n,u):d,Le),Xt(F?At(c[1],e,n,u,Me):c,Ae),Le.t===r.NUMBER&&(V?V._valueType===r.UNIT&&(Le.t=r.UNIT,Le.u=V._unit):(Xt(Pt(e,l,h,Fe),Yt),Yt.t===r.UNIT&&(Le.t=r.UNIT,Le.u=Yt.u)))):(L?Xt(c,Ae):y?Ut(y,Ae):Xt(s&&V&&V.parent.parent===s?V._value:Pt(e,l,h,Fe),Ae),D?Xt(d,Le):y?Ut(y,Le):Xt(s&&V&&V.parent.parent===s?V._value:Pt(e,l,h,Fe),Le)),Le.o&&(Le.n=It(V?V._toNumber:Xt(Pt(e,l,h,Fe),Yt).n,Le.n,Le.o)),Ae.o&&(Ae.n=It(Le.n,Ae.n,Ae.o)),Le.t!==Ae.t)if(Le.t===r.COMPLEX||Ae.t===r.COMPLEX){const t=Le.t===r.COMPLEX?Le:Ae,e=Le.t===r.COMPLEX?Ae:Le;e.t=r.COMPLEX,e.s=wt(t.s),e.d=t.d.map(()=>e.n)}else if(Le.t===r.UNIT||Ae.t===r.UNIT){const t=Le.t===r.UNIT?Le:Ae,e=Le.t===r.UNIT?Ae:Le;e.t=r.UNIT,e.u=t.u}else if(Le.t===r.COLOR||Ae.t===r.COLOR){const t=Le.t===r.COLOR?Le:Ae,e=Le.t===r.COLOR?Ae:Le;e.t=r.COLOR,e.s=t.s,e.d=[0,0,0,1]}if(Le.u!==Ae.u){let t=Ae.u?Le:Ae;t=Se(e,t,Ae.u?Ae.u:Le.u,!1)}if(Ae.d&&Le.d&&Ae.d.length!==Le.d.length){const t=Le.d.length>Ae.d.length?Le:Ae,e=t===Le?Ae:Le;e.d=t.d.map((t,s)=>H(e.d[s])?0:e.d[s]),e.s=wt(t.s)}const W=yt(+S||p,12);let j=Fe[l];q(j)||(Fe[l]=null);const Q={parent:this,id:Ye++,property:l,target:e,_value:null,_func:Me.func,_ease:De(g),_fromNumbers:wt(Le.d),_toNumbers:wt(Ae.d),_strings:wt(Ae.s),_fromNumber:Le.n,_toNumber:Ae.n,_numbers:wt(Le.d),_number:Le.n,_unit:Ae.u,_modifier:E,_currentTime:0,_startTime:I,_delay:+w,_updateDuration:W,_changeDuration:W,_absoluteStartTime:z,_tweenType:h,_valueType:Ae.t,_composition:C,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:j,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};C!==o.none&&he(Q,_),isNaN(v)&&(v=Q._startTime),b=yt(I+W,12),y=Q,A++,kt(this,Q)}(isNaN(L)||v<L)&&(L=v),(isNaN(D)||b>D)&&(D=b),h===i.TRANSFORM&&(f=A-T,g=A)}if(!isNaN(f)){let t=0;Ct(this,e=>{t>=f&&t<g&&(e._renderTransforms=1,e._composition===o.blend&&Ct(Gt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}d||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),L?(Ct(this,t=>{t._startTime-t._delay||(t._delay-=L),t._startTime-=L}),D-=L):L=0,D||(D=p,this.iterationCount=0),this.targets=c,this.duration=D===p?p:Tt((D+this._loopDelay)*this.iterationCount-this._loopDelay)||p,this.onRender=S||w.onRender,this._ease=C,this._delay=L,this.iterationDuration=D,!this._autoplay&&M&&this.onRender(this)}stretch(t){const e=this.duration;if(e===St(t))return this;const s=t/e;return Ct(this,t=>{t._updateDuration=St(t._updateDuration*s),t._changeDuration=St(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return Ct(this,t=>{const e=t._func;if(e){const s=Pt(t.target,t.property,t._tweenType);Xt(s,Yt),Xt(e(),Ae),t._fromNumbers=wt(Yt.d),t._fromNumber=Yt.n,t._toNumbers=wt(Ae.d),t._strings=wt(Ae.s),t._toNumber=Ae.o?It(Yt.n,Ae.n,Ae.o):Ae.n}}),this.duration===p&&this.restart(),this}revert(){return super.revert(),jt(this)}then(t){return super.then(t)}}const He=(t,e)=>new We(t,e,null,0,!1).init(),qe={_head:null,_tail:null},je=(t,e,s)=>{let i,r=qe._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,h=!s||r.parent===s;if(o&&a&&h){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),Et(qe,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},Qe=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),je(e,s),kt(qe,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>{je(e,s,t)};return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function Ge(t,e,s){const i=ve(t);if(!i.length)return;const[n]=i,o=Ft(n,e),a=qt(e,n,o);let h=Pt(n,a);if(H(s))return h;if(Xt(h,Yt),Yt.t===r.NUMBER||Yt.t===r.UNIT){if(!1===s)return Yt.n;{const t=Se(n,Yt,s,!1);return`${yt(t.n,F.precision)}${t.u}`}}}const Je=(t,e)=>{if(!H(e))return e.duration=p,e.composition=Lt(e.composition,o.none),new We(t,e,null,0,!0).resume()},Ze=(t,e,s)=>{const i=ye(t);for(let t=0,r=i.length;t<r;t++)je(i[t],s,e&&e.controlAnimation&&e);return de(i,e,s),i},Ke=(t,e)=>{if(I(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}},ts=(t,e)=>{let s=t.iterationDuration;if(s===p&&(s=0),H(e))return s;if(Y(+e))return+e;const i=e,r=t?t.labels:null,n=!q(r),o=Ke(t,i),a=!H(o),h=R.exec(i);if(h){const t=h[0],e=i.split(t),l=n&&e[0]?r[e[0]]:s,c=a?o:n?l:s,d=+e[1];return It(c,d,t[0])}return a?o:n?H(r[i])?s:r[i]:s};function es(t){return Tt((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||p}function ss(t,e,s,i,r,o){const a=Y(t.duration)&&t.duration<=p?s-p:s;Wt(e,a,1,1,n.AUTO);const h=i?new We(i,t,e,a,!1,r,o):new fe(t,e,a);return h.init(1),kt(e,h),Ct(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=es(e),e}class is extends fe{constructor(t={}){super(t,null,0),this.duration=0,this.labels={};const e=t.defaults,s=F.defaults;this.defaults=e?xt(e,s):s,this.onRender=t.onRender||s.onRender;const i=Lt(t.playbackEase,s.playbackEase);this._ease=i?De(i):null,this.iterationDuration=0}add(t,e,s){const i=U(e),r=U(t);if(i||r){if(this._hasChildren=!0,i){const i=e;if(W(s)){const e=s,r=ye(t),n=this.duration,o=this.iterationDuration,a=i.id;let h=0;const l=r.length;r.forEach(t=>{const s={...i};this.duration=n,this.iterationDuration=o,H(a)||(s.id=a+"-"+h),ss(s,this,ts(this,e(t,h,l,this)),t,h,l),h++})}else ss(i,this,ts(this,s),t)}else ss(t,this,ts(this,e));return this.init(1)}}sync(t,e){if(H(t)||t&&H(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return this.add(t,{currentTime:[0,s],duration:s,ease:"linear"},e)}set(t,e,s){return H(e)?this:(e.duration=p,e.composition=o.replace,this.add(t,e,s))}call(t,e){return H(t)||t&&!W(t)?this:this.add({duration:0,onComplete:()=>t(this)},e)}label(t,e){return H(t)||t&&!V(t)||(this.labels[t]=ts(this,e)),this}remove(t,e){return de(ye(t),this,e),this}stretch(t){const e=this.duration;if(e===St(t))return this;const s=t/e,i=this.labels;Ct(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return Ct(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),Ct(this,t=>t.revert,!0),jt(this)}then(t){return super.then(t)}}const rs=t=>new is(t).init();class ns{constructor(t,e){A.current&&A.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},r={v:1,autoplay:!1},n={};if(this.targets=[],this.animations={},this.callbacks=null,!H(t)&&!H(e)){for(let t in e){const s=e[t];K(t)?n[t]=s:I(t,"on")?r[t]=s:i[t]=s}this.callbacks=new We({v:0},r);for(let e in n){const s=n[e],r=U(s);let a={},h="+=0";if(r){const t=s.unit;V(t)&&(h+=t)}else a.duration=s;a[e]=r?xt({to:h},s):h;const l=xt(i,a);l.composition=o.replace,l.autoplay=!1;const c=this.animations[e]=new We(t,l,null,0,!1).init();this.targets.length||this.targets.push(...c.targets),this[e]=(t,e,s)=>{const i=c._head;if(H(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return Ct(c,e=>{if(X(t))for(let s=0,i=t.length;s<i;s++)H(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;H(s)||(e._ease=De(s)),e._currentTime=0}),H(e)||c.stretch(e),c.reset(1).resume(),this}}}}revert(){for(let t in this.animations)this[t]=S,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const os=(t,e)=>new ns(t,e),as=(t,e)=>(+t).toFixed(e),hs=(t,e,s)=>`${t}`.padStart(e,s),ls=(t,e,s)=>`${t}`.padEnd(e,s),cs=(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e,ds=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i),us=t=>t*Math.PI/180,ps=t=>180*t/Math.PI,ms=(t,e,s,i)=>i?1===i?e:bt(t,e,1-Math.exp(-i*s*.1)):t;var fs=Object.freeze({__proto__:null,clamp:gt,damp:ms,degToRad:us,lerp:bt,mapRange:ds,padEnd:ls,padStart:hs,radToDeg:ps,round:yt,roundPad:as,snap:vt,wrap:cs});const gs=10*f;class _s{constructor(t={}){const e=!H(t.bounce)||!H(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/f,this.maxIterations=this.maxDuration/this.timeStep/f,this.bn=gt(Lt(t.bounce,.5),-1,1),this.pd=gt(Lt(t.duration,628),10*F.timeScale,gs*F.timeScale),this.m=gt(Lt(t.mass,1),1,gs),this.s=gt(Lt(t.stiffness,100),p,gs),this.d=gt(Lt(t.damping,10),p,gs),this.v=gt(Lt(t.velocity,0),-1e4,gs),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||S,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?ht(-n*e*s)*(1*ot(i*n)+r*nt(i*n)):1===e?(1+r*n)*ht(-n*s):((1+r)*ht((-e*s+i)*n)+(1-r)*ht((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===F.timeScale?this.pd/f:this.pd;this.m=1,this.v=0,this.s=it(2*mt/t,2),this.bn>=0?this.d=4*(1-this.bn)*mt/t:this.d=4*mt/(t*(1+this.bn)),this.s=yt(gt(this.s,p,gs),3),this.d=yt(gt(this.d,p,300),3)}calculateBDFromSD(){const t=2*mt/rt(this.s);this.pd=t*(1===F.timeScale?f:1);const e=this.d/(2*rt(this.s));this.bn=e<=1?1-this.d*t/(4*mt):4*mt/(this.d*t)-1,this.bn=yt(gt(this.bn,-1,1),3),this.pd=yt(gt(this.pd,10*F.timeScale,gs*F.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,h=this.w0=gt(rt(o/r),p,f),l=this.zeta=n/(2*rt(o*r));l<1?(this.wd=h*rt(1-l*l),this.b=(l*h-a)/this.wd):1===l?(this.wd=0,this.b=-a+h):(this.wd=h*rt(l*l-1),this.b=(l*h-a)/this.wd);let c=0,d=0,u=0;for(;d<=t&&u<=e;)at(1-this.solve(c))<s?d++:d=0,this.solverDuration=c,c+=i,u++;this.settlingDuration=yt(this.solverDuration*f,0)*F.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=gt(Lt(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=gt(Lt(t,1),10*F.timeScale,gs*F.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=gt(Lt(t,100),p,gs),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=gt(Lt(t,10),p,gs),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=gt(Lt(t,1),1,gs),this.compute()}get velocity(){return this.v}set velocity(t){this.v=gt(Lt(t,0),-1e4,gs),this.compute()}}const ys=t=>new _s(t),vs=t=>(console.warn("createSpring() is deprecated use spring() instead"),new _s(t)),bs=t=>{t.cancelable&&t.preventDefault()};class Ts{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:S,remove:S}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class Ss{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,i=0;for(;e&&e!==s;)t(e,i),e=e.parentElement,i++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const ws=(t,e)=>t&&W(t)?t(e):t;let xs=0;class Cs{constructor(t,i={}){if(!t)return;A.current&&A.current.register(this);const r=i.x,n=i.y,o=i.trigger,a=i.modifier,h=i.releaseEase,l=h&&De(h),c=!H(h)&&!H(h.ease),d=U(r)&&!H(r.mapTo)?r.mapTo:"translateX",u=U(n)&&!H(n.mapTo)?n.mapTo:"translateY",p=ws(i.container,this);this.containerArray=X(p)?p:null,this.$container=p&&!this.containerArray?ye(p)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.$target=U(t)?new Ts(t):ye(t)[0],this.$trigger=ye(o||t)[0],this.fixed="fixed"===Ge(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=c?h:ys({mass:Lt(i.releaseMass,1),stiffness:Lt(i.releaseStiffness,80),damping:Lt(i.releaseDamping,20)}),this.releaseYSpring=c?h:ys({mass:Lt(i.releaseMass,1),stiffness:Lt(i.releaseStiffness,80),damping:Lt(i.releaseDamping,20)}),this.releaseEase=l||Be.outQuint,this.hasReleaseSpring=c,this.onGrab=i.onGrab||S,this.onDrag=i.onDrag||S,this.onRelease=i.onRelease||S,this.onUpdate=i.onUpdate||S,this.onSettle=i.onSettle||S,this.onSnap=i.onSnap||S,this.onResize=i.onResize||S,this.onAfterResize=i.onAfterResize||S,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),H(r)||!0===r)f[d]=0;else if(U(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[d]=e}else!1===r&&(f[d]=0,this.disabled[0]=1);if(H(n)||!0===n)f[u]=0;else if(U(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[u]=e}else!1===n&&(f[u]=0,this.disabled[1]=1);this.animate=new ns(this.$target,f),this.xProp=d,this.yProp=u,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-m,m,m,-m],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=z(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new Ss(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new fe({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new fe({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!H(p),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?d:u,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=pt(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new fe({autoplay:!1,duration:150*F.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=i,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),U(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=z(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,h=this.maxVelocity,l=this.velocityStackIndex;n[l]=yt(gt(rt(t*t+e*e)/r*o,a,h),5);const c=ut(n[0],n[1],n[2]);return this.velocity=c,this.velocityStackIndex=(l+1)%3,c}setX(t,e=!1){if(this.disabled[0])return;const s=yt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=vt(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=yt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=vt(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return yt(this.animate[this.xProp](),F.precision)}set x(t){this.setX(t,!1)}get y(){return yt(this.animate[this.yProp](),F.precision)}set y(t){this.setY(t,!1)}get progressX(){return ds(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(ds(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return ds(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(ds(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=yt(this.useWin?e.scrollX:this.$container.scrollLeft,0),s=yt(this.useWin?e.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=s,this.scrollBounds[0]=s-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=s-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const i=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=e.innerWidth,h=this.window[1]=e.innerHeight,l=this.useWin,c=t.scrollWidth,d=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,_]=this.containerPadding;this.dragArea[0]=l?0:p.left,this.dragArea[1]=l?0:p.top,this.scrollView[0]=l?gt(c,a,c):c,this.scrollView[1]=l?gt(d,h,d):d,this.updateScrollCoords();const{width:y,height:v,left:b,top:T,right:S,bottom:w}=t.getBoundingClientRect();this.dragArea[2]=yt(l?gt(y,a,a):y,0),this.dragArea[3]=yt(l?gt(v,h,h):v,0);const x=Ge(t,"overflow"),C="visible"===x,E="hidden"===x;if(this.canScroll=!u&&this.contained&&(t===s.body&&C||!E&&!C)&&(c>this.dragArea[2]+_-f||d>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!X(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?l?0:t.scrollLeft:0,o=i?l?0:t.scrollTop:0,c=i?this.scrollView[0]-n-y:0,d=i?this.scrollView[1]-o-v:0;this.targetBounds[0]=yt(r.top+s-(l?0:T),0),this.targetBounds[1]=yt(r.right+e-(l?a:S),0),this.targetBounds[2]=yt(r.bottom+s-(l?h:w),0),this.targetBounds[3]=yt(r.left+e-(l?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+_):(this.containerBounds[0]=-yt(r.top-(u?gt(T,0,h):T)+o-m,0),this.containerBounds[1]=-yt(r.right-(u?gt(S,0,a):S)-c+f,0),this.containerBounds[2]=-yt(r.bottom-(u?gt(w,0,h):w)-d+g,0),this.containerBounds[3]=-yt(r.left-(u?gt(b,0,a):b)+n-_,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(i,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,h]=this.disabled,l=!a&&e<o||!a&&e>r,c=!h&&s<i||!h&&s>n;return l&&!c?1:!l&&c?2:l&&c?3:0}refresh(){const t=this.parameters,i=t.x,r=t.y,n=ws(t.container,this),o=ws(t.containerPadding,this)||0,a=X(o)?o:[o,o,o,o],h=this.x,l=this.y,c=ws(t.cursor,this),d={onHover:"grab",onGrab:"grabbing"};if(c){const{onHover:t,onGrab:e}=c;t&&(d.onHover=t),e&&(d.onGrab=e)}this.containerArray=X(n)?n:null,this.$container=n&&!this.containerArray?ye(n)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=Lt(a,[0,0,0,0]),this.containerFriction=gt(Lt(ws(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=gt(Lt(ws(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=ws(U(i)&&!H(i.snap)?i.snap:t.snap,this),this.snapY=ws(U(r)&&!H(r.snap)?r.snap:t.snap,this),this.scrollSpeed=Lt(ws(t.scrollSpeed,this),1.5),this.scrollThreshold=Lt(ws(t.scrollThreshold,this),20),this.dragSpeed=Lt(ws(t.dragSpeed,this),1),this.minVelocity=Lt(ws(t.minVelocity,this),0),this.maxVelocity=Lt(ws(t.maxVelocity,this),50),this.velocityMultiplier=Lt(ws(t.velocityMultiplier,this),1),this.cursor=!1!==c&&d,this.updateBoundingValues();const[u,p,m,f]=this.containerBounds;this.setX(gt(h,f,p),!0),this.setY(gt(l,u,m),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],h=this.scroll.x,l=this.scroll.y,c=this.$container.scrollWidth,d=this.$container.scrollHeight,u=this.useWin?gt(c,this.window[0],c):c,p=this.useWin?gt(d,this.window[1],d):d,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,_=this.scrollThreshold,[y,v]=this.coords,[b,T,S,w]=this.scrollBounds,x=yt(gt((v-b+t)/_,-1,0)*g,0),C=yt(gt((y-T-e)/_,0,1)*g,0),E=yt(gt((v-S-s)/_,0,1)*g,0),k=yt(gt((y-w+i)/_,-1,0)*g,0);if(x||E||k||C){const[t,e]=this.disabled;let s=h,i=l;t||(s=yt(gt(h+(k||C),0,r-o),0),this.coords[0]-=h-s),e||(i=yt(gt(l+(x||E),0,n-a),0),this.coords[1]-=l-i),this.useWin?this.$scrollContainer.scrollBy(-(h-s),-(l-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,h,l]=this.pointer;this.coords[0]+=(r-h)*this.dragSpeed,this.coords[1]+=(n-l)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[c,d]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(c>e?e+(c-e)*m:c<i?i+(c-i)*m:c,!1),this.setY(d>s?s+(d-s)*m:d<t?t+(d-t)*m:d,!1),this.computeVelocity(r-h,n-l),this.angle=pt(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return de([this],null,"x"),de([this],null,"y"),de([this],null,"progressX"),de([this],null,"progressY"),de([this.scroll]),de([this.overshootCoords]),this}scrollInView(t,e=0,s=Be.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[h,l,c,d]=o,u=yt(gt(r-h,-m,0),0),p=yt(gt(i-l,0,m),0),f=yt(gt(r-c,0,m),0),g=yt(gt(i-d,-m,0),0);new We(n,{x:yt(n.x+(g?g-e:p?p+e:0),0),y:yt(n.y+(u?u-e:f?f+e:0),0),duration:H(t)?350*F.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Je(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=Be.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,h]=this.containerPadding,l=this.scroll.y-this.targetBounds[0]+n+e,c=this.scroll.x-this.targetBounds[1]-o-e,d=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+h+e,p=this.isOutOfBounds([l,c,d,u],i,r);if(p){const[e,n]=this.disabled,o=gt(vt(i,this.snapX),u,c),a=gt(vt(r,this.snapY),l,d),h=H(t)?350*F.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,h,s),n||2!==p&&3!==p||this.animate[this.yProp](a,h,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const i=t.changedTouches,r=i?i[0].clientX:t.clientX,n=i?i[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[h,l,c,d]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>l?l+(p-l)/u:p<d?d+(p-d)/u:p:p,this.coords[1]=this.coords[3]=u?m>c?c+(m-c)/u:m<h?h+(m-h)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Ge(this.$target,"zIndex",!1);xs=(f>xs?f:xs)+1,this.targetStyles=Je(this.$target,{zIndex:xs}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Je(s.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,Be.out(3)),this.onGrab(this),s.addEventListener("touchmove",this),s.addEventListener("touchend",this),s.addEventListener("touchcancel",this),s.addEventListener("mousemove",this),s.addEventListener("mouseup",this),s.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let h=t.target,l=!1,c=!1,d=!1;for(;e&&h&&h!==this.$trigger;){const t=Ge(h,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=h;if(e>s){d=!0,l=t<=3,c=t>=e-s-3;break}}h=h.parentElement}d&&(!l&&!c||l&&a<0||c&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(bs(t),this.triggerStyles||(this.triggerStyles=Je(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",bs,{passive:!1}),this.$trigger.addEventListener("touchmove",bs,{passive:!1}),this.$trigger.addEventListener("touchend",bs),(this.dragged||!this.disabled[0]&&at(o)>3||!this.disabled[1]&&at(a)>3)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[i,r,n,a,h,l]=this.pointer,[c,d,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,_=this.releaseYSpring,y=this.releaseEase,v=this.hasReleaseSpring,b=this.overshootCoords,T=this.x,S=this.y,w=this.computeVelocity(i-h,r-l),x=this.angle=pt(r-a,i-n),C=150*w,E=(1-this.releaseContainerFriction)*this.dragSpeed,k=T+ot(x)*C,$=S+nt(x)*C,B=k>d?d+(k-d)*E:k<p?p+(k-p)*E:k,O=$>u?u+($-u)*E:$<c?c+($-c)*E:$,N=this.destX=gt(yt(vt(B,this.snapX),5),p,d),R=this.destY=gt(yt(vt(O,this.snapY),5),c,u),D=this.isOutOfBounds(this.containerBounds,k,$);let L=0,A=0,M=y,P=y,I=0;if(b.x=T,b.y=S,!t){const t=N===d?T>d?-1:1:T<p?-1:1,s=yt(T-N,0);g.velocity=e&&v?s?C*t/at(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=g;L=T===N?0:v?r:r-n*F.timeScale,v&&(M=i),L>I&&(I=L)}if(!e){const e=R===u?S>u?-1:1:S<c?-1:1,s=yt(S-R,0);_.velocity=t&&v?s?C*e/at(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=_;A=S===R?0:v?r:r-n*F.timeScale,v&&(P=i),A>I&&(I=A)}if(!v&&D&&E&&(L||A)){const t=o.blend;new We(b,{x:{to:B,duration:.65*L},y:{to:O,duration:.65*A},ease:y,composition:t}).init(),new We(b,{x:{to:N,duration:L},y:{to:R,duration:A},ease:y,composition:t}).init(),this.overshootTicker.stretch(ut(L,A)).restart()}else t||this.animate[this.xProp](N,L,M),e||this.animate[this.yProp](R,A,P);this.scrollInView(I,this.scrollThreshold,y);let z=!1;N!==m&&(this.snapped[0]=N,this.snapX&&(z=!0)),R!==f&&this.snapY&&(this.snapped[1]=R,this.snapY&&(z=!0)),z&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",bs),this.$trigger.removeEventListener("touchmove",bs),this.$trigger.removeEventListener("touchend",bs),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Je(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":bs(t)}}}const Es=(t,e)=>new Cs(t,e),ks=(t=S)=>new fe({duration:1*F.timeScale,onComplete:t},null,0).resume(),$s=t=>{let e;return(...s)=>{let i,r,n,o;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,e.revert());const a=t(...s);return a&&!W(a)&&a.revert&&(e=a),H(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r),a||S}};class Bs{constructor(t={}){A.current&&A.current.register(this);const i=t.root;let r=s;i&&(r=i.current||i.nativeElement||ye(i)[0]||s);const n=t.defaults,o=F.defaults,a=t.mediaQueries;if(this.defaults=n?xt(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const s=e.matchMedia(a[t]);this.mediaQueryLists[t]=s,s.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=A.current,s=A.root,i=F.defaults;A.current=this,A.root=this.root,F.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return A.current=e,A.root=s,F.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);W(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,W(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);W(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,W(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);W(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(W(s))return s(this);const i=$s(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,h=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;h--;)i[h](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const Os=t=>new Bs(t),Ns=()=>{const t=s.createElement("div");s.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return s.body.removeChild(t),e},Rs=(t,e)=>t&&W(t)?t(e):t,Ds=new Map;class Ls{constructor(t){this.element=t,this.useWin=this.element===s.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new fe({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;Ct(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new fe({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=yt(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new fe({autoplay:!1,duration:250*F.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new fe({autoplay:!1,duration:500*F.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?e:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,s=this.element;this.scrollX=yt(t?e.scrollX:s.scrollLeft,0),this.scrollY=yt(t?e.scrollY:s.scrollTop,0)}updateWindowBounds(){this.winWidth=e.innerWidth,this.winHeight=Ns()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left}this.width=s,this.height=i}refreshScrollObservers(){Ct(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),Ct(this,t=>{t.refresh(),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?e:this.element).removeEventListener("scroll",this),Ds.delete(this.element)}}const As=t=>{const e=t&&ye(t)[0]||s.body;let i=Ds.get(e);return i||(i=new Ls(e),Ds.set(e,i)),i},Fs=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:h,u:l}=Xt(a,Yt);let c=h;return"%"===l?c=h/100*s:l&&(c=Se(t,Yt,"px",!0).n),o&&i<0&&(c+=i),n&&r>0&&(c+=r),c},Ms=(t,e,s,i,r)=>{let n;if(V(e)){const o=R.exec(e);if(o){const a=o[0],h=a[0],l=e.split(a),c="min"===l[0],d="max"===l[0],u=Fs(t,l[0],s,i,r),p=Fs(t,l[1],s,i,r);if(c){const e=It(Fs(t,"min",s),p,h);n=e<u?u:e}else if(d){const e=It(Fs(t,"max",s),p,h);n=e>u?u:e}else n=It(u,p,h)}else n=Fs(t,e,s,i,r)}else n=e;return yt(n,0)},Ps=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[h]){e=i;break}}return e};let Is=0;const zs=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class Xs{constructor(t={}){A.current&&A.current.register(this);const e=Lt(t.sync,"play pause"),i=e?De(e):null,r=e&&("linear"===e||e===we),n=e&&!(i===we&&!r),o=e&&(Y(e)||!0===e||r),a=e&&V(e)&&!n&&!o,h=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,l=a&&h.length>2;this.index=Is++,this.id=H(t.id)?this.index:t.id,this.container=As(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!h,this.syncEase=n?i:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=h&&!l&&h[0]?h[0]:S,this.onSyncLeave=h&&!l&&h[1]?h[1]:S,this.onSyncEnterForward=h&&l&&h[0]?h[0]:S,this.onSyncLeaveForward=h&&l&&h[1]?h[1]:S,this.onSyncEnterBackward=h&&l&&h[2]?h[2]:S,this.onSyncLeaveBackward=h&&l&&h[3]?h[3]:S,this.onEnter=t.onEnter||S,this.onLeave=t.onLeave||S,this.onEnterForward=t.onEnterForward||S,this.onLeaveForward=t.onLeaveForward||S,this.onEnterBackward=t.onEnterBackward||S,this.onLeaveBackward=t.onLeaveBackward||S,this.onUpdate=t.onUpdate||S,this.onSyncComplete=t.onSyncComplete||S,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=Lt(t.debug,!1),this._next=null,this._prev=null,kt(this.container,this),ks(()=>{if(!this.reverted){if(!this.target){const e=ye(t.target)[0];this.target=e||s.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,H(t)||(t.persist=!0),!this._params.target)){let e;H(t.targets)?Ct(t,t=>{t.targets&&!e&&(e=Ps(t))}):e=Ps(t),this.target=e||s.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:yt(gt(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=Lt(Rs(t.repeat,this),!0),this.horizontal="x"===Lt(Rs(t.axis,this),"y"),this.enter=Lt(Rs(t.enter,this),"end start"),this.leave=Lt(Rs(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,i=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=s.createElement("div"),n=s.createElement("div"),o=s.createElement("div"),a=zs[this.index%zs.length],h=t.useWin,l=h?t.winWidth:t.width,c=h?t.winHeight:t.height,d=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,_=e?g:15,y=e?60:g,v=e?y:_,b=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",S=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,w=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${w("absolute",m,f,e?d:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${w("sticky",0,0,e?l:g,e?g:c)}`,i||(n.style.cssText+=`background:\n ${S("#FFFF")}${T(g-10)} / 100px 100px ${b},\n ${S("#FFF8")}${T(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${w("relative",0,0,e?d:g,e?g:u)}`,i||(o.style.cssText+=`background:\n ${S("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${S("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const x=[" enter: "," leave: "];this.coords.forEach((t,i)=>{const r=i>1,h=(r?0:this.offset)+t,m=i%2,f=h<v,g=h>(r?e?l:c:e?d:u)-v,b=(r?m&&!f:!m&&!f)||g,T=s.createElement("div"),S=s.createElement("div"),C=e?b?"right":"left":b?"bottom":"top",E=b?(e?y:_)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;S.innerHTML=`${this.id}${x[m]}${this.thresholds[i]}`,T.style.cssText=`${w("absolute",0,0,y,_)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${C}: 2px solid ${a};\n `,S.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${_};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(S);let k=h-E+(e?1:0);T.style[e?"left":"top"]=`${k}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),i||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Ge(t.element,"position")&&(this.debugStyles=Je(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,i=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0)),a.parentElement;a&&a!==i.element&&a!==s.body;){const e="sticky"===Ge(a,"position")&&Je(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const h=e.getBoundingClientRect(),l=r?h.left+i.scrollX-i.left:h.top+i.scrollY-i.top,c=r?h.width:h.height,d=r?i.width:i.height,u=(r?i.scrollWidth:i.scrollHeight)-d,p=this.enter,m=this.leave;let f="start",g="end",_="end",y="start";if(V(p)){const t=p.split(" ");_=t[0],f=t.length>1?t[1]:f}else if(U(p)){const t=p;H(t.container)||(_=t.container),H(t.target)||(f=t.target)}else Y(p)&&(_=p);if(V(m)){const t=m.split(" ");y=t[0],g=t.length>1?t[1]:g}else if(U(m)){const t=m;H(t.container)||(y=t.container),H(t.target)||(g=t.target)}else Y(m)&&(y=m);const v=Ms(e,f,c),b=Ms(e,g,c),T=v+l-d,S=b+l-u,w=Ms(e,_,d,T,S),x=Ms(e,y,d,T,S),C=v+l-w,E=b+l-x,k=E-C;this.offset=l,this.offsetStart=C,this.offsetEnd=E,this.distance=k<=0?0:k,this.thresholds=[f,g,_,y],this.coords=[v,b,w,x],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,h=a<=this.offsetStart,l=a>=this.offsetEnd,c=!h&&!l,d=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&d,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(h&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&Y(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=yt(bt(e,g,bt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(c&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(c&&(this.isInView=!0),this.forceEnter&&this.hasEntered?c&&(this.forceEnter=!1):(p&&c&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(c||!c&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!c&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return Et(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const Us=(t={})=>new Xs(t),Ys=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,Vs=(t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=Ys(r,e,s)-t,i>0?o=r:n=r}while(at(i)>1e-7&&++a<100);return r},Ws=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?we:r=>0===r||1===r?r:Ys(Vs(r,t,s),e,i),Hs=(t=10,e)=>{const s=e?lt:ct;return e=>s(gt(e,0,1)*t)*(1/t)},qs=(...t)=>{const e=t.length;if(!e)return we;const s=e-1,i=t[0],r=t[s],n=[0],o=[st(i)];for(let e=1;e<s;e++){const i=t[e],r=V(i)?i.trim().split(" "):[i],a=r[0],h=r[1];n.push(H(h)?e/s:st(h)/100),o.push(st(a))}return o.push(st(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},js=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(gt(o,r,1))}return s.push(1),qs(...s)};var Qs=Object.freeze({__proto__:null,Spring:_s,createSpring:vs,cubicBezier:Ws,eases:Be,irregular:js,linear:qs,spring:ys,steps:Hs});const Gs=fs,Js={},Zs=(t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s),Ks=t=>(...e)=>{const s=t(...e);return new Proxy(S,{apply:(t,e,[i])=>s(i),get:(t,e)=>Ks((...t)=>{const i=Js[e](...t);return t=>i(s(t))})})},ti=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?Ks(Zs(e,s)):e)(...t);return Js[t]||(Js[t]=i),i},ei=ti("roundPad",Gs.roundPad),si=ti("padStart",Gs.padStart),ii=ti("padEnd",Gs.padEnd),ri=ti("wrap",Gs.wrap),ni=ti("mapRange",Gs.mapRange),oi=ti("degToRad",Gs.degToRad),ai=ti("radToDeg",Gs.radToDeg),hi=ti("snap",Gs.snap),li=ti("clamp",Gs.clamp),ci=ti("round",Gs.round),di=ti("lerp",Gs.lerp,1),ui=ti("damp",Gs.damp,1),pi=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let mi=0;const fi=(t,e=0,s=1,i=0)=>{let r=void 0===t?mi++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},gi=t=>t[pi(0,t.length-1)],_i=t=>{let e,s,i=t.length;for(;i;)s=pi(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},yi=(t,e={})=>{let s=[],i=0;const r=e.from,n=e.reversed,o=e.ease,a=!H(o),h=a&&!H(o.ease)?o.ease:a?De(o):null,l=e.grid,c=e.axis,d=e.total,u=H(r)||0===r||"first"===r,p="center"===r,m="last"===r,f="random"===r,g=X(t),y=e.use,v=st(g?t[0]:t),b=g?st(t[1]):0,T=B.exec((g?t[1]:t)+_),S=e.start||0+(g?v:0);let w=u?0:Y(r)?r:0;return(t,r,o,a)=>{const[u]=ve(t),_=H(d)?o:d,x=!H(y)&&(W(y)?y(u,r,_):Pt(u,y)),C=Y(x)||V(x)&&Y(+x)?+x:r;if(p&&(w=(_-1)/2),m&&(w=_-1),!s.length){for(let t=0;t<_;t++){if(l){const e=p?(l[0]-1)/2:w%l[0],i=p?(l[1]-1)/2:ct(w/l[0]),r=e-t%l[0],n=i-ct(t/l[0]);let o=rt(r*r+n*n);"x"===c&&(o=-r),"y"===c&&(o=-n),s.push(o)}else s.push(at(w-t));i=ut(...s)}h&&(s=s.map(t=>h(t/i)*i)),n&&(s=s.map(t=>c?t<0?-1*t:-t:at(i-t))),f&&(s=_i(s))}const E=g?(b-v)/i:v;let k=(a?ts(a,H(e.start)?a.iterationDuration:S):S)+(E*yt(s[C],2)||0);return e.modifier&&(k=e.modifier(k)),T&&(k=`${k}${T[2]}`),k}};var vi=Object.freeze({__proto__:null,$:ve,clamp:li,cleanInlineStyles:jt,createSeededRandom:fi,damp:ui,degToRad:oi,get:Ge,keepTime:$s,lerp:di,mapRange:ni,padEnd:ii,padStart:si,radToDeg:ai,random:pi,randomPick:gi,remove:Ze,round:ci,roundPad:ei,set:Je,shuffle:_i,snap:hi,stagger:yi,sync:ks,wrap:ri});const bi=t=>{const e=ye(t)[0];return e&&j(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},Ti=(t,e,s=0)=>t.getPointAtLength(e+s>=1?e+s:0),Si=(t,e)=>s=>{const i=+t.getTotalLength(),r=s[l],n=t.getCTM();return{from:0,to:i,modifier:s=>{if("a"===e){const e=Ti(t,s,-1),i=Ti(t,s,1);return 180*pt(i.y-e.y,i.x-e.x)/mt}{const i=Ti(t,s,0);return"x"===e?r||!n?i.x:i.x*n.a+i.y*n.c+n.e:r||!n?i.y:i.x*n.b+i.y*n.d+n.f}}}},wi=t=>{const e=bi(t);if(e)return{translateX:Si(e,"x"),translateY:Si(e,"y"),rotate:Si(e,"a")}},xi=t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(rt(s.a*s.a+s.b*s.b)+rt(s.c*s.c+s.d*s.d))/2)}return e},Ci=(t,e,s)=>{const i=f,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const h=new Proxy(t,{get(t,e){const s=t[e];return e===u?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],h=+s[1],l=xi(o),c=-1e3*r*l,d=h*i*l+c,u=i*l+(0===r&&1===h||1===r&&0===h?0:10*l)-d;if("butt"!==n){const e=r===h?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${c}`),t.setAttribute("stroke-dasharray",`${d} ${u}`)}return Reflect.apply(s,t,e)}:W(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),h.setAttribute("draw",`${e} ${s}`)),h},Ei=(t,e=0,s=0)=>ye(t).map(t=>Ci(t,e,s)),ki=(t,e=.33)=>s=>{const i=bi(t);if(!i)return;const r="path"===s.tagName,n=r?" ":",",o=s[d];o&&s.setAttribute(r?"d":"points",o);let a="",h="";if(e){const t=s.getTotalLength(),o=i.getTotalLength(),l=Math.max(Math.ceil(t*e),Math.ceil(o*e));for(let e=0;e<l;e++){const c=e/(l-1),d=s.getPointAtLength(t*c),u=i.getPointAtLength(o*c),p=r?0===e?"M":"L":"";a+=p+yt(d.x,3)+n+d.y+" ",h+=p+yt(u.x,3)+n+u.y+" "}}else a=s.getAttribute(r?"d":"points"),h=i.getAttribute(r?"d":"points");return s[d]=h,[a,h]};var $i=Object.freeze({__proto__:null,createDrawable:Ei,createMotionPath:wi,morphTo:ki});const Bi="undefined"!=typeof Intl&&Intl.Segmenter,Oi=/\{value\}/g,Ni=/\{i\}/g,Ri=/(\s+)/,Di=/^\s+$/,Li="line",Ai="word",Fi="char",Mi="data-line";let Pi=null,Ii=null,zi=null;const Xi=t=>t.isWordLike||" "===t.segment||Y(+t.segment),Ui=t=>t.setAttribute("aria-hidden","true"),Yi=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],Vi={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},Wi=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&Wi(e)}},Hi=(t,e,s)=>{const i=t.getAttribute(Mi);(null!==i&&+i!==e||"BR"===t.tagName)&&s.add(t);let r=t.childElementCount;for(;r--;)Hi(t.children[r],e,s);return s},qi=(t,e={})=>{let s="";const i=V(e.class)?` class="${e.class}"`:"",r=Lt(e.clone,!1),n=Lt(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},ji=(t,e,s,i,r,n,o,a,h)=>{const l=r===Li,c=r===Fi,d=`_${r}_`,u=W(t)?t(s):t,p=l?"block":"inline-block";zi.innerHTML=u.replace(Oi,`<i class="${d}"></i>`).replace(Ni,`${c?h:l?o:a}`);const m=zi.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,_=m.querySelectorAll(`i.${d}`),y=_.length;if(y){f.style.display=p,g.style.display=p,g.setAttribute(Mi,`${o}`),l||(g.setAttribute("data-word",`${a}`),c&&g.setAttribute("data-char",`${h}`));let t=y;for(;t--;){const e=_[t],i=e.parentElement;i.style.display=p,l?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${Vi[r]}`),f};class Qi{constructor(e,i={}){Pi||(Pi=Bi?new Bi([],{granularity:Ai}):{segment:t=>{const e=[],s=t.split(Ri);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!Di.test(i)})}return e}}),Ii||(Ii=Bi?new Bi([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!zi&&t&&(zi=s.createElement("template")),A.current&&A.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:h,debug:l}=i,c=(e=X(e)?e[0]:e)&&e.nodeType?e:(_e(e)||[])[0],d=!0===o?{}:o,u=!0===r||H(r)?{}:r,p=!0===n?{}:n;this.debug=Lt(l,!1),this.includeSpaces=Lt(h,!1),this.accessible=Lt(a,!0),this.linesOnly=d&&!u&&!p,this.lineTemplate=U(d)?qi(Li,d):d,this.wordTemplate=U(u)||this.linesOnly?qi(Ai,u):u,this.charTemplate=U(p)?qi(Fi,p):p,this.$target=c,this.html=c&&c.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(d||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=c.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?s.fonts.ready.then(m):m(),c?this.resizeObserver.observe(c):console.warn("No Text Splitter target found.")}addEffect(t){if(!W(t))return console.warn("Effect must return a function.");const e=$s(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>W(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,i=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],h=this.words,l=this.chars,c=Pi.segment(o),d=s.createDocumentFragment();let u=null;for(const t of c){const e=t.segment,s=Xi(t);if(!u||s&&u&&Xi(u))a.push(e);else{const t=a.length-1;a[t].includes(" ")||e.includes(" ")?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const c=a[t+1],u=r&&c&&!c.trim(),p=o,m=i?Ii.segment(p):null,f=i?s.createDocumentFragment():s.createTextNode(u?o+" ":o);if(i){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,c=s.createTextNode(a);ji(i,l,c,f,Fi,n,-1,h.length,l.length)}}e?ji(e,h,f,d,Ai,n,-1,h.length,l.length):i?d.appendChild(f):d.appendChild(s.createTextNode(o)),u&&t++}else{if(t&&r)continue;d.appendChild(s.createTextNode(o))}}t.parentNode.replaceChild(d,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,i=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==s.fonts.status,h=r&&a;this.ready=!r||a,(h||t)&&this.effectsCleanups.forEach(t=>W(t)&&t(this)),i||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),h&&(i&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=Yi(e,Ai))),o&&(h||n)&&(this.chars=Yi(e,Fi));const l=this.words.length?this.words:this.chars;let c,d=0;for(let t=0,e=l.length;t<e;t++){const e=l[t],{top:s,height:i}=e.getBoundingClientRect();c&&s-c>.5*i&&d++,e.setAttribute(Mi,`${d}`);const r=e.querySelectorAll(`[${Mi}]`);let n=r.length;for(;n--;)r[n].setAttribute(Mi,`${d}`);c=s}if(h){const t=s.createDocumentFragment(),i=new Set,a=[];for(let t=0;t<d+1;t++){const s=e.cloneNode(!0);Hi(s,t,new Set).forEach(t=>{const e=t.parentElement;e&&i.add(e),t.remove()}),a.push(s)}i.forEach(Wi);for(let e=0,s=a.length;e<s;e++)ji(r,this.lines,a[e],t,Li,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=Yi(e,Ai)),o&&(this.chars=Yi(e,Fi))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(h||!i)){const t=s.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(Ui),this.words.forEach(Ui),this.chars.forEach(Ui)}return this.width=e.offsetWidth,(h||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const Gi=(t,e)=>new Qi(t,e),Ji=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new Qi(t,e));var Zi=Object.freeze({__proto__:null,TextSplitter:Qi,split:Ji,splitText:Gi});const Ki=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(yt(t(i/e),4));return`linear(${s.join(", ")})`},tr={},er=t=>{let e=tr[t];if(e)return e;if(e="linear",V(t)){if(I(t,"linear")||I(t,"cubic-")||I(t,"steps")||I(t,"ease"))e=t;else if(I(t,"cubicB"))e=P(t);else{const s=Ne(t);W(s)&&(e=s===we?"linear":Ki(s))}tr[t]=e}else if(W(t)){const s=Ki(t);s&&(e=s)}else t.ease&&(e=Ki(t.ease));return e},sr=["x","y","z"],ir=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...sr],rr=(()=>[...sr,...b.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let nr=null;const or=(t,e,s,i,r)=>{let n=V(e)?e:At(e,s,i,r);return Y(n)?ir.includes(t)||I(t,"translate")?`${n}px`:I(t,"rotate")||I(t,"skew")?`${n}deg`:`${n}`:n},ar=(t,e,s,i,r,n)=>{let o="0";const a=H(i)?getComputedStyle(t)[e]:or(e,i,t,r,n);return o=H(s)?X(i)?i.map(s=>or(e,s,t,r,n)):a:[or(e,s,t,r,n),a],o};class hr{constructor(e,s){A.current&&A.current.register(this),q(nr)&&(!t||!H(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(b.forEach(t=>{const e=I(t,"skew"),s=I(t,"scale"),i=I(t,"rotate"),r=I(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),nr=!0):nr=!1);const i=ve(e),r=i.length;r||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const n=Lt(s.ease,er(F.defaults.ease)),o=n.ease&&n,a=Lt(s.autoplay,F.defaults.autoplay),h=!(!a||!a.link)&&a,l=s.alternate&&!0===s.alternate,d=s.reversed&&!0===s.reversed,u=Lt(s.loop,F.defaults.loop),p=!0===u||u===1/0?1/0:Y(u)?u+1:1,m=l?d?"alternate-reverse":"alternate":d?"reverse":"normal",g=er(n),y=1===F.timeScale?1:f;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||F.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!a||!1!==h,this.reversed=d,this.persist=Lt(s.persist,F.defaults.persist),this.autoplay=a,this._speed=Lt(s.playbackRate,F.defaults.playbackRate),this._resolve=S,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const i=t[c],a=rr.some(t=>s.hasOwnProperty(t)),h=t.style,l=this._inlineStyles[e]={},d=(o?o.settlingDuration:At(Lt(s.duration,F.defaults.duration),t,e,r))*y,u=At(Lt(s.delay,F.defaults.delay),t,e,r)*y,f=Lt(s.composition,"replace");for(let o in s){if(!K(o))continue;const c={},_={iterations:p,direction:m,fill:"both",easing:g,duration:d,delay:u,composite:f},T=s[o],S=!!a&&(b.includes(o)?o:v.get(o)),w=S?"transform":o;let x;if(l[w]||(l[w]=h[w]),U(T)){const s=T,a=Lt(s.ease,n),l=a.ease&&a,p=s.to,m=s.from;if(_.duration=(l?l.settlingDuration:At(Lt(s.duration,d),t,e,r))*y,_.delay=At(Lt(s.delay,u),t,e,r)*y,_.composite=Lt(s.composition,f),_.easing=er(a),x=ar(t,o,m,p,e,r),S?(c[`--${S}`]=x,i[S]=x):c[o]=ar(t,o,m,p,e,r),Qe(this,t,o,c,_),!H(m))if(S){const t=`--${S}`;h.setProperty(t,c[t][0])}else h[o]=c[o][0]}else x=X(T)?T.map(s=>or(o,s,t,e,r)):or(o,T,t,e,r),S?(c[`--${S}`]=x,i[S]=x):c[o]=x,Qe(this,t,o,c,_)}if(a){let t=_;for(let e in i)t+=`${T[e]}var(--${e})) `;h.transform=t}}),h&&this.autoplay.link(this)}forEach(t){const e=V(t)?e=>e[t]():t;return this.animations.forEach(e),this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=F.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===F.timeScale?1:f);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel")}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let t in i){const e=i[t];H(e)||e===_?s.removeProperty(P(t)):s[t]=e}t.getAttribute("style")===_&&t.removeAttribute("style")}),this}then(t=S){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=S};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const lr={animate:(t,e)=>new hr(t,e),convertEase:Ki};export{ve as $,ns as Animatable,Cs as Draggable,We as JSAnimation,Bs as Scope,Xs as ScrollObserver,_s as Spring,Qi as TextSplitter,is as Timeline,fe as Timer,hr as WAAPIAnimation,He as animate,li as clamp,jt as cleanInlineStyles,os as createAnimatable,Es as createDraggable,Ei as createDrawable,wi as createMotionPath,Os as createScope,fi as createSeededRandom,vs as createSpring,rs as createTimeline,ge as createTimer,Ws as cubicBezier,ui as damp,oi as degToRad,Be as eases,Qs as easings,ee as engine,Ge as get,js as irregular,$s as keepTime,di as lerp,qs as linear,ni as mapRange,ki as morphTo,Us as onScroll,ii as padEnd,si as padStart,ai as radToDeg,pi as random,gi as randomPick,Ze as remove,ci as round,ei as roundPad,Ds as scrollContainers,Je as set,_i as shuffle,hi as snap,Ji as split,Gi as splitText,ys as spring,yi as stagger,Hs as steps,$i as svg,ks as sync,Zi as text,vi as utils,lr as waapi,ri as wrap};
diff --git a/dist/bundles/anime.umd.js b/dist/bundles/anime.umd.js
index d84af67d..11c1eae8 100644
--- a/dist/bundles/anime.umd.js
+++ b/dist/bundles/anime.umd.js
@@ -17,6 +17,7 @@
* @property {Number|Boolean} [loop]
* @property {Boolean} [reversed]
* @property {Boolean} [alternate]
+ * @property {Boolean} [persist]
* @property {Boolean|ScrollObserver} [autoplay]
* @property {Number|FunctionValue} [duration]
* @property {Number|FunctionValue} [delay]
@@ -24,13 +25,13 @@
* @property {EasingParam} [ease]
* @property {'none'|'replace'|'blend'|compositionTypes} [composition]
* @property {(v: any) => any} [modifier]
- * @property {(tickable: Tickable) => void} [onBegin]
- * @property {(tickable: Tickable) => void} [onBeforeUpdate]
- * @property {(tickable: Tickable) => void} [onUpdate]
- * @property {(tickable: Tickable) => void} [onLoop]
- * @property {(tickable: Tickable) => void} [onPause]
- * @property {(tickable: Tickable) => void} [onComplete]
- * @property {(renderable: Renderable) => void} [onRender]
+ * @property {Callback<Tickable>} [onBegin]
+ * @property {Callback<Tickable>} [onBeforeUpdate]
+ * @property {Callback<Tickable>} [onUpdate]
+ * @property {Callback<Tickable>} [onLoop]
+ * @property {Callback<Tickable>} [onPause]
+ * @property {Callback<Tickable>} [onComplete]
+ * @property {Callback<Renderable>} [onRender]
*/
/** @typedef {JSAnimation|Timeline} Renderable */
@@ -86,7 +87,11 @@
*/
/**
- * @typedef {('linear'|'linear(x1, x2 25%, x3)'|'in'|'out'|'inOut'|'inQuad'|'outQuad'|'inOutQuad'|'inCubic'|'outCubic'|'inOutCubic'|'inQuart'|'outQuart'|'inOutQuart'|'inQuint'|'outQuint'|'inOutQuint'|'inSine'|'outSine'|'inOutSine'|'inCirc'|'outCirc'|'inOutCirc'|'inExpo'|'outExpo'|'inOutExpo'|'inBounce'|'outBounce'|'inOutBounce'|'inBack'|'outBack'|'inOutBack'|'inElastic'|'outElastic'|'inOutElastic'|'irregular'|'cubicBezier'|'steps'|'in(p = 1.675)'|'out(p = 1.675)'|'inOut(p = 1.675)'|'inBack(overshoot = 1.70158)'|'outBack(overshoot = 1.70158)'|'inOutBack(overshoot = 1.70158)'|'inElastic(amplitude = 1, period = .3)'|'outElastic(amplitude = 1, period = .3)'|'inOutElastic(amplitude = 1, period = .3)'|'irregular(length = 10, randomness = 1)'|'cubicBezier(x1, y1, x2, y2)'|'steps(steps = 10)')} EaseStringParamNames
+ * @typedef {('linear'|'none'|'in'|'out'|'inOut'|'inQuad'|'outQuad'|'inOutQuad'|'inCubic'|'outCubic'|'inOutCubic'|'inQuart'|'outQuart'|'inOutQuart'|'inQuint'|'outQuint'|'inOutQuint'|'inSine'|'outSine'|'inOutSine'|'inCirc'|'outCirc'|'inOutCirc'|'inExpo'|'outExpo'|'inOutExpo'|'inBounce'|'outBounce'|'inOutBounce'|'inBack'|'outBack'|'inOutBack'|'inElastic'|'outElastic'|'inOutElastic'|'out(p = 1.675)'|'inOut(p = 1.675)'|'inBack(overshoot = 1.7)'|'outBack(overshoot = 1.7)'|'inOutBack(overshoot = 1.7)'|'inElastic(amplitude = 1, period = .3)'|'outElastic(amplitude = 1, period = .3)'|'inOutElastic(amplitude = 1, period = .3)')} EaseStringParamNames
+ */
+
+/**
+ * @typedef {('ease'|'ease-in'|'ease-out'|'ease-in-out'|'linear(0, 0.25, 1)'|'steps'|'steps(6, start)'|'step-start'|'step-end'|'cubic-bezier(0.42, 0, 1, 1)') } WAAPIEaseStringParamNames
*/
/**
@@ -97,7 +102,7 @@
/**
* @callback BackEasing
- * @param {Number|String} [overshoot=1.70158]
+ * @param {Number|String} [overshoot=1.7]
* @return {EasingFunction}
*/
@@ -113,6 +118,7 @@
// A hack to get both ease names suggestions AND allow any strings
// https://github.com/microsoft/TypeScript/issues/29729#issuecomment-460346421
/** @typedef {(String & {})|EaseStringParamNames|EasingFunction|Spring} EasingParam */
+/** @typedef {(String & {})|EaseStringParamNames|WAAPIEaseStringParamNames|EasingFunction|Spring} WAAPIEasingParam */
// Spring types
@@ -122,6 +128,9 @@
* @property {Number} [stiffness=100] - Stiffness, default 100
* @property {Number} [damping=10] - Damping, default 10
* @property {Number} [velocity=0] - Initial velocity, default 0
+ * @property {Number} [bounce=0] - Initial bounce, default 0
+ * @property {Number} [duration=0] - The perceived duration, default 0
+ * @property {Callback<JSAnimation>} [onComplete] - Callback function called when the spring currentTime hits the perceived duration
*/
// Callback types
@@ -219,6 +228,7 @@
* @property {Number} _isOverlapped
* @property {Number} _isOverridden
* @property {Number} _renderTransforms
+ * @property {String} _inlineValue
* @property {Tween} _prevRep
* @property {Tween} _nextRep
* @property {Tween} _prevAdd
@@ -376,7 +386,7 @@
*/
/**
- * @typedef {(animation: WAAPIAnimation) => void} WAAPICallback
+ * @typedef {Callback<WAAPIAnimation>} WAAPICallback
*/
/**
@@ -385,7 +395,7 @@
* @property {WAAPIKeyframeValue} [from]
* @property {Number|WAAPIFunctionValue} [duration]
* @property {Number|WAAPIFunctionValue} [delay]
- * @property {EasingParam} [ease]
+ * @property {WAAPIEasingParam} [ease]
* @property {CompositeOperation} [composition]
*/
@@ -398,13 +408,14 @@
* @property {Number} [playbackRate]
* @property {Number|WAAPIFunctionValue} [duration]
* @property {Number|WAAPIFunctionValue} [delay]
- * @property {EasingParam} [ease]
+ * @property {WAAPIEasingParam} [ease]
* @property {CompositeOperation} [composition]
+ * @property {Boolean} [persist]
* @property {WAAPICallback} [onComplete]
*/
/**
- * @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | WAAPICallback | EasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams
+ * @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | WAAPICallback | WAAPIEasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams
*/
// Animatable types
@@ -688,6 +699,8 @@
// Strings
const emptyString = '';
+ const cssVarPrefix = 'var(';
+
const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -711,9 +724,9 @@
'skew',
'skewX',
'skewY',
- 'perspective',
'matrix',
'matrix3d',
+ 'perspective',
];
const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) => ({...a, [v]: v + '('}), {});
@@ -737,6 +750,7 @@
const lowerCaseRgx = /([a-z])([A-Z])/g;
const transformsExecRgx = /(\w+)(\([^)]+\)+)/g; // Match inline transforms with cacl() values, returns the value wrapped in ()
const relativeValuesExecRgx = /(\*=|\+=|-=)/;
+ const cssVariableMatchRgx = /var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/;
@@ -751,6 +765,7 @@
reversed: false,
alternate: false,
autoplay: true,
+ persist: false,
duration: K,
delay: 0,
loopDelay: 0,
@@ -1174,19 +1189,30 @@
* @return {any}
*/
const getFunctionValue = (value, target, index, total, store) => {
+ let func;
if (isFnc(value)) {
- const func = () => {
+ func = () => {
const computed = /** @type {Function} */(value)(target, index, total);
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed || 0;
};
- if (store) {
- store.func = func;
- }
- return func();
+ } else if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
+ func = () => {
+ const match = value.match(cssVariableMatchRgx);
+ const cssVarName = match[1];
+ const fallbackValue = match[2];
+ let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
+ // Use fallback if CSS variable is not set or empty
+ if ((!computed || computed.trim() === emptyString) && fallbackValue) {
+ computed = fallbackValue.trim();
+ }
+ return computed || 0;
+ };
} else {
return value;
}
+ if (store) store.func = func;
+ return func();
};
/**
@@ -1593,7 +1619,9 @@
// Handle setters on timeline differently and allow re-trigering the onComplete callback when seeking backwards
if (parent && isSetter) {
if (!muteCallbacks && (
- (parent.began && !isRunningBackwards && tickableAbsoluteTime >= duration && !completed) ||
+ // (tickableAbsoluteTime > 0 instead) of (tickableAbsoluteTime >= duration) to prevent floating point precision issues
+ // see: https://github.com/juliangarnier/anime/issues/1088
+ (parent.began && !isRunningBackwards && tickableAbsoluteTime > 0 && !completed) ||
(isRunningBackwards && tickableAbsoluteTime <= minValue && completed)
)) {
tickable.onComplete(/** @type {CallbackArgument} */(tickable));
@@ -1695,13 +1723,12 @@
}
};
- const propertyNamesCache = {};
-
-
+ const propertyNamesCache = {};
+
/**
* @param {String} propertyName
* @param {Target} target
@@ -1748,10 +1775,11 @@
const tweenTarget = tween.target;
if (tweenTarget[isDomSymbol]) {
const targetStyle = /** @type {DOMTarget} */(tweenTarget).style;
- const originalInlinedValue = animation._inlineStyles[tweenProperty];
+ const originalInlinedValue = tween._inlineValue;
+ const tweenHadNoInlineValue = isNil(originalInlinedValue) || originalInlinedValue === emptyString;
if (tween._tweenType === tweenTypes.TRANSFORM) {
const cachedTransforms = tweenTarget[transformsSymbol];
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ if (tweenHadNoInlineValue) {
delete cachedTransforms[tweenProperty];
} else {
cachedTransforms[tweenProperty] = originalInlinedValue;
@@ -1768,8 +1796,8 @@
}
}
} else {
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
- targetStyle.removeProperty(tweenProperty);
+ if (tweenHadNoInlineValue) {
+ targetStyle.removeProperty(toLowerCase(tweenProperty));
} else {
targetStyle[tweenProperty] = originalInlinedValue;
}
@@ -3054,6 +3082,7 @@
+
/** @type {PowerEasing} */
const easeInPower = (p = 1.68) => t => pow(t, +p);
@@ -3071,154 +3100,6 @@
outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
};
- /**
- * @param {String} string
- * @param {Record<String, EasingFunctionWithParams|EasingFunction>} easesFunctions
- * @param {Object} easesLookups
- * @return {EasingFunction}
- */
- const parseEaseString = (string, easesFunctions, easesLookups) => {
- if (easesLookups[string]) return easesLookups[string];
- if (string.indexOf('(') <= -1) {
- const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
- const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(easesFunctions[string])() : easesFunctions[string]);
- return parsedFn ? easesLookups[string] = parsedFn : none;
- } else {
- const split = string.slice(0, -1).split('(');
- const parsedFn = /** @type {EasingFunctionWithParams} */(easesFunctions[split[0]]);
- return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
- }
- };
-
-
-
- /**
- * Cubic Bezier solver adapted from https://github.com/gre/bezier-easing
- * (c) 2014 Gaëtan Renaudeau
- */
-
- /**
- * @param {Number} aT
- * @param {Number} aA1
- * @param {Number} aA2
- * @return {Number}
- */
- const calcBezier = (aT, aA1, aA2) => (((1 - 3 * aA2 + 3 * aA1) * aT + (3 * aA2 - 6 * aA1)) * aT + (3 * aA1)) * aT;
-
- /**
- * @param {Number} aX
- * @param {Number} mX1
- * @param {Number} mX2
- * @return {Number}
- */
- const binarySubdivide = (aX, mX1, mX2) => {
- let aA = 0, aB = 1, currentX, currentT, i = 0;
- do {
- currentT = aA + (aB - aA) / 2;
- currentX = calcBezier(currentT, mX1, mX2) - aX;
- if (currentX > 0) {
- aB = currentT;
- } else {
- aA = currentT;
- }
- } while (abs(currentX) > .0000001 && ++i < 100);
- return currentT;
- };
-
- /**
- * @param {Number} [mX1] The x coordinate of the first point
- * @param {Number} [mY1] The y coordinate of the first point
- * @param {Number} [mX2] The x coordinate of the second point
- * @param {Number} [mY2] The y coordinate of the second point
- * @return {EasingFunction}
- */
-
- const cubicBezier = (mX1 = 0.5, mY1 = 0.0, mX2 = 0.5, mY2 = 1.0) => (mX1 === mY1 && mX2 === mY2) ? none :
- t => t === 0 || t === 1 ? t :
- calcBezier(binarySubdivide(t, mX1, mX2), mY1, mY2);
-
-
-
- /**
- * Steps ease implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
- * Only covers 'end' and 'start' jumpterms
- * @param {Number} steps
- * @param {Boolean} [fromStart]
- * @return {EasingFunction}
- */
- const steps = (steps = 10, fromStart) => {
- const roundMethod = fromStart ? ceil : floor;
- return t => roundMethod(clamp$1(t, 0, 1) * steps) * (1 / steps);
- };
-
-
-
- /**
- * Without parameters, the linear function creates a non-eased transition.
- * Parameters, if used, creates a piecewise linear easing by interpolating linearly between the specified points.
- *
- * @param {...(String|Number)} args - Points
- * @return {EasingFunction}
- */
- const linear = (...args) => {
- const argsLength = args.length;
- if (!argsLength) return none;
- const totalPoints = argsLength - 1;
- const firstArg = args[0];
- const lastArg = args[totalPoints];
- const xPoints = [0];
- const yPoints = [parseNumber(firstArg)];
- for (let i = 1; i < totalPoints; i++) {
- const arg = args[i];
- const splitValue = isStr(arg) ?
- /** @type {String} */(arg).trim().split(' ') :
- [arg];
- const value = splitValue[0];
- const percent = splitValue[1];
- xPoints.push(!isUnd(percent) ? parseNumber(percent) / 100 : i / totalPoints);
- yPoints.push(parseNumber(value));
- }
- yPoints.push(parseNumber(lastArg));
- xPoints.push(1);
- return function easeLinear(t) {
- for (let i = 1, l = xPoints.length; i < l; i++) {
- const currentX = xPoints[i];
- if (t <= currentX) {
- const prevX = xPoints[i - 1];
- const prevY = yPoints[i - 1];
- return prevY + (yPoints[i] - prevY) * (t - prevX) / (currentX - prevX);
- }
- }
- return yPoints[yPoints.length - 1];
- }
- };
-
-
-
- /**
- * Generate random steps
- * @param {Number} [length] - The number of steps
- * @param {Number} [randomness] - How strong the randomness is
- * @return {EasingFunction}
- */
- const irregular = (length = 10, randomness = 1) => {
- const values = [0];
- const total = length - 1;
- for (let i = 1; i < total; i++) {
- const previousValue = values[i - 1];
- const spacing = i / total;
- const segmentEnd = (i + 1) / total;
- const randomVariation = spacing + (segmentEnd - spacing) * Math.random();
- // Mix the even spacing and random variation based on the randomness parameter
- const randomValue = spacing * (1 - randomness) + randomVariation * randomness;
- values.push(clamp$1(randomValue, previousValue, 1));
- }
- values.push(1);
- return linear(...values);
- };
-
-
-
/**
* Easing functions adapted and simplified from https://robertpenner.com/easing/
* (c) 2001 Robert Penner
@@ -3247,7 +3128,7 @@
return 1 / pow(4, 3 - b) - 7.5625 * pow((pow2 * 3 - 2) / 22 - t, 2);
},
/** @type {BackEasing} */
- Back: (overshoot = 1.70158) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
+ Back: (overshoot = 1.7) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
/** @type {ElasticEasing} */
Elastic: (amplitude = 1, period = .3) => {
const a = clamp$1(+amplitude, 1, 10);
@@ -3260,10 +3141,8 @@
/**
* @typedef {Object} EasesFunctions
- * @property {typeof linear} linear
- * @property {typeof irregular} irregular
- * @property {typeof steps} steps
- * @property {typeof cubicBezier} cubicBezier
+ * @property {typeof none} linear
+ * @property {typeof none} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
@@ -3311,7 +3190,7 @@
*/
const eases = (/*#__PURE__ */ (() => {
- const list = { linear, irregular, steps, cubicBezier };
+ const list = { linear: none, none: none };
for (let type in easeTypes) {
for (let name in easeInFunctions) {
const easeIn = easeInFunctions[name];
@@ -3327,15 +3206,43 @@
})());
/** @type {Record<String, EasingFunction>} */
- const JSEasesLookups = { linear: none };
+ const easesLookups = { linear: none, none: none };
+
+ /**
+ * @param {String} string
+ * @return {EasingFunction}
+ */
+ const parseEaseString = (string) => {
+ if (easesLookups[string]) return easesLookups[string];
+ if (string.indexOf('(') <= -1) {
+ const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
+ const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(eases[string])() : eases[string]);
+ return parsedFn ? easesLookups[string] = parsedFn : none;
+ } else {
+ const split = string.slice(0, -1).split('(');
+ const parsedFn = /** @type {EasingFunctionWithParams} */(eases[split[0]]);
+ return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
+ }
+ };
+
+ const deprecated = ['steps(', 'irregular(', 'linear(', 'cubicBezier('];
/**
* @param {EasingParam} ease
* @return {EasingFunction}
*/
- const parseEase = ease => isFnc(ease) ? ease :
- isStr(ease) ? parseEaseString(/** @type {String} */(ease), eases, JSEasesLookups) :
- none;
+ const parseEase = ease => {
+ if (isStr(ease)) {
+ for (let i = 0, l = deprecated.length; i < l; i++) {
+ if (stringStartsWith(ease, deprecated[i])) {
+ console.warn(`String syntax for \`ease: "${ease}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${ease}\``);
+ return none;
+ }
+ }
+ }
+ const easeFunc = isFnc(ease) ? ease : isStr(ease) ? parseEaseString(/** @type {String} */(ease)) : none;
+ return easeFunc;
+ };
@@ -3343,6 +3250,7 @@
// TODO: Maybe move the objects creation to values.js and use the decompose function to create the base object
const fromTargetObject = createDecomposedValueTargetObject();
const toTargetObject = createDecomposedValueTargetObject();
+ const inlineStylesStore = {};
const toFunctionStore = { func: null };
const keyframesTargetArray = [null];
const fastSetValuesArray = [null, null];
@@ -3487,15 +3395,15 @@
const animEase = animaPlaybackEase ? parseEase(animaPlaybackEase) : null;
const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */(ease).ease);
const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */(ease).duration : setValue(duration, animDefaults.duration);
+ const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : setValue(duration, animDefaults.duration);
const tDelay = setValue(delay, animDefaults.delay);
const tModifier = modifier || animDefaults.modifier;
// If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
const tComposition = isUnd(composition) && targetsLength >= K ? compositionTypes.none : !isUnd(composition) ? composition : animDefaults.composition;
- // TODO: Do not create an empty object until we know the animation will generate inline styles
- const animInlineStyles = {};
// const absoluteOffsetTime = this._offset;
const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
+ // This allows targeting the current animation in the spring onComplete callback
+ if (hasSpring) /** @type {Spring} */(ease).parent = this;
let iterationDuration = NaN;
let iterationDelay = NaN;
@@ -3597,7 +3505,7 @@
// Easing are treated differently and don't accept function based value to prevent having to pass a function wrapper that returns an other function all the time
const tweenEasing = hasSpring ? /** @type {Spring} */(keyEasing).ease : keyEasing || tEasing;
// Calculate default individual keyframe duration by dividing the tl of keyframes
- const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).duration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
+ const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).settlingDuration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
// Default delay value should only be applied to the first tween
const tweenDelay = getFunctionValue(setValue(key.delay, (!tweenIndex ? tDelay : 0)), target, ti, tl);
const computedComposition = getFunctionValue(setValue(key.composition, tComposition), target, ti, tl);
@@ -3647,7 +3555,7 @@
}
} else {
decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
decomposedOriginalValue
);
if (decomposedOriginalValue.t === valueTypes.UNIT) {
@@ -3665,7 +3573,7 @@
} else {
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), toTargetObject);
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), toTargetObject);
}
}
if (hasFromvalue) {
@@ -3676,7 +3584,7 @@
} else {
decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), fromTargetObject);
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
}
@@ -3685,7 +3593,7 @@
if (fromTargetObject.o) {
fromTargetObject.n = getRelativeValue(
!prevSibling ? decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
decomposedOriginalValue
).n : prevSibling._toNumber,
fromTargetObject.n,
@@ -3741,6 +3649,10 @@
// Rounding is necessary here to minimize floating point errors when working in seconds
const tweenUpdateDuration = round$1(+tweenDuration || minValue, 12);
+ // Copy the value of the iniline style if it exist and imediatly nullify it to prevents false positive on other targets
+ let inlineValue = inlineStylesStore[propName];
+ if (!isNil(inlineValue)) inlineStylesStore[propName] = null;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -3772,6 +3684,7 @@
_isOverlapped: 0,
_isOverridden: 0,
_renderTransforms: 0,
+ _inlineValue: inlineValue,
_prevRep: null, // For replaced tween
_nextRep: null, // For replaced tween
_prevAdd: null, // For additive tween
@@ -3874,8 +3787,6 @@
// this._offset += parent ? iterationDelay : 0;
/** @type {Number} */
this.iterationDuration = iterationDuration;
- /** @type {{}} */
- this._inlineStyles = animInlineStyles;
if (!this._autoplay && shouldTriggerRender) this.onRender(this);
}
@@ -3909,6 +3820,7 @@
if (tweenFunc) {
const ogValue = getOriginalAnimatableValue(tween.target, tween.property, tween._tweenType);
decomposeRawValue(ogValue, decomposedOriginalValue);
+ // TODO: Check for from / to Array based values here,
decomposeRawValue(tweenFunc(), toTargetObject);
tween._fromNumbers = cloneArray(decomposedOriginalValue.d);
tween._fromNumber = decomposedOriginalValue.n;
@@ -3918,6 +3830,8 @@
tween._toNumber = toTargetObject.o ? getRelativeValue(decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
}
});
+ // This forces setter animations to render once
+ if (this.duration === minValue) this.restart();
return this;
}
@@ -3960,16 +3874,18 @@
* @param {DOMTarget} $el
* @param {String} [property]
* @param {WAAPIAnimation} [parent]
+ * @return {globalThis.Animation}
*/
const removeWAAPIAnimation = ($el, property, parent) => {
let nextLookup = WAAPIAnimationsLookups._head;
+ let anim;
while (nextLookup) {
const next = nextLookup._next;
const matchTarget = nextLookup.$el === $el;
const matchProperty = !property || nextLookup.property === property;
const matchParent = !parent || nextLookup.parent === parent;
if (matchTarget && matchProperty && matchParent) {
- const anim = nextLookup.animation;
+ anim = nextLookup.animation;
try { anim.commitStyles(); } catch {} anim.cancel();
removeChild(WAAPIAnimationsLookups, nextLookup);
const lookupParent = nextLookup.parent;
@@ -3977,8 +3893,8 @@
lookupParent._completed++;
if (lookupParent.animations.length === lookupParent._completed) {
lookupParent.completed = true;
+ lookupParent.paused = true;
if (!lookupParent.muteCallbacks) {
- lookupParent.paused = true;
lookupParent.onComplete(lookupParent);
lookupParent._resolve(lookupParent);
}
@@ -3987,6 +3903,7 @@
}
nextLookup = next;
}
+ return anim;
};
/**
@@ -3995,7 +3912,7 @@
* @param {String} property
* @param {PropertyIndexedKeyframes} keyframes
* @param {KeyframeAnimationOptions} params
- * @retun {Animation}
+ * @retun {globalThis.Animation}
*/
const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
const animation = $el.animate(keyframes, params);
@@ -4010,8 +3927,11 @@
removeWAAPIAnimation($el, property);
addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
+ animation.oncancel = handleRemove;
animation.onremove = handleRemove;
- animation.onfinish = handleRemove;
+ if (!parent.persist) {
+ animation.onfinish = handleRemove;
+ }
return animation;
};
@@ -4639,8 +4559,10 @@
+
+
/*
- * Spring ease solver adapted from https://webkit.org/demos/spring/spring.js
+ * Spring easing solver adapted from https://webkit.org/demos/spring/spring.js
* (c) 2016 Webkit - Apple Inc
*/
@@ -4651,25 +4573,46 @@
* @param {SpringParams} [parameters]
*/
constructor(parameters = {}) {
+ const hasBounceOrDuration = !isUnd(parameters.bounce) || !isUnd(parameters.duration);
this.timeStep = .02; // Interval fed to the solver to calculate duration
this.restThreshold = .0005; // Values below this threshold are considered resting position
this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
this.maxRestSteps = this.restDuration / this.timeStep / K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
this.maxIterations = this.maxDuration / this.timeStep / K; // Calculate the maximum iterations allowed based on maxDuration
- this.m = clamp$1(setValue(parameters.mass, 1), 0, maxSpringParamValue);
- this.s = clamp$1(setValue(parameters.stiffness, 100), 1, maxSpringParamValue);
- this.d = clamp$1(setValue(parameters.damping, 10), .1, maxSpringParamValue);
+ this.bn = clamp$1(setValue(parameters.bounce, .5), -1, 1); // The bounce percentage between -1 and 1.
+ this.pd = clamp$1(setValue(parameters.duration, 628), 10 * globals.timeScale, maxSpringParamValue * globals.timeScale); // The perceived duration
+ this.m = clamp$1(setValue(parameters.mass, 1), 1, maxSpringParamValue);
+ this.s = clamp$1(setValue(parameters.stiffness, 100), minValue, maxSpringParamValue);
+ this.d = clamp$1(setValue(parameters.damping, 10), minValue, maxSpringParamValue);
this.v = clamp$1(setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
this.w0 = 0;
this.zeta = 0;
this.wd = 0;
this.b = 0;
+ this.completed = false;
this.solverDuration = 0;
- this.duration = 0;
+ this.settlingDuration = 0;
+ /** @type {JSAnimation} */
+ this.parent = null;
+ /** @type {Callback<JSAnimation>} */
+ this.onComplete = parameters.onComplete || noop;
+ if (hasBounceOrDuration) this.calculateSDFromBD();
this.compute();
/** @type {EasingFunction} */
- this.ease = t => t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
+ this.ease = t => {
+ const currentTime = t * this.settlingDuration;
+ const completed = this.completed;
+ const perceivedTime = this.pd;
+ if (currentTime >= perceivedTime && !completed) {
+ this.completed = true;
+ this.onComplete(this.parent);
+ }
+ if (currentTime < perceivedTime && completed) {
+ this.completed = false;
+ }
+ return t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
+ };
}
/** @type {EasingFunction} */
@@ -4677,23 +4620,83 @@
const { zeta, w0, wd, b } = this;
let t = time;
if (zeta < 1) {
+ // Underdamped
t = exp(-t * zeta * w0) * (1 * cos(wd * t) + b * sin(wd * t));
- } else {
+ } else if (zeta === 1) {
+ // Critically damped
t = (1 + b * t) * exp(-t * w0);
+ } else {
+ // Overdamped
+ // Using exponential instead of cosh and sinh functions to prevent Infinity
+ // Original exp(-zeta * w0 * t) * (cosh(wd * t) + b * sinh(wd * t))
+ t = ((1 + b) * exp((-zeta * w0 + wd) * t) + (1 - b) * exp((-zeta * w0 - wd) * t)) / 2;
}
return 1 - t;
}
+ calculateSDFromBD() {
+ // Apple's SwiftUI perceived spring duration implementation https://developer.apple.com/videos/play/wwdc2023/10158/?time=1010
+ // Equations taken from Kevin Grajeda's article https://www.kvin.me/posts/effortless-ui-spring-animations
+ const pds = globals.timeScale === 1 ? this.pd / K : this.pd;
+ // Mass and velocity should be set to their default values
+ this.m = 1;
+ this.v = 0;
+ // Stiffness = (2π ÷ perceptualDuration)²
+ this.s = pow((2 * PI) / pds, 2);
+ if (this.bn >= 0) {
+ // For bounce ≥ 0 (critically damped to underdamped)
+ // damping = ((1 - bounce) × 4π) ÷ perceptualDuration
+ this.d = ((1 - this.bn) * 4 * PI) / pds;
+ } else {
+ // For bounce < 0 (overdamped)
+ // damping = 4π ÷ (perceptualDuration × (1 + bounce))
+ // Note: (1 + bounce) is positive since bounce is negative
+ this.d = (4 * PI) / (pds * (1 + this.bn));
+ }
+ this.s = round$1(clamp$1(this.s, minValue, maxSpringParamValue), 3);
+ this.d = round$1(clamp$1(this.d, minValue, 300), 3); // Clamping to 300 is needed to prevent insane values in the solver
+ }
+
+ calculateBDFromSD() {
+ // Calculate perceived duration and bounce from stiffness and damping
+ // Note: We assumes m = 1 and v = 0 for these calculations
+ const pds = (2 * PI) / sqrt(this.s);
+ this.pd = pds * (globals.timeScale === 1 ? K : 1);
+ const zeta = this.d / (2 * sqrt(this.s));
+ if (zeta <= 1) {
+ // Critically damped to underdamped
+ this.bn = 1 - (this.d * pds) / (4 * PI);
+ } else {
+ // Overdamped
+ this.bn = (4 * PI) / (this.d * pds) - 1;
+ }
+ this.bn = round$1(clamp$1(this.bn, -1, 1), 3);
+ this.pd = round$1(clamp$1(this.pd, 10 * globals.timeScale, maxSpringParamValue * globals.timeScale), 3);
+ }
+
compute() {
const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
const w0 = this.w0 = clamp$1(sqrt(s / m), minValue, K);
- const zeta = this.zeta = d / (2 * sqrt(s * m));
- const wd = this.wd = zeta < 1 ? w0 * sqrt(1 - zeta * zeta) : 0;
- this.b = zeta < 1 ? (zeta * w0 + -v) / wd : -v + w0;
+ const bouncedZeta = this.zeta = d / (2 * sqrt(s * m));
+ // Calculate wd based on damping type
+ if (bouncedZeta < 1) {
+ // Underdamped
+ this.wd = w0 * sqrt(1 - bouncedZeta * bouncedZeta);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ } else if (bouncedZeta === 1) {
+ // Critically damped
+ this.wd = 0;
+ this.b = -v + w0;
+ } else {
+ // Overdamped
+ this.wd = w0 * sqrt(bouncedZeta * bouncedZeta - 1);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ }
+
let solverTime = 0;
let restSteps = 0;
let iterations = 0;
- while (restSteps < maxRestSteps && iterations < maxIterations) {
+ while (restSteps <= maxRestSteps && iterations <= maxIterations) {
if (abs(1 - this.solve(solverTime)) < restThreshold) {
restSteps++;
} else {
@@ -4703,15 +4706,26 @@
solverTime += timeStep;
iterations++;
}
- this.duration = round$1(this.solverDuration * K, 0) * globals.timeScale;
+ this.settlingDuration = round$1(this.solverDuration * K, 0) * globals.timeScale;
}
- get mass() {
- return this.m;
+ get bounce() {
+ return this.bn;
}
- set mass(v) {
- this.m = clamp$1(setValue(v, 1), 0, maxSpringParamValue);
+ set bounce(v) {
+ this.bn = clamp$1(setValue(v, 1), -1, 1);
+ this.calculateSDFromBD();
+ this.compute();
+ }
+
+ get duration() {
+ return this.pd;
+ }
+
+ set duration(v) {
+ this.pd = clamp$1(setValue(v, 1), 10 * globals.timeScale, maxSpringParamValue * globals.timeScale);
+ this.calculateSDFromBD();
this.compute();
}
@@ -4720,7 +4734,8 @@
}
set stiffness(v) {
- this.s = clamp$1(setValue(v, 100), 1, maxSpringParamValue);
+ this.s = clamp$1(setValue(v, 100), minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
this.compute();
}
@@ -4729,7 +4744,17 @@
}
set damping(v) {
- this.d = clamp$1(setValue(v, 10), .1, maxSpringParamValue);
+ this.d = clamp$1(setValue(v, 10), minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
+ this.compute();
+ }
+
+ get mass() {
+ return this.m;
+ }
+
+ set mass(v) {
+ this.m = clamp$1(setValue(v, 1), 1, maxSpringParamValue);
this.compute();
}
@@ -4747,7 +4772,18 @@
* @param {SpringParams} [parameters]
* @returns {Spring}
*/
- const createSpring = (parameters) => new Spring(parameters);
+ const spring = (parameters) => new Spring(parameters);
+
+ /**
+ * @deprecated createSpring() is deprecated use spring() instead
+ *
+ * @param {SpringParams} [parameters]
+ * @returns {Spring}
+ */
+ const createSpring = (parameters) => {
+ console.warn('createSpring() is deprecated use spring() instead');
+ return new Spring(parameters);
+ };
@@ -4928,13 +4964,13 @@
/** @type {Boolean|DraggableCursorParams} */
this.cursor = false;
/** @type {Spring} */
- this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : createSpring({
+ this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
mass: setValue(parameters.releaseMass, 1),
stiffness: setValue(parameters.releaseStiffness, 80),
damping: setValue(parameters.releaseDamping, 20),
});
/** @type {Spring} */
- this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : createSpring({
+ this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
mass: setValue(parameters.releaseMass, 1),
stiffness: setValue(parameters.releaseStiffness, 80),
damping: setValue(parameters.releaseDamping, 20),
@@ -5651,8 +5687,8 @@
this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
this.$trigger.addEventListener('touchend', preventDefault);
-
- if ((!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
+ // Don't check for a miminim distance move if already dragging
+ if (this.dragged || (!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
this.updateTicker.resume();
this.pointer[2] = this.pointer[0];
@@ -5718,8 +5754,8 @@
const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
const distanceX = round$1(cx - dx, 0);
springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / abs(distanceX) : 0 : pv;
- const { ease, duration, restDuration } = springX;
- durationX = cx === dx ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springX;
+ durationX = cx === dx ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
if (hasReleaseSpring) easeX = ease;
if (durationX > longestReleaseDuration) longestReleaseDuration = durationX;
}
@@ -5728,8 +5764,8 @@
const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
const distanceY = round$1(cy - dy, 0);
springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / abs(distanceY) : 0 : pv;
- const { ease, duration, restDuration } = springY;
- durationY = cy === dy ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springY;
+ durationY = cy === dy ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
if (hasReleaseSpring) easeY = ease;
if (durationY > longestReleaseDuration) longestReleaseDuration = durationY;
}
@@ -6582,6 +6618,8 @@
/** @type {Boolean} */
this.reverted = false;
/** @type {Boolean} */
+ this.ready = false;
+ /** @type {Boolean} */
this.completed = false;
/** @type {Boolean} */
this.began = false;
@@ -6591,8 +6629,6 @@
this.forceEnter = false;
/** @type {Boolean} */
this.hasEntered = false;
- // /** @type {Array.<Number>} */
- // this.offsets = [];
/** @type {Number} */
this.offset = 0;
/** @type {Number} */
@@ -6640,6 +6676,8 @@
// Make sure to pause the linked object in case it's added later
linked.pause();
this.linked = linked;
+ // Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
+ if (!isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
// Try to use a target of the linked object if no target parameters specified
if (!this._params.target) {
/** @type {HTMLElement} */
@@ -6679,6 +6717,8 @@
}
refresh() {
+ // This flag is used to prevent running handleScroll() outside of this.refresh() with values not yet calculated
+ this.ready = true;
this.reverted = false;
const params = this._params;
this.repeat = setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
@@ -6924,8 +6964,6 @@
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
const scrollDelta = offsetEnd - offsetStart;
- // this.offsets[0] = offsetX;
- // this.offsets[1] = offsetY;
this.offset = offset;
this.offsetStart = offsetStart;
this.offsetEnd = offsetEnd;
@@ -6944,6 +6982,7 @@
}
handleScroll() {
+ if (!this.ready) return;
const linked = this.linked;
const sync = this.sync;
const syncEase = this.syncEase;
@@ -7067,6 +7106,7 @@
this.removeDebug();
}
this.reverted = true;
+ this.ready = false;
return this;
}
@@ -7078,13 +7118,142 @@
*/
const onScroll = (parameters = {}) => new ScrollObserver(parameters);
+
+
+ /**
+ * Cubic Bezier solver adapted from https://github.com/gre/bezier-easing
+ * (c) 2014 Gaëtan Renaudeau
+ */
+
+ /**
+ * @param {Number} aT
+ * @param {Number} aA1
+ * @param {Number} aA2
+ * @return {Number}
+ */
+ const calcBezier = (aT, aA1, aA2) => (((1 - 3 * aA2 + 3 * aA1) * aT + (3 * aA2 - 6 * aA1)) * aT + (3 * aA1)) * aT;
+
+ /**
+ * @param {Number} aX
+ * @param {Number} mX1
+ * @param {Number} mX2
+ * @return {Number}
+ */
+ const binarySubdivide = (aX, mX1, mX2) => {
+ let aA = 0, aB = 1, currentX, currentT, i = 0;
+ do {
+ currentT = aA + (aB - aA) / 2;
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
+ if (currentX > 0) {
+ aB = currentT;
+ } else {
+ aA = currentT;
+ }
+ } while (abs(currentX) > .0000001 && ++i < 100);
+ return currentT;
+ };
+
+ /**
+ * @param {Number} [mX1] The x coordinate of the first point
+ * @param {Number} [mY1] The y coordinate of the first point
+ * @param {Number} [mX2] The x coordinate of the second point
+ * @param {Number} [mY2] The y coordinate of the second point
+ * @return {EasingFunction}
+ */
+
+ const cubicBezier = (mX1 = 0.5, mY1 = 0.0, mX2 = 0.5, mY2 = 1.0) => (mX1 === mY1 && mX2 === mY2) ? none :
+ t => t === 0 || t === 1 ? t :
+ calcBezier(binarySubdivide(t, mX1, mX2), mY1, mY2);
+
+
+
+ /**
+ * Steps ease implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
+ * Only covers 'end' and 'start' jumpterms
+ * @param {Number} steps
+ * @param {Boolean} [fromStart]
+ * @return {EasingFunction}
+ */
+ const steps = (steps = 10, fromStart) => {
+ const roundMethod = fromStart ? ceil : floor;
+ return t => roundMethod(clamp$1(t, 0, 1) * steps) * (1 / steps);
+ };
+
+
+
+ /**
+ * Without parameters, the linear function creates a non-eased transition.
+ * Parameters, if used, creates a piecewise linear easing by interpolating linearly between the specified points.
+ *
+ * @param {...(String|Number)} args - Points
+ * @return {EasingFunction}
+ */
+ const linear = (...args) => {
+ const argsLength = args.length;
+ if (!argsLength) return none;
+ const totalPoints = argsLength - 1;
+ const firstArg = args[0];
+ const lastArg = args[totalPoints];
+ const xPoints = [0];
+ const yPoints = [parseNumber(firstArg)];
+ for (let i = 1; i < totalPoints; i++) {
+ const arg = args[i];
+ const splitValue = isStr(arg) ?
+ /** @type {String} */(arg).trim().split(' ') :
+ [arg];
+ const value = splitValue[0];
+ const percent = splitValue[1];
+ xPoints.push(!isUnd(percent) ? parseNumber(percent) / 100 : i / totalPoints);
+ yPoints.push(parseNumber(value));
+ }
+ yPoints.push(parseNumber(lastArg));
+ xPoints.push(1);
+ return function easeLinear(t) {
+ for (let i = 1, l = xPoints.length; i < l; i++) {
+ const currentX = xPoints[i];
+ if (t <= currentX) {
+ const prevX = xPoints[i - 1];
+ const prevY = yPoints[i - 1];
+ return prevY + (yPoints[i] - prevY) * (t - prevX) / (currentX - prevX);
+ }
+ }
+ return yPoints[yPoints.length - 1];
+ }
+ };
+
+
+
+ /**
+ * Generate random steps
+ * @param {Number} [length] - The number of steps
+ * @param {Number} [randomness] - How strong the randomness is
+ * @return {EasingFunction}
+ */
+ const irregular = (length = 10, randomness = 1) => {
+ const values = [0];
+ const total = length - 1;
+ for (let i = 1; i < total; i++) {
+ const previousValue = values[i - 1];
+ const spacing = i / total;
+ const segmentEnd = (i + 1) / total;
+ const randomVariation = spacing + (segmentEnd - spacing) * Math.random();
+ // Mix the even spacing and random variation based on the randomness parameter
+ const randomValue = spacing * (1 - randomness) + randomVariation * randomness;
+ values.push(clamp$1(randomValue, previousValue, 1));
+ }
+ values.push(1);
+ return linear(...values);
+ };
+
var index$3 = /*#__PURE__*/Object.freeze({
__proto__: null,
+ Spring: Spring,
+ createSpring: createSpring,
cubicBezier: cubicBezier,
eases: eases,
irregular: irregular,
linear: linear,
- none: none,
+ spring: spring,
steps: steps
});
@@ -8140,21 +8309,11 @@
*/
const easingToLinear = (fn, samples = 100) => {
const points = [];
- for (let i = 0; i <= samples; i++) points.push(fn(i / samples));
+ for (let i = 0; i <= samples; i++) points.push(round$1(fn(i / samples), 4));
return `linear(${points.join(', ')})`;
};
- const WAAPIEasesLookups = {
- in: 'ease-in',
- out: 'ease-out',
- inOut: 'ease-in-out',
- };
-
- const WAAPIeases = /*#__PURE__*/(() => {
- const list = {};
- for (let type in easeTypes) list[type] = (/** @type {String|Number} */p) => easeTypes[type](easeInPower(p));
- return /** @type {Record<String, EasingFunction>} */(list);
- })();
+ const WAAPIEasesLookups = {};
/**
* @param {EasingParam} ease
@@ -8175,9 +8334,10 @@
} else if (stringStartsWith(ease, 'cubicB')) {
parsedEase = toLowerCase(ease);
} else {
- const parsed = parseEaseString(ease, WAAPIeases, WAAPIEasesLookups);
+ const parsed = parseEaseString(ease);
if (isFnc(parsed)) parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
}
+ // Only cache string based easing name, otherwise function arguments get lost
WAAPIEasesLookups[ease] = parsedEase;
} else if (isFnc(ease)) {
const easing = easingToLinear(ease);
@@ -8218,7 +8378,8 @@
* @return {String}
*/
const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
- let v = getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
+ // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
+ let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
if (!isNum(v)) return v;
if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
@@ -8298,7 +8459,7 @@
/** @type {PlaybackDirection} */
const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
/** @type {FillMode} */
- const fill = 'forwards';
+ const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
/** @type {String} */
const easing = parseWAAPIEasing(ease);
const timeScale = (globals.timeScale === 1 ? 1 : K);
@@ -8310,7 +8471,7 @@
/** @type {globalThis.Animation}] */
this.controlAnimation = null;
/** @type {Callback<this>} */
- this.onComplete = params.onComplete || noop;
+ this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.defaults.onComplete));
/** @type {Number} */
this.duration = 0;
/** @type {Boolean} */
@@ -8321,6 +8482,8 @@
this.paused = !autoplay || scroll !== false;
/** @type {Boolean} */
this.reversed = reversed;
+ /** @type {Boolean} */
+ this.persist = setValue(params.persist, globals.defaults.persist);
/** @type {Boolean|ScrollObserver} */
this.autoplay = autoplay;
/** @type {Number} */
@@ -8329,17 +8492,18 @@
this._resolve = noop; // Used by .then()
/** @type {Number} */
this._completed = 0;
- /** @type {Array<Object>}] */
- this._inlineStyles = parsedTargets.map($el => $el.getAttribute('style'));
+ /** @type {Array.<Object>} */
+ this._inlineStyles = [];
parsedTargets.forEach(($el, i) => {
const cachedTransforms = $el[transformsSymbol];
-
const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
+ const elStyle = $el.style;
+ const inlineStyles = this._inlineStyles[i] = {};
/** @type {Number} */
- const duration = (spring ? /** @type {Spring} */(spring).duration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
+ const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -8353,6 +8517,12 @@
const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
const propertyValue = params[name];
const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
+
+ const styleName = individualTransformProperty ? 'transform' : name;
+ if (!inlineStyles[styleName]) {
+ inlineStyles[styleName] = elStyle[styleName];
+ }
+
let parsedPropertyValue;
if (isObj(propertyValue)) {
const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
@@ -8361,7 +8531,7 @@
const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
/** @type {Number} */
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).duration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
+ tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -8378,10 +8548,10 @@
addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
if (!isUnd(from)) {
if (!individualTransformProperty) {
- $el.style[name] = keyframes[name][0];
+ elStyle[name] = keyframes[name][0];
} else {
const key = `--${individualTransformProperty}`;
- $el.style.setProperty(key, keyframes[key][0]);
+ elStyle.setProperty(key, keyframes[key][0]);
}
}
} else {
@@ -8402,7 +8572,7 @@
for (let t in cachedTransforms) {
transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
}
- $el.style.transform = transforms;
+ elStyle.transform = transforms;
}
});
@@ -8447,7 +8617,8 @@
// Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
// The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
// https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
- if (t >= this.duration) anim.play();
+ // This is not needed for persisting animations since they never finish.
+ if (!this.persist && t >= this.duration) anim.play();
anim.currentTime = t;
});
}
@@ -8517,13 +8688,30 @@
}
cancel() {
- this.forEach('cancel');
- return this.pause();
+ this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
+ return this.commitStyles().forEach('cancel');
}
revert() {
- this.cancel();
- this.targets.forEach(($el, i) => $el.setAttribute('style', this._inlineStyles[i]) );
+ // NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
+ // This means if you have multiple animations animating different transforms on the same target,
+ // reverting one of them will also override the transform property of the other animations.
+ // A better approach would be to store the original custom property values is they exist instead of the entire transform value,
+ // and update the CSS variables with the orignal value
+ this.cancel().targets.forEach(($el, i) => {
+ const targetStyle = $el.style;
+ const targetInlineStyles = this._inlineStyles[i];
+ for (let name in targetInlineStyles) {
+ const originalInlinedValue = targetInlineStyles[name];
+ if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ targetStyle.removeProperty(toLowerCase(name));
+ } else {
+ targetStyle[name] = originalInlinedValue;
+ }
+ }
+ // Remove style attribute if empty
+ if ($el.getAttribute('style') === emptyString) $el.removeAttribute('style');
+ });
return this;
}
@@ -8593,7 +8781,6 @@
exports.linear = linear;
exports.mapRange = mapRange;
exports.morphTo = morphTo;
- exports.none = none;
exports.onScroll = onScroll;
exports.padEnd = padEnd;
exports.padStart = padStart;
@@ -8609,6 +8796,7 @@
exports.snap = snap;
exports.split = split;
exports.splitText = splitText;
+ exports.spring = spring;
exports.stagger = stagger;
exports.steps = steps;
exports.svg = index$1;
diff --git a/dist/bundles/anime.umd.min.js b/dist/bundles/anime.umd.min.js
index 654bea5b..a5d23395 100644
--- a/dist/bundles/anime.umd.min.js
+++ b/dist/bundles/anime.umd.min.js
@@ -4,4 +4,4 @@
* @license MIT
* @copyright 2025 - Julian Garnier
*/
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).anime={})}(this,function(t){"use strict";const e="undefined"!=typeof window,s=e?window:null,i=e?document:null,r={replace:0,none:1,blend:2},n=Symbol(),o=Symbol(),a=Symbol(),h=Symbol(),l=Symbol(),c=Symbol(),d=1e-11,u=1e12,p=1e3,m="",f=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),g=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],_=g.reduce((t,e)=>({...t,[e]:e+"("}),{}),y=()=>{},v=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,b=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,T=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,S=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,w=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,x=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,k=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,$=/([a-z])([A-Z])/g,E=/(\w+)(\([^)]+\)+)/g,C=/(\*=|\+=|-=)/,B={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:120,loop:0,reversed:!1,alternate:!1,autoplay:!0,duration:p,delay:0,loopDelay:0,ease:"out(2)",composition:r.replace,modifier:t=>t,onBegin:y,onBeforeUpdate:y,onUpdate:y,onLoop:y,onPause:y,onComplete:y,onRender:y},D={current:null,root:i},L={defaults:B,precision:4,timeScale:1,tickThreshold:200},A={version:"4.2.0",engine:null};e&&(s.AnimeJS||(s.AnimeJS=[]),s.AnimeJS.push(A));const N=t=>t.replace($,"$1-$2").toLowerCase(),O=(t,e)=>0===t.indexOf(e),F=Date.now,P=Array.isArray,R=t=>t&&t.constructor===Object,M=t=>"number"==typeof t&&!isNaN(t),z=t=>"string"==typeof t,I=t=>"function"==typeof t,Y=t=>void 0===t,X=t=>Y(t)||null===t,W=t=>e&&t instanceof SVGElement,V=t=>v.test(t),H=t=>O(t,"rgb"),U=t=>O(t,"hsl"),q=t=>!L.defaults.hasOwnProperty(t),j=["opacity","rotate","overflow","color"],Q=t=>z(t)?parseFloat(t):t,G=Math.pow,Z=Math.sqrt,J=Math.sin,K=Math.cos,tt=Math.abs,et=Math.exp,st=Math.ceil,it=Math.floor,rt=Math.asin,nt=Math.max,ot=Math.atan2,at=Math.PI,ht=Math.round,lt=(t,e,s)=>t<e?e:t>s?s:t,ct={},dt=(t,e)=>{if(e<0)return t;if(!e)return ht(t);let s=ct[e];return s||(s=ct[e]=10**e),ht(t*s)/s},ut=(t,e)=>P(e)?e.reduce((e,s)=>tt(s-t)<tt(e-t)?s:e):e?ht(t/e)*e:t,pt=(t,e,s)=>t+(e-t)*s,mt=t=>t===1/0?u:t===-1/0?-u:t,ft=t=>t<=d?d:mt(dt(t,11)),gt=t=>P(t)?[...t]:t,_t=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=Y(r)?e[i]:r}return s},yt=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},vt=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},bt=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},Tt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),St=(t,e)=>Y(t)?e:t,wt=(t,e,s,i,r)=>{if(I(t)){const n=()=>{const r=t(e,s,i);return isNaN(+r)?r||0:+r};return r&&(r.func=n),n()}return t},xt=(t,e)=>t[o]?t[a]&&((t,e)=>{if(j.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}})(t,e)?1:g.includes(e)||f.get(e)?3:O(e,"--")?4:e in t.style?2:e in t?0:1:0,kt=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[c]||t).getPropertyValue(e);return"auto"===r?"0":r},$t=(t,e,s,i)=>{const r=Y(s)?xt(t,e):s;return 0===r?t[e]||0:1===r?t.getAttribute(e):3===r?((t,e,s)=>{const i=t.style.transform;let r;if(i){const n=t[h];let o;for(;o=E.exec(i);){const t=o[1],i=o[2].slice(1,-1);n[t]=i,t===e&&(r=i,s&&(s[e]=i))}}return i&&!Y(r)?r:O(e,"scale")?"1":O(e,"rotate")||O(e,"skew")?"0deg":"0px"})(t,e,i):4===r?kt(t,e,i).trimStart():kt(t,e,i)},Et=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,Ct=(t,e)=>{if(e.t=0,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const n=!s.includes(" ")&&k.exec(s);if(n)return e.t=1,e.n=+n[1],e.u=n[2],e;if(e.o)return e.n=+s,e;if(V(r=s)||H(r)||U(r))return e.t=2,e.d=H(i=s)?(t=>{const e=b.exec(t)||T.exec(t),s=Y(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]})(i):V(i)?(t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]})(i):U(i)?(t=>{const e=S.exec(t)||w.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=Y(e[4])?1:+e[4];let o,a,h;if(0===i)o=a=h=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=dt(255*Tt(e,t,s+1/3),0),a=dt(255*Tt(e,t,s),0),h=dt(255*Tt(e,t,s-1/3),0)}return[o,a,h,n]})(i):[0,0,0,1],e;{const t=s.match(x);return e.t=3,e.d=t?t.map(Number):[],e.s=s.split(x)||[],e}}var i,r;return e.n=s,e},Bt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=gt(t._toNumbers),e.s=gt(t._strings),e),Dt={t:0,n:0,u:null,o:null,d:null,s:null},Lt=(t,e,s,i,n)=>{const o=t.parent,a=t.duration,l=t.completed,c=t.iterationDuration,u=t.iterationCount,p=t._currentIteration,f=t._loopDelay,g=t._reversed,y=t._alternate,v=t._hasChildren,b=t._delay,T=t._currentTime,S=b+c,w=e-b,x=lt(T,-b,a),k=lt(w,-b,a),$=w-T,E=k>0,C=k>=a,B=a<=d,D=2===n;let A=0,N=w,O=0;if(u>1){const e=~~(k/(c+(C?0:f)));t._currentIteration=lt(e,0,u),C&&t._currentIteration--,A=t._currentIteration%2,N=k%(c+f)||0}const F=g^(y&&A),P=t._ease;let R=C?F?0:a:F?c-N:N;P&&(R=c*P(R/c)||0);const M=(o?o.backwards:w<T)?!F:!!F;if(t._currentTime=w,t._iterationTime=R,t.backwards=M,E&&!t.began?(t.began=!0,s||o&&(M||!o.began)||t.onBegin(t)):w<=0&&(t.began=!1),s||v||!E||t._currentIteration===p||t.onLoop(t),D||1===n&&(e>=b&&e<=S||e<=b&&x>b||e>=S&&x!==a)||R>=S&&x!==a||R<=b&&x>0||e<=x&&x===a&&l||C&&!l&&B){if(E&&(t.computeDeltaTime(x),s||t.onBeforeUpdate(t)),!v){const e=D||(M?-1*$:$)>=L.tickThreshold,n=t._offset+(o?o._offset:0)+b+R;let a,l,c,d,u=t._head,p=0;for(;u;){const t=u._composition,s=u._currentTime,o=u._changeDuration,f=u._absoluteStartTime+u._changeDuration,g=u._nextRep,y=u._prevRep,v=t!==r.none;if((e||(s!==o||n<=f+(g?g._delay:0))&&(0!==s||n>=u._absoluteStartTime))&&(!v||!u._isOverridden&&(!u._isOverlapped||n<=f)&&(!g||g._isOverridden||n<=g._absoluteStartTime)&&(!y||y._isOverridden||n>=y._absoluteStartTime+y._changeDuration+u._delay))){const e=u._currentTime=lt(R-u._startTime,0,o),s=u._ease(e/u._updateDuration),n=u._modifier,m=u._valueType,f=u._tweenType,g=0===f,_=0===m,y=_&&g||0===s||1===s?-1:L.precision;let b,T;if(_)b=T=n(dt(pt(u._fromNumber,u._toNumber,s),y));else if(1===m)T=n(dt(pt(u._fromNumber,u._toNumber,s),y)),b=`${T}${u._unit}`;else if(2===m){const t=u._fromNumbers,e=u._toNumbers,i=dt(lt(n(pt(t[0],e[0],s)),0,255),0),r=dt(lt(n(pt(t[1],e[1],s)),0,255),0),o=dt(lt(n(pt(t[2],e[2],s)),0,255),0),a=lt(n(dt(pt(t[3],e[3],s),y)),0,1);if(b=`rgba(${i},${r},${o},${a})`,v){const t=u._numbers;t[0]=i,t[1]=r,t[2]=o,t[3]=a}}else if(3===m){b=u._strings[0];for(let t=0,e=u._toNumbers.length;t<e;t++){const e=n(dt(pt(u._fromNumbers[t],u._toNumbers[t],s),y)),i=u._strings[t+1];b+=`${i?e+i:e}`,v&&(u._numbers[t]=e)}}if(v&&(u._number=T),i||t===r.blend)u._value=b;else{const t=u.property;a=u.target,g?a[t]=b:1===f?a.setAttribute(t,b):(l=a.style,3===f?(a!==c&&(c=a,d=a[h]),d[t]=b,p=1):2===f?l[t]=b:4===f&&l.setProperty(t,b)),E&&(O=1)}}if(p&&u._renderTransforms){let t=m;for(let e in d)t+=`${_[e]}${d[e]}) `;l.transform=t,p=0}u=u._next}!s&&O&&t.onRender(t)}!s&&E&&t.onUpdate(t)}return o&&B?!s&&(o.began&&!M&&w>=a&&!l||M&&w<=d&&l)&&(t.onComplete(t),t.completed=!M):E&&C?u===1/0?t._startTime+=t.duration:t._currentIteration>=u-1&&(t.paused=!0,l||v||(t.completed=!0,s||o&&(M||!o.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,O},At=(t,e,s,i,r)=>{const n=t._currentIteration;if(Lt(t,e,s,i,r),t._hasChildren){const o=t,a=o.backwards,h=i?e:o._iterationTime,l=F();let c=0,u=!0;if(!i&&o._currentIteration!==n){const t=o.iterationDuration;yt(o,e=>{if(a){const i=e.duration,r=e._offset+e._delay;s||!(i<=d)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Lt(e,t,s,1,2),e.began=!1,e.completed=!1}),s||o.onLoop(o)}yt(o,t=>{const e=dt((h-t._offset)*t._speed,12),n=t._fps<o._fps?t.requestTick(l):r;c+=Lt(t,e,s,i,n),!t.completed&&u&&(u=!1)},a),!s&&c&&o.onRender(o),(u||a)&&o._currentTime>=o.duration&&(o.paused=!0,o.completed||(o.completed=!0,s||(o.onComplete(o),o._resolve(o))))}},Nt={},Ot=(t,e,s)=>{if(3===s)return f.get(t)||t;if(2===s||1===s&&W(e)&&t in e.style){const e=Nt[t];if(e)return e;{const e=t?N(t):t;return Nt[t]=e,e}}return t},Ft=t=>{if(t._hasChildren)yt(t,Ft,!0);else{const e=t;e.pause(),yt(e,t=>{const s=t.property,i=t.target;if(i[o]){const r=i.style,n=e._inlineStyles[s];if(3===t._tweenType){const e=i[h];if(Y(n)||n===m?delete e[s]:e[s]=n,t._renderTransforms)if(Object.keys(e).length){let t=m;for(let s in e)t+=_[s]+e[s]+") ";r.transform=t}else r.removeProperty("transform")}else Y(n)||n===m?r.removeProperty(s):r[s]=n;e._tail===t&&e.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===m&&t.removeAttribute("style")})}})}return t};class Pt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._elapsedTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=dt(p/120,0),this._fps=120,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<d?d:s,r=dt(p/i,0);this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<d?d:e}requestTick(t){const e=this._scheduledTime,s=this._elapsedTime;if(this._elapsedTime+=t-s,s<e)return 0;const i=this._frameDuration,r=s-e;return this._scheduledTime+=r<i?i:r,1}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Rt={animation:null,update:y},Mt=(()=>e?requestAnimationFrame:setImmediate)(),zt=(()=>e?cancelAnimationFrame:clearImmediate)();class It extends Pt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=B,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=F();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(vt(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):At(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):1),i=r}Rt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(F()),this.reqId=Mt(Xt)),this}pause(){if(this.reqId)return this.paused=!0,Wt()}resume(){if(this.paused)return this.paused=!1,yt(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===L.timeScale?1:p)}set speed(t){this._speed=t*L.timeScale,yt(this,t=>t.speed=t._speed)}get timeUnit(){return 1===L.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(L.timeScale!==s){L.timeScale=s,L.tickThreshold=200*s;const t=e?.001:p;this.defaults.duration*=t,this._speed*=t}}get precision(){return L.precision}set precision(t){L.precision=t}}const Yt=(()=>{const t=new It(F());return e&&(A.engine=t,i.addEventListener("visibilitychange",()=>{t.pauseOnDocumentHidden&&(i.hidden?t.pause():t.resume())})),t})(),Xt=()=>{Yt._head?(Yt.reqId=Mt(Xt),Yt.update()):Yt.reqId=0},Wt=()=>(zt(Yt.reqId),Yt.reqId=0,Yt),Vt={_rep:new WeakMap,_add:new Map},Ht=(t,e,s="_rep")=>{const i=Vt[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},Ut=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,qt=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=d,t._currentTime=d},jt=(t,e)=>{const s=t._composition;if(s===r.replace){const s=t._absoluteStartTime;bt(e,t,Ut,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){qt(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)qt(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=dt(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<d&&qt(i)}let o=!0;if(yt(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;yt(t,t=>{t!==e&&yt(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===r.blend){const e=Ht(t.target,t.property,"_add"),s=(t=>{let e=Rt.animation;return e||(e={duration:d,computeDeltaTime:y,_offset:0,_delay:0,_head:null,_tail:null},Rt.animation=e,Rt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=3===t||2===t?gt(i._fromNumbers):null;let r=i._fromNumber,n=s._tail;for(;n&&n!==i;){if(e)for(let t=0,s=n._numbers.length;t<s;t++)e[t]+=n._numbers[t];else r+=n._number;n=n._prevAdd}i._toNumber=r,i._toNumbers=e}}}),Lt(e,1,1,0,2)}),e})(Vt._add);let i=e._head;i||(i={...t},i._composition=r.replace,i._updateDuration=d,i._startTime=0,i._numbers=gt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,bt(e,i),bt(s,i));const n=t._toNumber;if(t._fromNumber=i._fromNumber-n,t._toNumber=0,t._numbers=gt(t._fromNumbers),t._number=0,i._fromNumber=n,t._toNumbers){const e=gt(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}bt(e,t,null,"_prevAdd","_nextAdd")}return t},Qt=t=>{const e=t._composition;if(e!==r.none){const s=t.target,i=t.property,n=Vt._rep.get(s)[i];if(vt(n,t,"_prevRep","_nextRep"),e===r.blend){const e=Vt._add,r=e.get(s);if(!r)return;const n=r[i],o=Rt.animation;vt(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){vt(n,a,"_prevAdd","_nextAdd"),vt(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},Gt=(t,e,s)=>{let i=!1;return yt(e,r=>{const n=r.target;if(t.includes(n)){const t=r.property,o=r._tweenType,a=Ot(s,n,o);(!a||a&&a===t)&&(r.parent._tail===r&&3===r._tweenType&&r._prev&&3===r._prev._tweenType&&(r._prev._renderTransforms=1),vt(e,r),Qt(r),i=!0)}},!0),i},Zt=(t,e,s)=>{const i=e||Yt;let r;if(i._hasChildren){let e=0;yt(i,n=>{if(!n._hasChildren)if(r=Gt(t,n,s),r&&!n._head)n.cancel(),vt(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?Zt(t,n,s):n._hasChildren=!1},!0),Y(i.iterationDuration)||(i.iterationDuration=e)}else r=Gt(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},Jt=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),Kt=t=>t._cancelled?(t._hasChildren?yt(t,Kt):yt(t,t=>{t._composition!==r.none&&jt(t,Ht(t.target,t.property))}),t._cancelled=0,t):t;let te=0;class ee extends Pt{constructor(t={},e=null,s=0){super(0);const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:h,loopDelay:l,autoplay:c,frameRate:u,playbackRate:p,onComplete:m,onLoop:f,onPause:g,onBegin:_,onBeforeUpdate:v,onUpdate:b}=t;D.current&&D.current.register(this);const T=e?0:Yt._elapsedTime,S=e?e.defaults:L.defaults,w=I(r)||Y(r)?S.delay:+r,x=I(n)||Y(n)?1/0:+n,k=St(h,S.loop),$=St(l,S.loopDelay),E=!0===k||k===1/0||k<0?1/0:k+1;let C=0;e?C=s:(Yt.reqId||Yt.requestTick(F()),C=(Yt._elapsedTime-Yt._startTime)*L.timeScale),this.id=Y(i)?++te:i,this.parent=e,this.duration=mt((x+$)*E-$)||d,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=_||S.onBegin,this.onBeforeUpdate=v||S.onBeforeUpdate,this.onUpdate=b||S.onUpdate,this.onLoop=f||S.onLoop,this.onPause=g||S.onPause,this.onComplete=m||S.onComplete,this.iterationDuration=x,this.iterationCount=E,this._autoplay=!e&&St(c,S.autoplay),this._offset=C,this._delay=w,this._loopDelay=$,this._iterationTime=0,this._currentIteration=0,this._resolve=y,this._running=!1,this._reversed=+St(o,S.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=St(a,S.alternate),this._prev=null,this._next=null,this._elapsedTime=T,this._startTime=T,this._lastTime=T,this._fps=St(u,S.frameRate),this._speed=St(p,S.playbackRate)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(1).play()}get currentTime(){return lt(dt(this._currentTime,L.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return dt(this._iterationTime,L.precision)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return lt(dt(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return lt(dt(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*lt(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=0){return Kt(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,At(this,0,1,t,2),Jt(this),this._hasChildren&&yt(this,Jt),this}init(t=0){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&At(this,this.duration,1,t,2),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!Y(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*Yt._speed);return this._startTime=F()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=d&&!this._hasChildren?At(this,d,0,0,2):(this._running||(bt(Yt,this),Yt._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,Yt.wake()),this):this}restart(){return this.reset(0).resume()}seek(t,e=0,s=0){Kt(this),this.completed=!1;const i=this.paused;return this.paused=!0,At(this,t+this._delay,~~e,~~s,1),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?it(u/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?yt(this,t=>t.cancel(),!0):yt(this,Qt),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=ft(t);if(e===s)return this;const i=t/e,r=t<=d;return this.duration=r?d:s,this.iterationDuration=r?d:ft(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){At(this,0,1,0,1);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(){return this.seek(this.duration).cancel()}then(t=y){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=y};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}function se(t){const e=z(t)?D.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function ie(t){if(X(t))return[];if(!e)return P(t)&&t.flat(1/0)||[t];if(P(t)){const e=t.flat(1/0),s=[];for(let t=0,i=e.length;t<i;t++){const i=e[t];if(!X(i)){const t=se(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!X(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=se(t);return s?Array.from(s):[t]}function re(t){const e=ie(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[n]){s[n]=!0;const t=W(s);(s.nodeType||t)&&(s[o]=!0,s[a]=t,s[h]={})}}return e}const ne={deg:1,rad:180/at,turn:360},oe={},ae=(t,e,s,r=!1)=>{const n=e.u,o=e.n;if(1===e.t&&n===s)return e;const a=o+n+s,h=oe[a];if(Y(h)||r){let r;if(n in ne)r=o*ne[n]/ne[s];else{const e=100,a=t.cloneNode(),h=t.parentNode,l=h&&h!==i?h:i.body;l.appendChild(a);const c=a.style;c.width=e+n;const d=a.offsetWidth||e;c.width=e+s;const u=d/(a.offsetWidth||e);l.removeChild(a),r=u*o}e.n=r,oe[a]=r}else e.n=h;return e.t,e.u=s,e},he=t=>t,le=(t=1.68)=>e=>G(e,+t),ce={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},de=(t,e,s)=>{if(s[t])return s[t];if(t.indexOf("(")<=-1){const i=ce[t]||t.includes("Back")||t.includes("Elastic")?e[t]():e[t];return i?s[t]=i:he}{const i=t.slice(0,-1).split("("),r=e[i[0]];return r?s[t]=r(...i[1].split(",")):he}},ue=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,pe=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?he:r=>0===r||1===r?r:ue(((t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=ue(r,e,s)-t,i>0?o=r:n=r}while(tt(i)>1e-7&&++a<100);return r})(r,t,s),e,i),me=(t=10,e)=>{const s=e?st:it;return e=>s(lt(e,0,1)*t)*(1/t)},fe=(...t)=>{const e=t.length;if(!e)return he;const s=e-1,i=t[0],r=t[s],n=[0],o=[Q(i)];for(let e=1;e<s;e++){const i=t[e],r=z(i)?i.trim().split(" "):[i],a=r[0],h=r[1];n.push(Y(h)?e/s:Q(h)/100),o.push(Q(a))}return o.push(Q(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},ge=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(lt(o,r,1))}return s.push(1),fe(...s)},_e=at/2,ye=2*at,ve={[m]:le,Quad:le(2),Cubic:le(3),Quart:le(4),Quint:le(5),Sine:t=>1-K(t*_e),Circ:t=>1-Z(1-t*t),Expo:t=>t?G(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=G(2,--s))-1)/11;);return 1/G(4,3-s)-7.5625*G((3*e-2)/22-t,2)},Back:(t=1.70158)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=lt(+t,1,10),i=lt(+e,d,2),r=i/ye*rt(1/s),n=ye/i;return t=>0===t||1===t?t:-s*G(2,-10*(1-t))*J((1-t-r)*n)}},be=(()=>{const t={linear:fe,irregular:ge,steps:me,cubicBezier:pe};for(let e in ce)for(let s in ve){const i=ve[s],r=ce[e];t[e+s]=s===m||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),Te={linear:he},Se=t=>I(t)?t:z(t)?de(t,be,Te):he,we={t:0,n:0,u:null,o:null,d:null,s:null},xe={t:0,n:0,u:null,o:null,d:null,s:null},ke={func:null},$e=[null],Ee=[null,null],Ce={to:null};let Be,De,Le=0;class Ae extends ee{constructor(t,e,s,i,n=!1,o=0,a=0){super(e,s,i);const h=re(t),l=h.length,c=e.keyframes,u=c?_t(((t,e)=>{const s={};if(P(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(q);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];q(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=St(e.duration,L.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(q(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,h=n[a-1];const l={to:r[t]};let c=0;for(let t=0;t<a;t++)c+=n[t].duration;1===a&&(l.from=h.to),r.ease&&(l.ease=r.ease),l.duration=o-(a?c:0),n.push(l)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s})(c,e),e):e,{delay:m,duration:f,ease:g,playbackEase:_,modifier:y,composition:v,onRender:b}=u,T=s?s.defaults:L.defaults,S=St(_,T.playbackEase),w=S?Se(S):null,x=!Y(g)&&!Y(g.ease),k=x?g.ease:St(g,w?"linear":T.ease),$=x?g.duration:St(f,T.duration),E=St(m,T.delay),C=y||T.modifier,B=Y(v)&&l>=p?r.none:Y(v)?T.composition:v,D={},A=this._offset+(s?s._offset:0);let N=NaN,O=NaN,F=0,z=0;for(let t=0;t<l;t++){const e=h[t],i=o||t,c=a||l;let p=NaN,m=NaN;for(let t in u)if(q(t)){const o=xt(e,t),a=Ot(t,e,o);let h=u[t];const l=P(h);if(n&&!l&&(Ee[0]=h,Ee[1]=h,h=Ee),l){const t=h.length,e=!R(h[0]);2===t&&e?(Ce.to=h,$e[0]=Ce,Be=$e):t>2&&e?(Be=[],h.forEach((t,e)=>{e?1===e?(Ee[1]=t,Be.push(Ee)):Be.push(t):Ee[0]=t})):Be=h}else $e[0]=h,Be=$e;let f=null,g=null,_=NaN,y=0,v=0;for(let t=Be.length;v<t;v++){const n=Be[v];R(n)?De=n:(Ce.to=n,De=Ce),ke.func=null;const h=wt(De.to,e,i,c,ke);let l;R(h)&&!Y(h.to)?(De=h,l=h.to):l=h;const u=wt(De.from,e,i,c),p=De.ease,m=!Y(p)&&!Y(p.ease),b=m?p.ease:p||k,T=m?p.duration:wt(St(De.duration,t>1?wt($,e,i,c)/t:$),e,i,c),S=wt(St(De.delay,v?0:E),e,i,c),w=wt(St(De.composition,B),e,i,c),x=M(w)?w:r[w],L=De.modifier||C,N=!Y(u),O=!Y(l),I=P(l),X=I||N&&O,W=g?y+S:S,V=dt(A+W,12);z||!N&&!I||(z=1);let H=g;if(x!==r.none){f||(f=Ht(e,a));let t=f._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=V;)if(H=t,t=t._nextRep,t&&t._absoluteStartTime>=V)for(;t;)qt(t),t=t._nextRep}if(X?(Ct(I?wt(l[0],e,i,c):u,we),Ct(I?wt(l[1],e,i,c,ke):l,xe),0===we.t&&(H?1===H._valueType&&(we.t=1,we.u=H._unit):(Ct($t(e,a,o,D),Dt),1===Dt.t&&(we.t=1,we.u=Dt.u)))):(O?Ct(l,xe):g?Bt(g,xe):Ct(s&&H&&H.parent.parent===s?H._value:$t(e,a,o,D),xe),N?Ct(u,we):g?Bt(g,we):Ct(s&&H&&H.parent.parent===s?H._value:$t(e,a,o,D),we)),we.o&&(we.n=Et(H?H._toNumber:Ct($t(e,a,o,D),Dt).n,we.n,we.o)),xe.o&&(xe.n=Et(we.n,xe.n,xe.o)),we.t!==xe.t)if(3===we.t||3===xe.t){const t=3===we.t?we:xe,e=3===we.t?xe:we;e.t=3,e.s=gt(t.s),e.d=t.d.map(()=>e.n)}else if(1===we.t||1===xe.t){const t=1===we.t?we:xe,e=1===we.t?xe:we;e.t=1,e.u=t.u}else if(2===we.t||2===xe.t){const t=2===we.t?we:xe,e=2===we.t?xe:we;e.t=2,e.s=t.s,e.d=[0,0,0,1]}if(we.u!==xe.u){let t=xe.u?we:xe;t=ae(e,t,xe.u?xe.u:we.u,!1)}if(xe.d&&we.d&&xe.d.length!==we.d.length){const t=we.d.length>xe.d.length?we:xe,e=t===we?xe:we;e.d=t.d.map((t,s)=>Y(e.d[s])?0:e.d[s]),e.s=gt(t.s)}const U=dt(+T||d,12),q={parent:this,id:Le++,property:a,target:e,_value:null,_func:ke.func,_ease:Se(b),_fromNumbers:gt(we.d),_toNumbers:gt(xe.d),_strings:gt(xe.s),_fromNumber:we.n,_toNumber:xe.n,_numbers:gt(we.d),_number:we.n,_unit:xe.u,_modifier:L,_currentTime:0,_startTime:W,_delay:+S,_updateDuration:U,_changeDuration:U,_absoluteStartTime:V,_tweenType:o,_valueType:xe.t,_composition:x,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};x!==r.none&&jt(q,f),isNaN(_)&&(_=q._startTime),y=dt(W+U,12),g=q,F++,bt(this,q)}(isNaN(O)||_<O)&&(O=_),(isNaN(N)||y>N)&&(N=y),3===o&&(p=F-v,m=F)}if(!isNaN(p)){let t=0;yt(this,e=>{t>=p&&t<m&&(e._renderTransforms=1,e._composition===r.blend&&yt(Rt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}l||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),O?(yt(this,t=>{t._startTime-t._delay||(t._delay-=O),t._startTime-=O}),N-=O):O=0,N||(N=d,this.iterationCount=0),this.targets=h,this.duration=N===d?d:mt((N+this._loopDelay)*this.iterationCount-this._loopDelay)||d,this.onRender=b||T.onRender,this._ease=w,this._delay=O,this.iterationDuration=N,this._inlineStyles=D,!this._autoplay&&z&&this.onRender(this)}stretch(t){const e=this.duration;if(e===ft(t))return this;const s=t/e;return yt(this,t=>{t._updateDuration=ft(t._updateDuration*s),t._changeDuration=ft(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return yt(this,t=>{const e=t._func;if(e){const s=$t(t.target,t.property,t._tweenType);Ct(s,Dt),Ct(e(),xe),t._fromNumbers=gt(Dt.d),t._fromNumber=Dt.n,t._toNumbers=gt(xe.d),t._strings=gt(xe.s),t._toNumber=xe.o?Et(Dt.n,xe.n,xe.o):xe.n}}),this}revert(){return super.revert(),Ft(this)}then(t){return super.then(t)}}const Ne={_head:null,_tail:null},Oe=(t,e,s)=>{let i=Ne._head;for(;i;){const r=i._next,n=i.$el===t,o=!e||i.property===e,a=!s||i.parent===s;if(n&&o&&a){const t=i.animation;try{t.commitStyles()}catch{}t.cancel(),vt(Ne,i);const e=i.parent;e&&(e._completed++,e.animations.length===e._completed&&(e.completed=!0,e.muteCallbacks||(e.paused=!0,e.onComplete(e),e._resolve(e))))}i=r}},Fe=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Oe(e,s),bt(Ne,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>{Oe(e,s,t)};return n.onremove=a,n.onfinish=a,n};function Pe(t,e,s){const i=re(t);if(!i.length)return;const[r]=i,n=xt(r,e),o=Ot(e,r,n);let a=$t(r,o);if(Y(s))return a;if(Ct(a,Dt),0===Dt.t||1===Dt.t){if(!1===s)return Dt.n;{const t=ae(r,Dt,s,!1);return`${dt(t.n,L.precision)}${t.u}`}}}const Re=(t,e)=>{if(!Y(e))return e.duration=d,e.composition=St(e.composition,r.none),new Ae(t,e,null,0,!0).resume()},Me=(t,e,s)=>{const i=ie(t);for(let t=0,r=i.length;t<r;t++)Oe(i[t],s,e&&e.controlAnimation&&e);return Zt(i,e,s),i},ze=(t,e)=>{let s=t.iterationDuration;if(s===d&&(s=0),Y(e))return s;if(M(+e))return+e;const i=e,r=t?t.labels:null,n=!X(r),o=((t,e)=>{if(O(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}})(t,i),a=!Y(o),h=C.exec(i);if(h){const t=h[0],e=i.split(t),l=n&&e[0]?r[e[0]]:s,c=a?o:n?l:s,d=+e[1];return Et(c,d,t[0])}return a?o:n?Y(r[i])?s:r[i]:s};function Ie(t,e,s,i,r,n){const o=M(t.duration)&&t.duration<=d?s-d:s;At(e,o,1,1,1);const a=i?new Ae(i,t,e,o,!1,r,n):new ee(t,e,o);return a.init(1),bt(e,a),yt(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=function(t){return mt((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||d}(e),e}class Ye extends ee{constructor(t={}){super(t,null,0),this.duration=0,this.labels={};const e=t.defaults,s=L.defaults;this.defaults=e?_t(e,s):s,this.onRender=t.onRender||s.onRender;const i=St(t.playbackEase,s.playbackEase);this._ease=i?Se(i):null,this.iterationDuration=0}add(t,e,s){const i=R(e),r=R(t);if(i||r){if(this._hasChildren=!0,i){const i=e;if(I(s)){const e=s,r=ie(t),n=this.duration,o=this.iterationDuration,a=i.id;let h=0;const l=r.length;r.forEach(t=>{const s={...i};this.duration=n,this.iterationDuration=o,Y(a)||(s.id=a+"-"+h),Ie(s,this,ze(this,e(t,h,l,this)),t,h,l),h++})}else Ie(i,this,ze(this,s),t)}else Ie(t,this,ze(this,e));return this.init(1)}}sync(t,e){if(Y(t)||t&&Y(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return this.add(t,{currentTime:[0,s],duration:s,ease:"linear"},e)}set(t,e,s){return Y(e)?this:(e.duration=d,e.composition=r.replace,this.add(t,e,s))}call(t,e){return Y(t)||t&&!I(t)?this:this.add({duration:0,onComplete:()=>t(this)},e)}label(t,e){return Y(t)||t&&!z(t)||(this.labels[t]=ze(this,e)),this}remove(t,e){return Zt(ie(t),this,e),this}stretch(t){const e=this.duration;if(e===ft(t))return this;const s=t/e,i=this.labels;yt(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return yt(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),yt(this,t=>t.revert,!0),Ft(this)}then(t){return super.then(t)}}class Xe{constructor(t,e){D.current&&D.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},n={v:1,autoplay:!1},o={};if(this.targets=[],this.animations={},this.callbacks=null,!Y(t)&&!Y(e)){for(let t in e){const s=e[t];q(t)?o[t]=s:O(t,"on")?n[t]=s:i[t]=s}this.callbacks=new Ae({v:0},n);for(let e in o){const s=o[e],n=R(s);let a={},h="+=0";if(n){const t=s.unit;z(t)&&(h+=t)}else a.duration=s;a[e]=n?_t({to:h},s):h;const l=_t(i,a);l.composition=r.replace,l.autoplay=!1;const c=this.animations[e]=new Ae(t,l,null,0,!1).init();this.targets.length||this.targets.push(...c.targets),this[e]=(t,e,s)=>{const i=c._head;if(Y(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return yt(c,e=>{if(P(t))for(let s=0,i=t.length;s<i;s++)Y(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;Y(s)||(e._ease=Se(s)),e._currentTime=0}),Y(e)||c.stretch(e),c.reset(1).resume(),this}}}}revert(){for(let t in this.animations)this[t]=y,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const We=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i);var Ve=Object.freeze({__proto__:null,clamp:lt,damp:(t,e,s,i)=>i?1===i?e:pt(t,e,1-Math.exp(-i*s*.1)):t,degToRad:t=>t*Math.PI/180,lerp:pt,mapRange:We,padEnd:(t,e,s)=>`${t}`.padEnd(e,s),padStart:(t,e,s)=>`${t}`.padStart(e,s),radToDeg:t=>180*t/Math.PI,round:dt,roundPad:(t,e)=>(+t).toFixed(e),snap:ut,wrap:(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e});const He=10*p;class Ue{constructor(t={}){this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/p,this.maxIterations=this.maxDuration/this.timeStep/p,this.m=lt(St(t.mass,1),0,He),this.s=lt(St(t.stiffness,100),1,He),this.d=lt(St(t.damping,10),.1,He),this.v=lt(St(t.velocity,0),-1e4,He),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.solverDuration=0,this.duration=0,this.compute(),this.ease=t=>0===t||1===t?t:this.solve(t*this.solverDuration)}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?et(-n*e*s)*(1*K(i*n)+r*J(i*n)):(1+r*n)*et(-n*s),1-n}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,h=this.w0=lt(Z(o/r),d,p),l=this.zeta=n/(2*Z(o*r)),c=this.wd=l<1?h*Z(1-l*l):0;this.b=l<1?(l*h-a)/c:-a+h;let u=0,m=0,f=0;for(;m<t&&f<e;)tt(1-this.solve(u))<s?m++:m=0,this.solverDuration=u,u+=i,f++;this.duration=dt(this.solverDuration*p,0)*L.timeScale}get mass(){return this.m}set mass(t){this.m=lt(St(t,1),0,He),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=lt(St(t,100),1,He),this.compute()}get damping(){return this.d}set damping(t){this.d=lt(St(t,10),.1,He),this.compute()}get velocity(){return this.v}set velocity(t){this.v=lt(St(t,0),-1e4,He),this.compute()}}const qe=t=>new Ue(t),je=t=>{t.cancelable&&t.preventDefault()};class Qe{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:y,remove:y}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class Ge{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,s=0;for(;e&&e!==i;)t(e,s),e=e.parentElement,s++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const Ze=(t,e)=>t&&I(t)?t(e):t;let Je=0;class Ke{constructor(t,e={}){if(!t)return;D.current&&D.current.register(this);const r=e.x,n=e.y,o=e.trigger,a=e.modifier,h=e.releaseEase,l=h&&Se(h),c=!Y(h)&&!Y(h.ease),d=R(r)&&!Y(r.mapTo)?r.mapTo:"translateX",p=R(n)&&!Y(n.mapTo)?n.mapTo:"translateY",m=Ze(e.container,this);this.containerArray=P(m)?m:null,this.$container=m&&!this.containerArray?ie(m)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.$target=R(t)?new Qe(t):ie(t)[0],this.$trigger=ie(o||t)[0],this.fixed="fixed"===Pe(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=c?h:qe({mass:St(e.releaseMass,1),stiffness:St(e.releaseStiffness,80),damping:St(e.releaseDamping,20)}),this.releaseYSpring=c?h:qe({mass:St(e.releaseMass,1),stiffness:St(e.releaseStiffness,80),damping:St(e.releaseDamping,20)}),this.releaseEase=l||be.outQuint,this.hasReleaseSpring=c,this.onGrab=e.onGrab||y,this.onDrag=e.onDrag||y,this.onRelease=e.onRelease||y,this.onUpdate=e.onUpdate||y,this.onSettle=e.onSettle||y,this.onSnap=e.onSnap||y,this.onResize=e.onResize||y,this.onAfterResize=e.onAfterResize||y,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),Y(r)||!0===r)f[d]=0;else if(R(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[d]=e}else!1===r&&(f[d]=0,this.disabled[0]=1);if(Y(n)||!0===n)f[p]=0;else if(R(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[p]=e}else!1===n&&(f[p]=0,this.disabled[1]=1);this.animate=new Xe(this.$target,f),this.xProp=d,this.yProp=p,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-u,u,u,-u],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=F(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new Ge(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new ee({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new ee({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!Y(m),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?d:p,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=ot(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new ee({autoplay:!1,duration:150*L.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=e,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),R(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=F(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,h=this.maxVelocity,l=this.velocityStackIndex;n[l]=dt(lt(Z(t*t+e*e)/r*o,a,h),5);const c=nt(n[0],n[1],n[2]);return this.velocity=c,this.velocityStackIndex=(l+1)%3,c}setX(t,e=!1){if(this.disabled[0])return;const s=dt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=ut(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=dt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=ut(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return dt(this.animate[this.xProp](),L.precision)}set x(t){this.setX(t,!1)}get y(){return dt(this.animate[this.yProp](),L.precision)}set y(t){this.setY(t,!1)}get progressX(){return We(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(We(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return We(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(We(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=dt(this.useWin?s.scrollX:this.$container.scrollLeft,0),e=dt(this.useWin?s.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=e,this.scrollBounds[0]=e-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=e-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const e=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=s.innerWidth,h=this.window[1]=s.innerHeight,l=this.useWin,c=t.scrollWidth,d=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,_]=this.containerPadding;this.dragArea[0]=l?0:p.left,this.dragArea[1]=l?0:p.top,this.scrollView[0]=l?lt(c,a,c):c,this.scrollView[1]=l?lt(d,h,d):d,this.updateScrollCoords();const{width:y,height:v,left:b,top:T,right:S,bottom:w}=t.getBoundingClientRect();this.dragArea[2]=dt(l?lt(y,a,a):y,0),this.dragArea[3]=dt(l?lt(v,h,h):v,0);const x=Pe(t,"overflow"),k="visible"===x,$="hidden"===x;if(this.canScroll=!u&&this.contained&&(t===i.body&&k||!$&&!k)&&(c>this.dragArea[2]+_-f||d>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!P(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?l?0:t.scrollLeft:0,o=i?l?0:t.scrollTop:0,c=i?this.scrollView[0]-n-y:0,d=i?this.scrollView[1]-o-v:0;this.targetBounds[0]=dt(r.top+s-(l?0:T),0),this.targetBounds[1]=dt(r.right+e-(l?a:S),0),this.targetBounds[2]=dt(r.bottom+s-(l?h:w),0),this.targetBounds[3]=dt(r.left+e-(l?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+_):(this.containerBounds[0]=-dt(r.top-(u?lt(T,0,h):T)+o-m,0),this.containerBounds[1]=-dt(r.right-(u?lt(S,0,a):S)-c+f,0),this.containerBounds[2]=-dt(r.bottom-(u?lt(w,0,h):w)-d+g,0),this.containerBounds[3]=-dt(r.left-(u?lt(b,0,a):b)+n-_,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(e,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,h]=this.disabled,l=!a&&e<o||!a&&e>r,c=!h&&s<i||!h&&s>n;return l&&!c?1:!l&&c?2:l&&c?3:0}refresh(){const t=this.parameters,e=t.x,r=t.y,n=Ze(t.container,this),o=Ze(t.containerPadding,this)||0,a=P(o)?o:[o,o,o,o],h=this.x,l=this.y,c=Ze(t.cursor,this),d={onHover:"grab",onGrab:"grabbing"};if(c){const{onHover:t,onGrab:e}=c;t&&(d.onHover=t),e&&(d.onGrab=e)}this.containerArray=P(n)?n:null,this.$container=n&&!this.containerArray?ie(n)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=St(a,[0,0,0,0]),this.containerFriction=lt(St(Ze(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=lt(St(Ze(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=Ze(R(e)&&!Y(e.snap)?e.snap:t.snap,this),this.snapY=Ze(R(r)&&!Y(r.snap)?r.snap:t.snap,this),this.scrollSpeed=St(Ze(t.scrollSpeed,this),1.5),this.scrollThreshold=St(Ze(t.scrollThreshold,this),20),this.dragSpeed=St(Ze(t.dragSpeed,this),1),this.minVelocity=St(Ze(t.minVelocity,this),0),this.maxVelocity=St(Ze(t.maxVelocity,this),50),this.velocityMultiplier=St(Ze(t.velocityMultiplier,this),1),this.cursor=!1!==c&&d,this.updateBoundingValues();const[u,p,m,f]=this.containerBounds;this.setX(lt(h,f,p),!0),this.setY(lt(l,u,m),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],h=this.scroll.x,l=this.scroll.y,c=this.$container.scrollWidth,d=this.$container.scrollHeight,u=this.useWin?lt(c,this.window[0],c):c,p=this.useWin?lt(d,this.window[1],d):d,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,_=this.scrollThreshold,[y,v]=this.coords,[b,T,S,w]=this.scrollBounds,x=dt(lt((v-b+t)/_,-1,0)*g,0),k=dt(lt((y-T-e)/_,0,1)*g,0),$=dt(lt((v-S-s)/_,0,1)*g,0),E=dt(lt((y-w+i)/_,-1,0)*g,0);if(x||$||E||k){const[t,e]=this.disabled;let s=h,i=l;t||(s=dt(lt(h+(E||k),0,r-o),0),this.coords[0]-=h-s),e||(i=dt(lt(l+(x||$),0,n-a),0),this.coords[1]-=l-i),this.useWin?this.$scrollContainer.scrollBy(-(h-s),-(l-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,h,l]=this.pointer;this.coords[0]+=(r-h)*this.dragSpeed,this.coords[1]+=(n-l)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[c,d]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(c>e?e+(c-e)*m:c<i?i+(c-i)*m:c,!1),this.setY(d>s?s+(d-s)*m:d<t?t+(d-t)*m:d,!1),this.computeVelocity(r-h,n-l),this.angle=ot(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return Zt([this],null,"x"),Zt([this],null,"y"),Zt([this],null,"progressX"),Zt([this],null,"progressY"),Zt([this.scroll]),Zt([this.overshootCoords]),this}scrollInView(t,e=0,s=be.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[h,l,c,d]=o,p=dt(lt(r-h,-u,0),0),m=dt(lt(i-l,0,u),0),f=dt(lt(r-c,0,u),0),g=dt(lt(i-d,-u,0),0);new Ae(n,{x:dt(n.x+(g?g-e:m?m+e:0),0),y:dt(n.y+(p?p-e:f?f+e:0),0),duration:Y(t)?350*L.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Re(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=be.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,h]=this.containerPadding,l=this.scroll.y-this.targetBounds[0]+n+e,c=this.scroll.x-this.targetBounds[1]-o-e,d=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+h+e,p=this.isOutOfBounds([l,c,d,u],i,r);if(p){const[e,n]=this.disabled,o=lt(ut(i,this.snapX),u,c),a=lt(ut(r,this.snapY),l,d),h=Y(t)?350*L.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,h,s),n||2!==p&&3!==p||this.animate[this.yProp](a,h,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const s=t.changedTouches,r=s?s[0].clientX:t.clientX,n=s?s[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[h,l,c,d]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>l?l+(p-l)/u:p<d?d+(p-d)/u:p:p,this.coords[1]=this.coords[3]=u?m>c?c+(m-c)/u:m<h?h+(m-h)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Pe(this.$target,"zIndex",!1);Je=(f>Je?f:Je)+1,this.targetStyles=Re(this.$target,{zIndex:Je}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Re(i.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,be.out(3)),this.onGrab(this),i.addEventListener("touchmove",this),i.addEventListener("touchend",this),i.addEventListener("touchcancel",this),i.addEventListener("mousemove",this),i.addEventListener("mouseup",this),i.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let h=t.target,l=!1,c=!1,d=!1;for(;e&&h&&h!==this.$trigger;){const t=Pe(h,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=h;if(e>s){d=!0,l=t<=3,c=t>=e-s-3;break}}h=h.parentElement}d&&(!l&&!c||l&&a<0||c&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(je(t),this.triggerStyles||(this.triggerStyles=Re(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",je,{passive:!1}),this.$trigger.addEventListener("touchmove",je,{passive:!1}),this.$trigger.addEventListener("touchend",je),(!this.disabled[0]&&tt(o)>3||!this.disabled[1]&&tt(a)>3)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[s,n,o,a,h,l]=this.pointer,[c,d,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,_=this.releaseYSpring,y=this.releaseEase,v=this.hasReleaseSpring,b=this.overshootCoords,T=this.x,S=this.y,w=this.computeVelocity(s-h,n-l),x=this.angle=ot(n-a,s-o),k=150*w,$=(1-this.releaseContainerFriction)*this.dragSpeed,E=T+K(x)*k,C=S+J(x)*k,B=E>d?d+(E-d)*$:E<p?p+(E-p)*$:E,D=C>u?u+(C-u)*$:C<c?c+(C-c)*$:C,A=this.destX=lt(dt(ut(B,this.snapX),5),p,d),N=this.destY=lt(dt(ut(D,this.snapY),5),c,u),O=this.isOutOfBounds(this.containerBounds,E,C);let F=0,P=0,R=y,M=y,z=0;if(b.x=T,b.y=S,!t){const t=A===d?T>d?-1:1:T<p?-1:1,s=dt(T-A,0);g.velocity=e&&v?s?k*t/tt(s):0:w;const{ease:i,duration:r,restDuration:n}=g;F=T===A?0:v?r:r-n*L.timeScale,v&&(R=i),F>z&&(z=F)}if(!e){const e=N===u?S>u?-1:1:S<c?-1:1,s=dt(S-N,0);_.velocity=t&&v?s?k*e/tt(s):0:w;const{ease:i,duration:r,restDuration:n}=_;P=S===N?0:v?r:r-n*L.timeScale,v&&(M=i),P>z&&(z=P)}if(!v&&O&&$&&(F||P)){const t=r.blend;new Ae(b,{x:{to:B,duration:.65*F},y:{to:D,duration:.65*P},ease:y,composition:t}).init(),new Ae(b,{x:{to:A,duration:F},y:{to:N,duration:P},ease:y,composition:t}).init(),this.overshootTicker.stretch(nt(F,P)).restart()}else t||this.animate[this.xProp](A,F,R),e||this.animate[this.yProp](N,P,M);this.scrollInView(z,this.scrollThreshold,y);let I=!1;A!==m&&(this.snapped[0]=A,this.snapX&&(I=!0)),N!==f&&this.snapY&&(this.snapped[1]=N,this.snapY&&(I=!0)),I&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",je),this.$trigger.removeEventListener("touchmove",je),this.$trigger.removeEventListener("touchend",je),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Re(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":je(t)}}}const ts=(t=y)=>new ee({duration:1*L.timeScale,onComplete:t},null,0).resume(),es=t=>{let e;return(...s)=>{let i,r,n,o;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,e.revert());const a=t(...s);return a&&!I(a)&&a.revert&&(e=a),Y(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r),a||y}};class ss{constructor(t={}){D.current&&D.current.register(this);const e=t.root;let r=i;e&&(r=e.current||e.nativeElement||ie(e)[0]||i);const n=t.defaults,o=L.defaults,a=t.mediaQueries;if(this.defaults=n?_t(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const e=s.matchMedia(a[t]);this.mediaQueryLists[t]=e,e.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=D.current,s=D.root,i=L.defaults;D.current=this,D.root=this.root,L.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return D.current=e,D.root=s,L.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);I(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,I(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);I(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,I(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);I(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(I(s))return s(this);const i=es(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,h=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;h--;)i[h](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const is=(t,e)=>t&&I(t)?t(e):t,rs=new Map;class ns{constructor(t){this.element=t,this.useWin=this.element===i.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new ee({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;yt(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new ee({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=dt(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new ee({autoplay:!1,duration:250*L.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new ee({autoplay:!1,duration:500*L.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?s:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,e=this.element;this.scrollX=dt(t?s.scrollX:e.scrollLeft,0),this.scrollY=dt(t?s.scrollY:e.scrollTop,0)}updateWindowBounds(){this.winWidth=s.innerWidth,this.winHeight=(()=>{const t=i.createElement("div");i.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return i.body.removeChild(t),e})()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left}this.width=s,this.height=i}refreshScrollObservers(){yt(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),yt(this,t=>{t.refresh(),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?s:this.element).removeEventListener("scroll",this),rs.delete(this.element)}}const os=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:h,u:l}=Ct(a,Dt);let c=h;return"%"===l?c=h/100*s:l&&(c=ae(t,Dt,"px",!0).n),o&&i<0&&(c+=i),n&&r>0&&(c+=r),c},as=(t,e,s,i,r)=>{let n;if(z(e)){const o=C.exec(e);if(o){const a=o[0],h=a[0],l=e.split(a),c="min"===l[0],d="max"===l[0],u=os(t,l[0],s,i,r),p=os(t,l[1],s,i,r);if(c){const e=Et(os(t,"min",s),p,h);n=e<u?u:e}else if(d){const e=Et(os(t,"max",s),p,h);n=e>u?u:e}else n=Et(u,p,h)}else n=os(t,e,s,i,r)}else n=e;return dt(n,0)},hs=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[o]){e=i;break}}return e};let ls=0;const cs=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class ds{constructor(t={}){D.current&&D.current.register(this);const e=St(t.sync,"play pause"),s=e?Se(e):null,r=e&&("linear"===e||e===he),n=e&&!(s===he&&!r),o=e&&(M(e)||!0===e||r),a=e&&z(e)&&!n&&!o,h=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,l=a&&h.length>2;this.index=ls++,this.id=Y(t.id)?this.index:t.id,this.container=(t=>{const e=t&&ie(t)[0]||i.body;let s=rs.get(e);return s||(s=new ns(e),rs.set(e,s)),s})(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!h,this.syncEase=n?s:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=h&&!l&&h[0]?h[0]:y,this.onSyncLeave=h&&!l&&h[1]?h[1]:y,this.onSyncEnterForward=h&&l&&h[0]?h[0]:y,this.onSyncLeaveForward=h&&l&&h[1]?h[1]:y,this.onSyncEnterBackward=h&&l&&h[2]?h[2]:y,this.onSyncLeaveBackward=h&&l&&h[3]?h[3]:y,this.onEnter=t.onEnter||y,this.onLeave=t.onLeave||y,this.onEnterForward=t.onEnterForward||y,this.onLeaveForward=t.onLeaveForward||y,this.onEnterBackward=t.onEnterBackward||y,this.onLeaveBackward=t.onLeaveBackward||y,this.onUpdate=t.onUpdate||y,this.onSyncComplete=t.onSyncComplete||y,this.reverted=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=St(t.debug,!1),this._next=null,this._prev=null,bt(this.container,this),ts(()=>{if(!this.reverted){if(!this.target){const e=ie(t.target)[0];this.target=e||i.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,!this._params.target)){let e;Y(t.targets)?yt(t,t=>{t.targets&&!e&&(e=hs(t))}):e=hs(t),this.target=e||i.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:dt(lt(t,0,1),6)}refresh(){this.reverted=!1;const t=this._params;return this.repeat=St(is(t.repeat,this),!0),this.horizontal="x"===St(is(t.axis,this),"y"),this.enter=St(is(t.enter,this),"end start"),this.leave=St(is(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,s=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=i.createElement("div"),n=i.createElement("div"),o=i.createElement("div"),a=cs[this.index%cs.length],h=t.useWin,l=h?t.winWidth:t.width,c=h?t.winHeight:t.height,d=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,_=e?g:15,y=e?60:g,v=e?y:_,b=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",S=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,w=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${w("absolute",m,f,e?d:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${w("sticky",0,0,e?l:g,e?g:c)}`,s||(n.style.cssText+=`background:\n ${S("#FFFF")}${T(g-10)} / 100px 100px ${b},\n ${S("#FFF8")}${T(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${w("relative",0,0,e?d:g,e?g:u)}`,s||(o.style.cssText+=`background:\n ${S("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${S("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const x=[" enter: "," leave: "];this.coords.forEach((t,s)=>{const r=s>1,h=(r?0:this.offset)+t,m=s%2,f=h<v,g=h>(r?e?l:c:e?d:u)-v,b=(r?m&&!f:!m&&!f)||g,T=i.createElement("div"),S=i.createElement("div"),k=e?b?"right":"left":b?"bottom":"top",$=b?(e?y:_)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;S.innerHTML=`${this.id}${x[m]}${this.thresholds[s]}`,T.style.cssText=`${w("absolute",0,0,y,_)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${k}: 2px solid ${a};\n `,S.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${_};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(S);let E=h-$+(e?1:0);T.style[e?"left":"top"]=`${E}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),s||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Pe(t.element,"position")&&(this.debugStyles=Re(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,s=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0)),a.parentElement;a&&a!==s.element&&a!==i.body;){const e="sticky"===Pe(a,"position")&&Re(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const h=e.getBoundingClientRect(),l=r?h.left+s.scrollX-s.left:h.top+s.scrollY-s.top,c=r?h.width:h.height,d=r?s.width:s.height,u=(r?s.scrollWidth:s.scrollHeight)-d,p=this.enter,m=this.leave;let f="start",g="end",_="end",y="start";if(z(p)){const t=p.split(" ");_=t[0],f=t.length>1?t[1]:f}else if(R(p)){const t=p;Y(t.container)||(_=t.container),Y(t.target)||(f=t.target)}else M(p)&&(_=p);if(z(m)){const t=m.split(" ");y=t[0],g=t.length>1?t[1]:g}else if(R(m)){const t=m;Y(t.container)||(y=t.container),Y(t.target)||(g=t.target)}else M(m)&&(y=m);const v=as(e,f,c),b=as(e,g,c),T=v+l-d,S=b+l-u,w=as(e,_,d,T,S),x=as(e,y,d,T,S),k=v+l-w,$=b+l-x,E=$-k;this.offset=l,this.offsetStart=k,this.offsetEnd=$,this.distance=E<=0?0:E,this.thresholds=[f,g,_,y],this.coords=[v,b,w,x],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,h=a<=this.offsetStart,l=a>=this.offsetEnd,c=!h&&!l,d=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&d,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(h&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&M(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=dt(pt(e,g,pt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(c&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(c&&(this.isInView=!0),this.forceEnter&&this.hasEntered?c&&(this.forceEnter=!1):(p&&c&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(c||!c&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!c&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return vt(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this}}var us=Object.freeze({__proto__:null,cubicBezier:pe,eases:be,irregular:ge,linear:fe,none:he,steps:me});const ps=Ve,ms={},fs=t=>(...e)=>{const s=t(...e);return new Proxy(y,{apply:(t,e,[i])=>s(i),get:(t,e)=>fs((...t)=>{const i=ms[e](...t);return t=>i(s(t))})})},gs=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?fs(((t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s))(e,s)):e)(...t);return ms[t]||(ms[t]=i),i},_s=gs("roundPad",ps.roundPad),ys=gs("padStart",ps.padStart),vs=gs("padEnd",ps.padEnd),bs=gs("wrap",ps.wrap),Ts=gs("mapRange",ps.mapRange),Ss=gs("degToRad",ps.degToRad),ws=gs("radToDeg",ps.radToDeg),xs=gs("snap",ps.snap),ks=gs("clamp",ps.clamp),$s=gs("round",ps.round),Es=gs("lerp",ps.lerp,1),Cs=gs("damp",ps.damp,1),Bs=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let Ds=0;const Ls=(t,e=0,s=1,i=0)=>{let r=void 0===t?Ds++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},As=t=>t[Bs(0,t.length-1)],Ns=t=>{let e,s,i=t.length;for(;i;)s=Bs(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},Os=(t,e={})=>{let s=[],i=0;const r=e.from,n=e.reversed,o=e.ease,a=!Y(o),h=a&&!Y(o.ease)?o.ease:a?Se(o):null,l=e.grid,c=e.axis,d=e.total,u=Y(r)||0===r||"first"===r,p="center"===r,f="last"===r,g="random"===r,_=P(t),y=e.use,v=Q(_?t[0]:t),b=_?Q(t[1]):0,T=k.exec((_?t[1]:t)+m),S=e.start||0+(_?v:0);let w=u?0:M(r)?r:0;return(t,r,o,a)=>{const[u]=re(t),m=Y(d)?o:d,x=!Y(y)&&(I(y)?y(u,r,m):$t(u,y)),k=M(x)||z(x)&&M(+x)?+x:r;if(p&&(w=(m-1)/2),f&&(w=m-1),!s.length){for(let t=0;t<m;t++){if(l){const e=p?(l[0]-1)/2:w%l[0],i=p?(l[1]-1)/2:it(w/l[0]),r=e-t%l[0],n=i-it(t/l[0]);let o=Z(r*r+n*n);"x"===c&&(o=-r),"y"===c&&(o=-n),s.push(o)}else s.push(tt(w-t));i=nt(...s)}h&&(s=s.map(t=>h(t/i)*i)),n&&(s=s.map(t=>c?t<0?-1*t:-t:tt(i-t))),g&&(s=Ns(s))}const $=_?(b-v)/i:v;let E=(a?ze(a,Y(e.start)?a.iterationDuration:S):S)+($*dt(s[k],2)||0);return e.modifier&&(E=e.modifier(E)),T&&(E=`${E}${T[2]}`),E}};var Fs=Object.freeze({__proto__:null,$:re,clamp:ks,cleanInlineStyles:Ft,createSeededRandom:Ls,damp:Cs,degToRad:Ss,get:Pe,keepTime:es,lerp:Es,mapRange:Ts,padEnd:vs,padStart:ys,radToDeg:ws,random:Bs,randomPick:As,remove:Me,round:$s,roundPad:_s,set:Re,shuffle:Ns,snap:xs,stagger:Os,sync:ts,wrap:bs});const Ps=t=>{const e=ie(t)[0];return e&&W(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},Rs=(t,e,s=0)=>t.getPointAtLength(e+s>=1?e+s:0),Ms=(t,e)=>s=>{const i=+t.getTotalLength(),r=s[a],n=t.getCTM();return{from:0,to:i,modifier:s=>{if("a"===e){const e=Rs(t,s,-1),i=Rs(t,s,1);return 180*ot(i.y-e.y,i.x-e.x)/at}{const i=Rs(t,s,0);return"x"===e?r||!n?i.x:i.x*n.a+i.y*n.c+n.e:r||!n?i.y:i.x*n.b+i.y*n.d+n.f}}}},zs=t=>{const e=Ps(t);if(e)return{translateX:Ms(e,"x"),translateY:Ms(e,"y"),rotate:Ms(e,"a")}},Is=(t,e=0,s=0)=>ie(t).map(t=>((t,e,s)=>{const i=p,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const h=new Proxy(t,{get(t,e){const s=t[e];return e===c?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],h=+s[1],l=(t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(Z(s.a*s.a+s.b*s.b)+Z(s.c*s.c+s.d*s.d))/2)}return e})(o),c=-1e3*r*l,d=h*i*l+c,u=i*l+(0===r&&1===h||1===r&&0===h?0:10*l)-d;if("butt"!==n){const e=r===h?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${c}`),t.setAttribute("stroke-dasharray",`${d} ${u}`)}return Reflect.apply(s,t,e)}:I(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),h.setAttribute("draw",`${e} ${s}`)),h})(t,e,s)),Ys=(t,e=.33)=>s=>{const i=Ps(t);if(!i)return;const r="path"===s.tagName,n=r?" ":",",o=s[l];o&&s.setAttribute(r?"d":"points",o);let a="",h="";if(e){const t=s.getTotalLength(),o=i.getTotalLength(),l=Math.max(Math.ceil(t*e),Math.ceil(o*e));for(let e=0;e<l;e++){const c=e/(l-1),d=s.getPointAtLength(t*c),u=i.getPointAtLength(o*c),p=r?0===e?"M":"L":"";a+=p+dt(d.x,3)+n+d.y+" ",h+=p+dt(u.x,3)+n+u.y+" "}}else a=s.getAttribute(r?"d":"points"),h=i.getAttribute(r?"d":"points");return s[l]=h,[a,h]};var Xs=Object.freeze({__proto__:null,createDrawable:Is,createMotionPath:zs,morphTo:Ys});const Ws="undefined"!=typeof Intl&&Intl.Segmenter,Vs=/\{value\}/g,Hs=/\{i\}/g,Us=/(\s+)/,qs=/^\s+$/,js="line",Qs="word",Gs="char",Zs="data-line";let Js=null,Ks=null,ti=null;const ei=t=>t.isWordLike||" "===t.segment||M(+t.segment),si=t=>t.setAttribute("aria-hidden","true"),ii=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],ri={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},ni=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&ni(e)}},oi=(t,e,s)=>{const i=t.getAttribute(Zs);(null!==i&&+i!==e||"BR"===t.tagName)&&s.add(t);let r=t.childElementCount;for(;r--;)oi(t.children[r],e,s);return s},ai=(t,e={})=>{let s="";const i=z(e.class)?` class="${e.class}"`:"",r=St(e.clone,!1),n=St(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},hi=(t,e,s,i,r,n,o,a,h)=>{const l=r===js,c=r===Gs,d=`_${r}_`,u=I(t)?t(s):t,p=l?"block":"inline-block";ti.innerHTML=u.replace(Vs,`<i class="${d}"></i>`).replace(Hs,`${c?h:l?o:a}`);const m=ti.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,_=m.querySelectorAll(`i.${d}`),y=_.length;if(y){f.style.display=p,g.style.display=p,g.setAttribute(Zs,`${o}`),l||(g.setAttribute("data-word",`${a}`),c&&g.setAttribute("data-char",`${h}`));let t=y;for(;t--;){const e=_[t],i=e.parentElement;i.style.display=p,l?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${ri[r]}`),f};class li{constructor(t,s={}){Js||(Js=Ws?new Ws([],{granularity:Qs}):{segment:t=>{const e=[],s=t.split(Us);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!qs.test(i)})}return e}}),Ks||(Ks=Ws?new Ws([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!ti&&e&&(ti=i.createElement("template")),D.current&&D.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:h,debug:l}=s,c=(t=P(t)?t[0]:t)&&t.nodeType?t:(se(t)||[])[0],d=!0===o?{}:o,u=!0===r||Y(r)?{}:r,p=!0===n?{}:n;this.debug=St(l,!1),this.includeSpaces=St(h,!1),this.accessible=St(a,!0),this.linesOnly=d&&!u&&!p,this.lineTemplate=R(d)?ai(js,d):d,this.wordTemplate=R(u)||this.linesOnly?ai(Qs,u):u,this.charTemplate=R(p)?ai(Gs,p):p,this.$target=c,this.html=c&&c.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(d||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=c.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?i.fonts.ready.then(m):m(),c?this.resizeObserver.observe(c):console.warn("No Text Splitter target found.")}addEffect(t){if(!I(t))return console.warn("Effect must return a function.");const e=es(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>I(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,s=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],h=this.words,l=this.chars,c=Js.segment(o),d=i.createDocumentFragment();let u=null;for(const t of c){const e=t.segment,s=ei(t);if(!u||s&&u&&ei(u))a.push(e);else{const t=a.length-1;a[t].includes(" ")||e.includes(" ")?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const c=a[t+1],u=r&&c&&!c.trim(),p=o,m=s?Ks.segment(p):null,f=s?i.createDocumentFragment():i.createTextNode(u?o+" ":o);if(s){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,c=i.createTextNode(a);hi(s,l,c,f,Gs,n,-1,h.length,l.length)}}e?hi(e,h,f,d,Qs,n,-1,h.length,l.length):s?d.appendChild(f):d.appendChild(i.createTextNode(o)),u&&t++}else{if(t&&r)continue;d.appendChild(i.createTextNode(o))}}t.parentNode.replaceChild(d,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,s=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==i.fonts.status,h=r&&a;this.ready=!r||a,(h||t)&&this.effectsCleanups.forEach(t=>I(t)&&t(this)),s||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),h&&(s&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=ii(e,Qs))),o&&(h||n)&&(this.chars=ii(e,Gs));const l=this.words.length?this.words:this.chars;let c,d=0;for(let t=0,e=l.length;t<e;t++){const e=l[t],{top:s,height:i}=e.getBoundingClientRect();c&&s-c>.5*i&&d++,e.setAttribute(Zs,`${d}`);const r=e.querySelectorAll(`[${Zs}]`);let n=r.length;for(;n--;)r[n].setAttribute(Zs,`${d}`);c=s}if(h){const t=i.createDocumentFragment(),s=new Set,a=[];for(let t=0;t<d+1;t++){const i=e.cloneNode(!0);oi(i,t,new Set).forEach(t=>{const e=t.parentElement;e&&s.add(e),t.remove()}),a.push(i)}s.forEach(ni);for(let e=0,s=a.length;e<s;e++)hi(r,this.lines,a[e],t,js,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=ii(e,Qs)),o&&(this.chars=ii(e,Gs))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(h||!s)){const t=i.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(si),this.words.forEach(si),this.chars.forEach(si)}return this.width=e.offsetWidth,(h||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const ci=(t,e)=>new li(t,e),di=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new li(t,e));var ui=Object.freeze({__proto__:null,TextSplitter:li,split:di,splitText:ci});const pi=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(t(i/e));return`linear(${s.join(", ")})`},mi={in:"ease-in",out:"ease-out",inOut:"ease-in-out"},fi=(()=>{const t={};for(let e in ce)t[e]=t=>ce[e](le(t));return t})(),gi=t=>{let e=mi[t];if(e)return e;if(e="linear",z(t)){if(O(t,"linear")||O(t,"cubic-")||O(t,"steps")||O(t,"ease"))e=t;else if(O(t,"cubicB"))e=N(t);else{const s=de(t,fi,mi);I(s)&&(e=s===he?"linear":pi(s))}mi[t]=e}else if(I(t)){const s=pi(t);s&&(e=s)}else t.ease&&(e=pi(t.ease));return e},_i=["x","y","z"],yi=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",..._i],vi=(()=>[..._i,...g.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let bi=null;const Ti=(t,e,s,i,r)=>{let n=wt(e,s,i,r);return M(n)?yi.includes(t)||O(t,"translate")?`${n}px`:O(t,"rotate")||O(t,"skew")?`${n}deg`:`${n}`:n},Si=(t,e,s,i,r,n)=>{let o="0";const a=Y(i)?getComputedStyle(t)[e]:Ti(e,i,t,r,n);return o=Y(s)?P(i)?i.map(s=>Ti(e,s,t,r,n)):a:[Ti(e,s,t,r,n),a],o};class wi{constructor(t,s){D.current&&D.current.register(this),X(bi)&&(!e||!Y(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(g.forEach(t=>{const e=O(t,"skew"),s=O(t,"scale"),i=O(t,"rotate"),r=O(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),bi=!0):bi=!1);const i=re(t),r=i.length;r||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const n=St(s.ease,gi(L.defaults.ease)),o=n.ease&&n,a=St(s.autoplay,L.defaults.autoplay),l=!(!a||!a.link)&&a,c=s.alternate&&!0===s.alternate,d=s.reversed&&!0===s.reversed,u=St(s.loop,L.defaults.loop),v=!0===u||u===1/0?1/0:M(u)?u+1:1,b=c?d?"alternate-reverse":"alternate":d?"reverse":"normal",T=gi(n),S=1===L.timeScale?1:p;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||y,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!a||!1!==l,this.reversed=d,this.autoplay=a,this._speed=St(s.playbackRate,L.defaults.playbackRate),this._resolve=y,this._completed=0,this._inlineStyles=i.map(t=>t.getAttribute("style")),i.forEach((t,e)=>{const i=t[h],a=vi.some(t=>s.hasOwnProperty(t)),l=(o?o.duration:wt(St(s.duration,L.defaults.duration),t,e,r))*S,c=wt(St(s.delay,L.defaults.delay),t,e,r)*S,d=St(s.composition,"replace");for(let o in s){if(!q(o))continue;const h={},u={iterations:v,direction:b,fill:"forwards",easing:T,duration:l,delay:c,composite:d},p=s[o],m=!!a&&(g.includes(o)?o:f.get(o));let _;if(R(p)){const s=p,a=St(s.ease,n),f=a.ease&&a,g=s.to,y=s.from;if(u.duration=(f?f.duration:wt(St(s.duration,l),t,e,r))*S,u.delay=wt(St(s.delay,c),t,e,r)*S,u.composite=St(s.composition,d),u.easing=gi(a),_=Si(t,o,y,g,e,r),m?(h[`--${m}`]=_,i[m]=_):h[o]=Si(t,o,y,g,e,r),Fe(this,t,o,h,u),!Y(y))if(m){const e=`--${m}`;t.style.setProperty(e,h[e][0])}else t.style[o]=h[o][0]}else _=P(p)?p.map(s=>Ti(o,s,t,e,r)):Ti(o,p,t,e,r),m?(h[`--${m}`]=_,i[m]=_):h[o]=_,Fe(this,t,o,h,u)}if(a){let e=m;for(let t in i)e+=`${_[t]}var(--${t})) `;t.style.transform=e}}),l&&this.autoplay.link(this)}forEach(t){const e=z(t)?e=>e[t]():t;return this.animations.forEach(e),this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=L.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===L.timeScale?1:p);this.forEach(t=>{e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.forEach("cancel"),this.pause()}revert(){return this.cancel(),this.targets.forEach((t,e)=>t.setAttribute("style",this._inlineStyles[e])),this}then(t=y){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=y};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const xi={animate:(t,e)=>new wi(t,e),convertEase:pi};t.$=re,t.Animatable=Xe,t.Draggable=Ke,t.JSAnimation=Ae,t.Scope=ss,t.ScrollObserver=ds,t.Spring=Ue,t.TextSplitter=li,t.Timeline=Ye,t.Timer=ee,t.WAAPIAnimation=wi,t.animate=(t,e)=>new Ae(t,e,null,0,!1).init(),t.clamp=ks,t.cleanInlineStyles=Ft,t.createAnimatable=(t,e)=>new Xe(t,e),t.createDraggable=(t,e)=>new Ke(t,e),t.createDrawable=Is,t.createMotionPath=zs,t.createScope=t=>new ss(t),t.createSeededRandom=Ls,t.createSpring=qe,t.createTimeline=t=>new Ye(t).init(),t.createTimer=t=>new ee(t,null,0).init(),t.cubicBezier=pe,t.damp=Cs,t.degToRad=Ss,t.eases=be,t.easings=us,t.engine=Yt,t.get=Pe,t.irregular=ge,t.keepTime=es,t.lerp=Es,t.linear=fe,t.mapRange=Ts,t.morphTo=Ys,t.none=he,t.onScroll=(t={})=>new ds(t),t.padEnd=vs,t.padStart=ys,t.radToDeg=ws,t.random=Bs,t.randomPick=As,t.remove=Me,t.round=$s,t.roundPad=_s,t.scrollContainers=rs,t.set=Re,t.shuffle=Ns,t.snap=xs,t.split=di,t.splitText=ci,t.stagger=Os,t.steps=me,t.svg=Xs,t.sync=ts,t.text=ui,t.utils=Fs,t.waapi=xi,t.wrap=bs});
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).anime={})}(this,function(t){"use strict";const e="undefined"!=typeof window,s=e?window:null,i=e?document:null,r={replace:0,none:1,blend:2},n=Symbol(),o=Symbol(),a=Symbol(),h=Symbol(),l=Symbol(),c=Symbol(),d=1e-11,u=1e12,p=1e3,m="",f=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),g=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","matrix","matrix3d","perspective"],_=g.reduce((t,e)=>({...t,[e]:e+"("}),{}),y=()=>{},v=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,b=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,S=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,T=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,w=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,x=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,k=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,$=/([a-z])([A-Z])/g,E=/(\w+)(\([^)]+\)+)/g,C=/(\*=|\+=|-=)/,D=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,B={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:120,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:p,delay:0,loopDelay:0,ease:"out(2)",composition:r.replace,modifier:t=>t,onBegin:y,onBeforeUpdate:y,onUpdate:y,onLoop:y,onPause:y,onComplete:y,onRender:y},L={current:null,root:i},A={defaults:B,precision:4,timeScale:1,tickThreshold:200},N={version:"4.2.0",engine:null};e&&(s.AnimeJS||(s.AnimeJS=[]),s.AnimeJS.push(N));const F=t=>t.replace($,"$1-$2").toLowerCase(),P=(t,e)=>0===t.indexOf(e),O=Date.now,R=Array.isArray,M=t=>t&&t.constructor===Object,z=t=>"number"==typeof t&&!isNaN(t),I=t=>"string"==typeof t,Y=t=>"function"==typeof t,X=t=>void 0===t,W=t=>X(t)||null===t,V=t=>e&&t instanceof SVGElement,H=t=>v.test(t),U=t=>P(t,"rgb"),q=t=>P(t,"hsl"),j=t=>!A.defaults.hasOwnProperty(t),Q=["opacity","rotate","overflow","color"],G=t=>I(t)?parseFloat(t):t,Z=Math.pow,J=Math.sqrt,K=Math.sin,tt=Math.cos,et=Math.abs,st=Math.exp,it=Math.ceil,rt=Math.floor,nt=Math.asin,ot=Math.max,at=Math.atan2,ht=Math.PI,lt=Math.round,ct=(t,e,s)=>t<e?e:t>s?s:t,dt={},ut=(t,e)=>{if(e<0)return t;if(!e)return lt(t);let s=dt[e];return s||(s=dt[e]=10**e),lt(t*s)/s},pt=(t,e)=>R(e)?e.reduce((e,s)=>et(s-t)<et(e-t)?s:e):e?lt(t/e)*e:t,mt=(t,e,s)=>t+(e-t)*s,ft=t=>t===1/0?u:t===-1/0?-u:t,gt=t=>t<=d?d:ft(ut(t,11)),_t=t=>R(t)?[...t]:t,yt=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=X(r)?e[i]:r}return s},vt=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},bt=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},St=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},Tt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),wt=(t,e)=>X(t)?e:t,xt=(t,e,s,i,r)=>{let n;if(Y(t))n=()=>{const r=t(e,s,i);return isNaN(+r)?r||0:+r};else{if(!I(t)||!P(t,"var("))return t;n=()=>{const s=t.match(D),i=s[1],r=s[2];let n=getComputedStyle(e)?.getPropertyValue(i);return n&&n.trim()!==m||!r||(n=r.trim()),n||0}}return r&&(r.func=n),n()},kt=(t,e)=>t[o]?t[a]&&((t,e)=>{if(Q.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}})(t,e)?1:g.includes(e)||f.get(e)?3:P(e,"--")?4:e in t.style?2:e in t?0:1:0,$t=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[c]||t).getPropertyValue(e);return"auto"===r?"0":r},Et=(t,e,s,i)=>{const r=X(s)?kt(t,e):s;return 0===r?t[e]||0:1===r?t.getAttribute(e):3===r?((t,e,s)=>{const i=t.style.transform;let r;if(i){const n=t[h];let o;for(;o=E.exec(i);){const t=o[1],i=o[2].slice(1,-1);n[t]=i,t===e&&(r=i,s&&(s[e]=i))}}return i&&!X(r)?r:P(e,"scale")?"1":P(e,"rotate")||P(e,"skew")?"0deg":"0px"})(t,e,i):4===r?$t(t,e,i).trimStart():$t(t,e,i)},Ct=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,Dt=(t,e)=>{if(e.t=0,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const n=!s.includes(" ")&&k.exec(s);if(n)return e.t=1,e.n=+n[1],e.u=n[2],e;if(e.o)return e.n=+s,e;if(H(r=s)||U(r)||q(r))return e.t=2,e.d=U(i=s)?(t=>{const e=b.exec(t)||S.exec(t),s=X(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]})(i):H(i)?(t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]})(i):q(i)?(t=>{const e=T.exec(t)||w.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=X(e[4])?1:+e[4];let o,a,h;if(0===i)o=a=h=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=ut(255*Tt(e,t,s+1/3),0),a=ut(255*Tt(e,t,s),0),h=ut(255*Tt(e,t,s-1/3),0)}return[o,a,h,n]})(i):[0,0,0,1],e;{const t=s.match(x);return e.t=3,e.d=t?t.map(Number):[],e.s=s.split(x)||[],e}}var i,r;return e.n=s,e},Bt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=_t(t._toNumbers),e.s=_t(t._strings),e),Lt={t:0,n:0,u:null,o:null,d:null,s:null},At=(t,e,s,i,n)=>{const o=t.parent,a=t.duration,l=t.completed,c=t.iterationDuration,u=t.iterationCount,p=t._currentIteration,f=t._loopDelay,g=t._reversed,y=t._alternate,v=t._hasChildren,b=t._delay,S=t._currentTime,T=b+c,w=e-b,x=ct(S,-b,a),k=ct(w,-b,a),$=w-S,E=k>0,C=k>=a,D=a<=d,B=2===n;let L=0,N=w,F=0;if(u>1){const e=~~(k/(c+(C?0:f)));t._currentIteration=ct(e,0,u),C&&t._currentIteration--,L=t._currentIteration%2,N=k%(c+f)||0}const P=g^(y&&L),O=t._ease;let R=C?P?0:a:P?c-N:N;O&&(R=c*O(R/c)||0);const M=(o?o.backwards:w<S)?!P:!!P;if(t._currentTime=w,t._iterationTime=R,t.backwards=M,E&&!t.began?(t.began=!0,s||o&&(M||!o.began)||t.onBegin(t)):w<=0&&(t.began=!1),s||v||!E||t._currentIteration===p||t.onLoop(t),B||1===n&&(e>=b&&e<=T||e<=b&&x>b||e>=T&&x!==a)||R>=T&&x!==a||R<=b&&x>0||e<=x&&x===a&&l||C&&!l&&D){if(E&&(t.computeDeltaTime(x),s||t.onBeforeUpdate(t)),!v){const e=B||(M?-1*$:$)>=A.tickThreshold,n=t._offset+(o?o._offset:0)+b+R;let a,l,c,d,u=t._head,p=0;for(;u;){const t=u._composition,s=u._currentTime,o=u._changeDuration,f=u._absoluteStartTime+u._changeDuration,g=u._nextRep,y=u._prevRep,v=t!==r.none;if((e||(s!==o||n<=f+(g?g._delay:0))&&(0!==s||n>=u._absoluteStartTime))&&(!v||!u._isOverridden&&(!u._isOverlapped||n<=f)&&(!g||g._isOverridden||n<=g._absoluteStartTime)&&(!y||y._isOverridden||n>=y._absoluteStartTime+y._changeDuration+u._delay))){const e=u._currentTime=ct(R-u._startTime,0,o),s=u._ease(e/u._updateDuration),n=u._modifier,m=u._valueType,f=u._tweenType,g=0===f,_=0===m,y=_&&g||0===s||1===s?-1:A.precision;let b,S;if(_)b=S=n(ut(mt(u._fromNumber,u._toNumber,s),y));else if(1===m)S=n(ut(mt(u._fromNumber,u._toNumber,s),y)),b=`${S}${u._unit}`;else if(2===m){const t=u._fromNumbers,e=u._toNumbers,i=ut(ct(n(mt(t[0],e[0],s)),0,255),0),r=ut(ct(n(mt(t[1],e[1],s)),0,255),0),o=ut(ct(n(mt(t[2],e[2],s)),0,255),0),a=ct(n(ut(mt(t[3],e[3],s),y)),0,1);if(b=`rgba(${i},${r},${o},${a})`,v){const t=u._numbers;t[0]=i,t[1]=r,t[2]=o,t[3]=a}}else if(3===m){b=u._strings[0];for(let t=0,e=u._toNumbers.length;t<e;t++){const e=n(ut(mt(u._fromNumbers[t],u._toNumbers[t],s),y)),i=u._strings[t+1];b+=`${i?e+i:e}`,v&&(u._numbers[t]=e)}}if(v&&(u._number=S),i||t===r.blend)u._value=b;else{const t=u.property;a=u.target,g?a[t]=b:1===f?a.setAttribute(t,b):(l=a.style,3===f?(a!==c&&(c=a,d=a[h]),d[t]=b,p=1):2===f?l[t]=b:4===f&&l.setProperty(t,b)),E&&(F=1)}}if(p&&u._renderTransforms){let t=m;for(let e in d)t+=`${_[e]}${d[e]}) `;l.transform=t,p=0}u=u._next}!s&&F&&t.onRender(t)}!s&&E&&t.onUpdate(t)}return o&&D?!s&&(o.began&&!M&&w>0&&!l||M&&w<=d&&l)&&(t.onComplete(t),t.completed=!M):E&&C?u===1/0?t._startTime+=t.duration:t._currentIteration>=u-1&&(t.paused=!0,l||v||(t.completed=!0,s||o&&(M||!o.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,F},Nt=(t,e,s,i,r)=>{const n=t._currentIteration;if(At(t,e,s,i,r),t._hasChildren){const o=t,a=o.backwards,h=i?e:o._iterationTime,l=O();let c=0,u=!0;if(!i&&o._currentIteration!==n){const t=o.iterationDuration;vt(o,e=>{if(a){const i=e.duration,r=e._offset+e._delay;s||!(i<=d)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&At(e,t,s,1,2),e.began=!1,e.completed=!1}),s||o.onLoop(o)}vt(o,t=>{const e=ut((h-t._offset)*t._speed,12),n=t._fps<o._fps?t.requestTick(l):r;c+=At(t,e,s,i,n),!t.completed&&u&&(u=!1)},a),!s&&c&&o.onRender(o),(u||a)&&o._currentTime>=o.duration&&(o.paused=!0,o.completed||(o.completed=!0,s||(o.onComplete(o),o._resolve(o))))}},Ft={},Pt=(t,e,s)=>{if(3===s)return f.get(t)||t;if(2===s||1===s&&V(e)&&t in e.style){const e=Ft[t];if(e)return e;{const e=t?F(t):t;return Ft[t]=e,e}}return t},Ot=t=>{if(t._hasChildren)vt(t,Ot,!0);else{const e=t;e.pause(),vt(e,t=>{const s=t.property,i=t.target;if(i[o]){const r=i.style,n=t._inlineValue,o=W(n)||n===m;if(3===t._tweenType){const e=i[h];if(o?delete e[s]:e[s]=n,t._renderTransforms)if(Object.keys(e).length){let t=m;for(let s in e)t+=_[s]+e[s]+") ";r.transform=t}else r.removeProperty("transform")}else o?r.removeProperty(F(s)):r[s]=n;e._tail===t&&e.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===m&&t.removeAttribute("style")})}})}return t};class Rt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._elapsedTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=ut(p/120,0),this._fps=120,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<d?d:s,r=ut(p/i,0);this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<d?d:e}requestTick(t){const e=this._scheduledTime,s=this._elapsedTime;if(this._elapsedTime+=t-s,s<e)return 0;const i=this._frameDuration,r=s-e;return this._scheduledTime+=r<i?i:r,1}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Mt={animation:null,update:y},zt=(()=>e?requestAnimationFrame:setImmediate)(),It=(()=>e?cancelAnimationFrame:clearImmediate)();class Yt extends Rt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=B,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=O();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(bt(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Nt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):1),i=r}Mt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(O()),this.reqId=zt(Wt)),this}pause(){if(this.reqId)return this.paused=!0,Vt()}resume(){if(this.paused)return this.paused=!1,vt(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===A.timeScale?1:p)}set speed(t){this._speed=t*A.timeScale,vt(this,t=>t.speed=t._speed)}get timeUnit(){return 1===A.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(A.timeScale!==s){A.timeScale=s,A.tickThreshold=200*s;const t=e?.001:p;this.defaults.duration*=t,this._speed*=t}}get precision(){return A.precision}set precision(t){A.precision=t}}const Xt=(()=>{const t=new Yt(O());return e&&(N.engine=t,i.addEventListener("visibilitychange",()=>{t.pauseOnDocumentHidden&&(i.hidden?t.pause():t.resume())})),t})(),Wt=()=>{Xt._head?(Xt.reqId=zt(Wt),Xt.update()):Xt.reqId=0},Vt=()=>(It(Xt.reqId),Xt.reqId=0,Xt),Ht={_rep:new WeakMap,_add:new Map},Ut=(t,e,s="_rep")=>{const i=Ht[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},qt=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,jt=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=d,t._currentTime=d},Qt=(t,e)=>{const s=t._composition;if(s===r.replace){const s=t._absoluteStartTime;St(e,t,qt,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){jt(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)jt(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=ut(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<d&&jt(i)}let o=!0;if(vt(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;vt(t,t=>{t!==e&&vt(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===r.blend){const e=Ut(t.target,t.property,"_add"),s=(t=>{let e=Mt.animation;return e||(e={duration:d,computeDeltaTime:y,_offset:0,_delay:0,_head:null,_tail:null},Mt.animation=e,Mt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=3===t||2===t?_t(i._fromNumbers):null;let r=i._fromNumber,n=s._tail;for(;n&&n!==i;){if(e)for(let t=0,s=n._numbers.length;t<s;t++)e[t]+=n._numbers[t];else r+=n._number;n=n._prevAdd}i._toNumber=r,i._toNumbers=e}}}),At(e,1,1,0,2)}),e})(Ht._add);let i=e._head;i||(i={...t},i._composition=r.replace,i._updateDuration=d,i._startTime=0,i._numbers=_t(t._fromNumbers),i._number=0,i._next=null,i._prev=null,St(e,i),St(s,i));const n=t._toNumber;if(t._fromNumber=i._fromNumber-n,t._toNumber=0,t._numbers=_t(t._fromNumbers),t._number=0,i._fromNumber=n,t._toNumbers){const e=_t(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}St(e,t,null,"_prevAdd","_nextAdd")}return t},Gt=t=>{const e=t._composition;if(e!==r.none){const s=t.target,i=t.property,n=Ht._rep.get(s)[i];if(bt(n,t,"_prevRep","_nextRep"),e===r.blend){const e=Ht._add,r=e.get(s);if(!r)return;const n=r[i],o=Mt.animation;bt(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){bt(n,a,"_prevAdd","_nextAdd"),bt(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},Zt=(t,e,s)=>{let i=!1;return vt(e,r=>{const n=r.target;if(t.includes(n)){const t=r.property,o=r._tweenType,a=Pt(s,n,o);(!a||a&&a===t)&&(r.parent._tail===r&&3===r._tweenType&&r._prev&&3===r._prev._tweenType&&(r._prev._renderTransforms=1),bt(e,r),Gt(r),i=!0)}},!0),i},Jt=(t,e,s)=>{const i=e||Xt;let r;if(i._hasChildren){let e=0;vt(i,n=>{if(!n._hasChildren)if(r=Zt(t,n,s),r&&!n._head)n.cancel(),bt(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?Jt(t,n,s):n._hasChildren=!1},!0),X(i.iterationDuration)||(i.iterationDuration=e)}else r=Zt(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},Kt=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),te=t=>t._cancelled?(t._hasChildren?vt(t,te):vt(t,t=>{t._composition!==r.none&&Qt(t,Ut(t.target,t.property))}),t._cancelled=0,t):t;let ee=0;class se extends Rt{constructor(t={},e=null,s=0){super(0);const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:h,loopDelay:l,autoplay:c,frameRate:u,playbackRate:p,onComplete:m,onLoop:f,onPause:g,onBegin:_,onBeforeUpdate:v,onUpdate:b}=t;L.current&&L.current.register(this);const S=e?0:Xt._elapsedTime,T=e?e.defaults:A.defaults,w=Y(r)||X(r)?T.delay:+r,x=Y(n)||X(n)?1/0:+n,k=wt(h,T.loop),$=wt(l,T.loopDelay),E=!0===k||k===1/0||k<0?1/0:k+1;let C=0;e?C=s:(Xt.reqId||Xt.requestTick(O()),C=(Xt._elapsedTime-Xt._startTime)*A.timeScale),this.id=X(i)?++ee:i,this.parent=e,this.duration=ft((x+$)*E-$)||d,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=_||T.onBegin,this.onBeforeUpdate=v||T.onBeforeUpdate,this.onUpdate=b||T.onUpdate,this.onLoop=f||T.onLoop,this.onPause=g||T.onPause,this.onComplete=m||T.onComplete,this.iterationDuration=x,this.iterationCount=E,this._autoplay=!e&&wt(c,T.autoplay),this._offset=C,this._delay=w,this._loopDelay=$,this._iterationTime=0,this._currentIteration=0,this._resolve=y,this._running=!1,this._reversed=+wt(o,T.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=wt(a,T.alternate),this._prev=null,this._next=null,this._elapsedTime=S,this._startTime=S,this._lastTime=S,this._fps=wt(u,T.frameRate),this._speed=wt(p,T.playbackRate)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(1).play()}get currentTime(){return ct(ut(this._currentTime,A.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return ut(this._iterationTime,A.precision)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return ct(ut(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return ct(ut(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*ct(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=0){return te(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Nt(this,0,1,t,2),Kt(this),this._hasChildren&&vt(this,Kt),this}init(t=0){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Nt(this,this.duration,1,t,2),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!X(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*Xt._speed);return this._startTime=O()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=d&&!this._hasChildren?Nt(this,d,0,0,2):(this._running||(St(Xt,this),Xt._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,Xt.wake()),this):this}restart(){return this.reset(0).resume()}seek(t,e=0,s=0){te(this),this.completed=!1;const i=this.paused;return this.paused=!0,Nt(this,t+this._delay,~~e,~~s,1),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?rt(u/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?vt(this,t=>t.cancel(),!0):vt(this,Gt),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=gt(t);if(e===s)return this;const i=t/e,r=t<=d;return this.duration=r?d:s,this.iterationDuration=r?d:gt(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Nt(this,0,1,0,1);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(){return this.seek(this.duration).cancel()}then(t=y){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=y};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}function ie(t){const e=I(t)?L.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function re(t){if(W(t))return[];if(!e)return R(t)&&t.flat(1/0)||[t];if(R(t)){const e=t.flat(1/0),s=[];for(let t=0,i=e.length;t<i;t++){const i=e[t];if(!W(i)){const t=ie(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!W(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=ie(t);return s?Array.from(s):[t]}function ne(t){const e=re(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[n]){s[n]=!0;const t=V(s);(s.nodeType||t)&&(s[o]=!0,s[a]=t,s[h]={})}}return e}const oe={deg:1,rad:180/ht,turn:360},ae={},he=(t,e,s,r=!1)=>{const n=e.u,o=e.n;if(1===e.t&&n===s)return e;const a=o+n+s,h=ae[a];if(X(h)||r){let r;if(n in oe)r=o*oe[n]/oe[s];else{const e=100,a=t.cloneNode(),h=t.parentNode,l=h&&h!==i?h:i.body;l.appendChild(a);const c=a.style;c.width=e+n;const d=a.offsetWidth||e;c.width=e+s;const u=d/(a.offsetWidth||e);l.removeChild(a),r=u*o}e.n=r,ae[a]=r}else e.n=h;return e.t,e.u=s,e},le=t=>t,ce=(t=1.68)=>e=>Z(e,+t),de={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},ue=ht/2,pe=2*ht,me={[m]:ce,Quad:ce(2),Cubic:ce(3),Quart:ce(4),Quint:ce(5),Sine:t=>1-tt(t*ue),Circ:t=>1-J(1-t*t),Expo:t=>t?Z(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=Z(2,--s))-1)/11;);return 1/Z(4,3-s)-7.5625*Z((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=ct(+t,1,10),i=ct(+e,d,2),r=i/pe*nt(1/s),n=pe/i;return t=>0===t||1===t?t:-s*Z(2,-10*(1-t))*K((1-t-r)*n)}},fe=(()=>{const t={linear:le,none:le};for(let e in de)for(let s in me){const i=me[s],r=de[e];t[e+s]=s===m||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),ge={linear:le,none:le},_e=t=>{if(ge[t])return ge[t];if(t.indexOf("(")<=-1){const e=de[t]||t.includes("Back")||t.includes("Elastic")?fe[t]():fe[t];return e?ge[t]=e:le}{const e=t.slice(0,-1).split("("),s=fe[e[0]];return s?ge[t]=s(...e[1].split(",")):le}},ye=["steps(","irregular(","linear(","cubicBezier("],ve=t=>{if(I(t))for(let e=0,s=ye.length;e<s;e++)if(P(t,ye[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),le;return Y(t)?t:I(t)?_e(t):le},be={t:0,n:0,u:null,o:null,d:null,s:null},Se={t:0,n:0,u:null,o:null,d:null,s:null},Te={},we={func:null},xe=[null],ke=[null,null],$e={to:null};let Ee,Ce,De=0;class Be extends se{constructor(t,e,s,i,n=!1,o=0,a=0){super(e,s,i);const h=ne(t),l=h.length,c=e.keyframes,u=c?yt(((t,e)=>{const s={};if(R(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(j);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];j(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=wt(e.duration,A.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(j(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,h=n[a-1];const l={to:r[t]};let c=0;for(let t=0;t<a;t++)c+=n[t].duration;1===a&&(l.from=h.to),r.ease&&(l.ease=r.ease),l.duration=o-(a?c:0),n.push(l)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s})(c,e),e):e,{delay:m,duration:f,ease:g,playbackEase:_,modifier:y,composition:v,onRender:b}=u,S=s?s.defaults:A.defaults,T=wt(_,S.playbackEase),w=T?ve(T):null,x=!X(g)&&!X(g.ease),k=x?g.ease:wt(g,w?"linear":S.ease),$=x?g.settlingDuration:wt(f,S.duration),E=wt(m,S.delay),C=y||S.modifier,D=X(v)&&l>=p?r.none:X(v)?S.composition:v,B=this._offset+(s?s._offset:0);x&&(g.parent=this);let L=NaN,N=NaN,F=0,P=0;for(let t=0;t<l;t++){const e=h[t],i=o||t,c=a||l;let p=NaN,m=NaN;for(let t in u)if(j(t)){const o=kt(e,t),a=Pt(t,e,o);let h=u[t];const l=R(h);if(n&&!l&&(ke[0]=h,ke[1]=h,h=ke),l){const t=h.length,e=!M(h[0]);2===t&&e?($e.to=h,xe[0]=$e,Ee=xe):t>2&&e?(Ee=[],h.forEach((t,e)=>{e?1===e?(ke[1]=t,Ee.push(ke)):Ee.push(t):ke[0]=t})):Ee=h}else xe[0]=h,Ee=xe;let f=null,g=null,_=NaN,y=0,v=0;for(let t=Ee.length;v<t;v++){const n=Ee[v];M(n)?Ce=n:($e.to=n,Ce=$e),we.func=null;const h=xt(Ce.to,e,i,c,we);let l;M(h)&&!X(h.to)?(Ce=h,l=h.to):l=h;const u=xt(Ce.from,e,i,c),p=Ce.ease,m=!X(p)&&!X(p.ease),b=m?p.ease:p||k,S=m?p.settlingDuration:xt(wt(Ce.duration,t>1?xt($,e,i,c)/t:$),e,i,c),T=xt(wt(Ce.delay,v?0:E),e,i,c),w=xt(wt(Ce.composition,D),e,i,c),x=z(w)?w:r[w],L=Ce.modifier||C,A=!X(u),N=!X(l),O=R(l),I=O||A&&N,Y=g?y+T:T,V=ut(B+Y,12);P||!A&&!O||(P=1);let H=g;if(x!==r.none){f||(f=Ut(e,a));let t=f._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=V;)if(H=t,t=t._nextRep,t&&t._absoluteStartTime>=V)for(;t;)jt(t),t=t._nextRep}if(I?(Dt(O?xt(l[0],e,i,c):u,be),Dt(O?xt(l[1],e,i,c,we):l,Se),0===be.t&&(H?1===H._valueType&&(be.t=1,be.u=H._unit):(Dt(Et(e,a,o,Te),Lt),1===Lt.t&&(be.t=1,be.u=Lt.u)))):(N?Dt(l,Se):g?Bt(g,Se):Dt(s&&H&&H.parent.parent===s?H._value:Et(e,a,o,Te),Se),A?Dt(u,be):g?Bt(g,be):Dt(s&&H&&H.parent.parent===s?H._value:Et(e,a,o,Te),be)),be.o&&(be.n=Ct(H?H._toNumber:Dt(Et(e,a,o,Te),Lt).n,be.n,be.o)),Se.o&&(Se.n=Ct(be.n,Se.n,Se.o)),be.t!==Se.t)if(3===be.t||3===Se.t){const t=3===be.t?be:Se,e=3===be.t?Se:be;e.t=3,e.s=_t(t.s),e.d=t.d.map(()=>e.n)}else if(1===be.t||1===Se.t){const t=1===be.t?be:Se,e=1===be.t?Se:be;e.t=1,e.u=t.u}else if(2===be.t||2===Se.t){const t=2===be.t?be:Se,e=2===be.t?Se:be;e.t=2,e.s=t.s,e.d=[0,0,0,1]}if(be.u!==Se.u){let t=Se.u?be:Se;t=he(e,t,Se.u?Se.u:be.u,!1)}if(Se.d&&be.d&&Se.d.length!==be.d.length){const t=be.d.length>Se.d.length?be:Se,e=t===be?Se:be;e.d=t.d.map((t,s)=>X(e.d[s])?0:e.d[s]),e.s=_t(t.s)}const U=ut(+S||d,12);let q=Te[a];W(q)||(Te[a]=null);const j={parent:this,id:De++,property:a,target:e,_value:null,_func:we.func,_ease:ve(b),_fromNumbers:_t(be.d),_toNumbers:_t(Se.d),_strings:_t(Se.s),_fromNumber:be.n,_toNumber:Se.n,_numbers:_t(be.d),_number:be.n,_unit:Se.u,_modifier:L,_currentTime:0,_startTime:Y,_delay:+T,_updateDuration:U,_changeDuration:U,_absoluteStartTime:V,_tweenType:o,_valueType:Se.t,_composition:x,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:q,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};x!==r.none&&Qt(j,f),isNaN(_)&&(_=j._startTime),y=ut(Y+U,12),g=j,F++,St(this,j)}(isNaN(N)||_<N)&&(N=_),(isNaN(L)||y>L)&&(L=y),3===o&&(p=F-v,m=F)}if(!isNaN(p)){let t=0;vt(this,e=>{t>=p&&t<m&&(e._renderTransforms=1,e._composition===r.blend&&vt(Mt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}l||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),N?(vt(this,t=>{t._startTime-t._delay||(t._delay-=N),t._startTime-=N}),L-=N):N=0,L||(L=d,this.iterationCount=0),this.targets=h,this.duration=L===d?d:ft((L+this._loopDelay)*this.iterationCount-this._loopDelay)||d,this.onRender=b||S.onRender,this._ease=w,this._delay=N,this.iterationDuration=L,!this._autoplay&&P&&this.onRender(this)}stretch(t){const e=this.duration;if(e===gt(t))return this;const s=t/e;return vt(this,t=>{t._updateDuration=gt(t._updateDuration*s),t._changeDuration=gt(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return vt(this,t=>{const e=t._func;if(e){const s=Et(t.target,t.property,t._tweenType);Dt(s,Lt),Dt(e(),Se),t._fromNumbers=_t(Lt.d),t._fromNumber=Lt.n,t._toNumbers=_t(Se.d),t._strings=_t(Se.s),t._toNumber=Se.o?Ct(Lt.n,Se.n,Se.o):Se.n}}),this.duration===d&&this.restart(),this}revert(){return super.revert(),Ot(this)}then(t){return super.then(t)}}const Le={_head:null,_tail:null},Ae=(t,e,s)=>{let i,r=Le._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,h=!s||r.parent===s;if(o&&a&&h){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),bt(Le,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},Ne=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Ae(e,s),St(Le,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>{Ae(e,s,t)};return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function Fe(t,e,s){const i=ne(t);if(!i.length)return;const[r]=i,n=kt(r,e),o=Pt(e,r,n);let a=Et(r,o);if(X(s))return a;if(Dt(a,Lt),0===Lt.t||1===Lt.t){if(!1===s)return Lt.n;{const t=he(r,Lt,s,!1);return`${ut(t.n,A.precision)}${t.u}`}}}const Pe=(t,e)=>{if(!X(e))return e.duration=d,e.composition=wt(e.composition,r.none),new Be(t,e,null,0,!0).resume()},Oe=(t,e,s)=>{const i=re(t);for(let t=0,r=i.length;t<r;t++)Ae(i[t],s,e&&e.controlAnimation&&e);return Jt(i,e,s),i},Re=(t,e)=>{let s=t.iterationDuration;if(s===d&&(s=0),X(e))return s;if(z(+e))return+e;const i=e,r=t?t.labels:null,n=!W(r),o=((t,e)=>{if(P(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}})(t,i),a=!X(o),h=C.exec(i);if(h){const t=h[0],e=i.split(t),l=n&&e[0]?r[e[0]]:s,c=a?o:n?l:s,d=+e[1];return Ct(c,d,t[0])}return a?o:n?X(r[i])?s:r[i]:s};function Me(t,e,s,i,r,n){const o=z(t.duration)&&t.duration<=d?s-d:s;Nt(e,o,1,1,1);const a=i?new Be(i,t,e,o,!1,r,n):new se(t,e,o);return a.init(1),St(e,a),vt(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=function(t){return ft((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||d}(e),e}class ze extends se{constructor(t={}){super(t,null,0),this.duration=0,this.labels={};const e=t.defaults,s=A.defaults;this.defaults=e?yt(e,s):s,this.onRender=t.onRender||s.onRender;const i=wt(t.playbackEase,s.playbackEase);this._ease=i?ve(i):null,this.iterationDuration=0}add(t,e,s){const i=M(e),r=M(t);if(i||r){if(this._hasChildren=!0,i){const i=e;if(Y(s)){const e=s,r=re(t),n=this.duration,o=this.iterationDuration,a=i.id;let h=0;const l=r.length;r.forEach(t=>{const s={...i};this.duration=n,this.iterationDuration=o,X(a)||(s.id=a+"-"+h),Me(s,this,Re(this,e(t,h,l,this)),t,h,l),h++})}else Me(i,this,Re(this,s),t)}else Me(t,this,Re(this,e));return this.init(1)}}sync(t,e){if(X(t)||t&&X(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return this.add(t,{currentTime:[0,s],duration:s,ease:"linear"},e)}set(t,e,s){return X(e)?this:(e.duration=d,e.composition=r.replace,this.add(t,e,s))}call(t,e){return X(t)||t&&!Y(t)?this:this.add({duration:0,onComplete:()=>t(this)},e)}label(t,e){return X(t)||t&&!I(t)||(this.labels[t]=Re(this,e)),this}remove(t,e){return Jt(re(t),this,e),this}stretch(t){const e=this.duration;if(e===gt(t))return this;const s=t/e,i=this.labels;vt(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return vt(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),vt(this,t=>t.revert,!0),Ot(this)}then(t){return super.then(t)}}class Ie{constructor(t,e){L.current&&L.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},n={v:1,autoplay:!1},o={};if(this.targets=[],this.animations={},this.callbacks=null,!X(t)&&!X(e)){for(let t in e){const s=e[t];j(t)?o[t]=s:P(t,"on")?n[t]=s:i[t]=s}this.callbacks=new Be({v:0},n);for(let e in o){const s=o[e],n=M(s);let a={},h="+=0";if(n){const t=s.unit;I(t)&&(h+=t)}else a.duration=s;a[e]=n?yt({to:h},s):h;const l=yt(i,a);l.composition=r.replace,l.autoplay=!1;const c=this.animations[e]=new Be(t,l,null,0,!1).init();this.targets.length||this.targets.push(...c.targets),this[e]=(t,e,s)=>{const i=c._head;if(X(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return vt(c,e=>{if(R(t))for(let s=0,i=t.length;s<i;s++)X(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;X(s)||(e._ease=ve(s)),e._currentTime=0}),X(e)||c.stretch(e),c.reset(1).resume(),this}}}}revert(){for(let t in this.animations)this[t]=y,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const Ye=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i);var Xe=Object.freeze({__proto__:null,clamp:ct,damp:(t,e,s,i)=>i?1===i?e:mt(t,e,1-Math.exp(-i*s*.1)):t,degToRad:t=>t*Math.PI/180,lerp:mt,mapRange:Ye,padEnd:(t,e,s)=>`${t}`.padEnd(e,s),padStart:(t,e,s)=>`${t}`.padStart(e,s),radToDeg:t=>180*t/Math.PI,round:ut,roundPad:(t,e)=>(+t).toFixed(e),snap:pt,wrap:(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e});const We=10*p;class Ve{constructor(t={}){const e=!X(t.bounce)||!X(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/p,this.maxIterations=this.maxDuration/this.timeStep/p,this.bn=ct(wt(t.bounce,.5),-1,1),this.pd=ct(wt(t.duration,628),10*A.timeScale,We*A.timeScale),this.m=ct(wt(t.mass,1),1,We),this.s=ct(wt(t.stiffness,100),d,We),this.d=ct(wt(t.damping,10),d,We),this.v=ct(wt(t.velocity,0),-1e4,We),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||y,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?st(-n*e*s)*(1*tt(i*n)+r*K(i*n)):1===e?(1+r*n)*st(-n*s):((1+r)*st((-e*s+i)*n)+(1-r)*st((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===A.timeScale?this.pd/p:this.pd;this.m=1,this.v=0,this.s=Z(2*ht/t,2),this.bn>=0?this.d=4*(1-this.bn)*ht/t:this.d=4*ht/(t*(1+this.bn)),this.s=ut(ct(this.s,d,We),3),this.d=ut(ct(this.d,d,300),3)}calculateBDFromSD(){const t=2*ht/J(this.s);this.pd=t*(1===A.timeScale?p:1);const e=this.d/(2*J(this.s));this.bn=e<=1?1-this.d*t/(4*ht):4*ht/(this.d*t)-1,this.bn=ut(ct(this.bn,-1,1),3),this.pd=ut(ct(this.pd,10*A.timeScale,We*A.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,h=this.w0=ct(J(o/r),d,p),l=this.zeta=n/(2*J(o*r));l<1?(this.wd=h*J(1-l*l),this.b=(l*h-a)/this.wd):1===l?(this.wd=0,this.b=-a+h):(this.wd=h*J(l*l-1),this.b=(l*h-a)/this.wd);let c=0,u=0,m=0;for(;u<=t&&m<=e;)et(1-this.solve(c))<s?u++:u=0,this.solverDuration=c,c+=i,m++;this.settlingDuration=ut(this.solverDuration*p,0)*A.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=ct(wt(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=ct(wt(t,1),10*A.timeScale,We*A.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=ct(wt(t,100),d,We),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=ct(wt(t,10),d,We),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=ct(wt(t,1),1,We),this.compute()}get velocity(){return this.v}set velocity(t){this.v=ct(wt(t,0),-1e4,We),this.compute()}}const He=t=>new Ve(t),Ue=t=>(console.warn("createSpring() is deprecated use spring() instead"),new Ve(t)),qe=t=>{t.cancelable&&t.preventDefault()};class je{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:y,remove:y}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class Qe{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,s=0;for(;e&&e!==i;)t(e,s),e=e.parentElement,s++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const Ge=(t,e)=>t&&Y(t)?t(e):t;let Ze=0;class Je{constructor(t,e={}){if(!t)return;L.current&&L.current.register(this);const r=e.x,n=e.y,o=e.trigger,a=e.modifier,h=e.releaseEase,l=h&&ve(h),c=!X(h)&&!X(h.ease),d=M(r)&&!X(r.mapTo)?r.mapTo:"translateX",p=M(n)&&!X(n.mapTo)?n.mapTo:"translateY",m=Ge(e.container,this);this.containerArray=R(m)?m:null,this.$container=m&&!this.containerArray?re(m)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.$target=M(t)?new je(t):re(t)[0],this.$trigger=re(o||t)[0],this.fixed="fixed"===Fe(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=c?h:He({mass:wt(e.releaseMass,1),stiffness:wt(e.releaseStiffness,80),damping:wt(e.releaseDamping,20)}),this.releaseYSpring=c?h:He({mass:wt(e.releaseMass,1),stiffness:wt(e.releaseStiffness,80),damping:wt(e.releaseDamping,20)}),this.releaseEase=l||fe.outQuint,this.hasReleaseSpring=c,this.onGrab=e.onGrab||y,this.onDrag=e.onDrag||y,this.onRelease=e.onRelease||y,this.onUpdate=e.onUpdate||y,this.onSettle=e.onSettle||y,this.onSnap=e.onSnap||y,this.onResize=e.onResize||y,this.onAfterResize=e.onAfterResize||y,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),X(r)||!0===r)f[d]=0;else if(M(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[d]=e}else!1===r&&(f[d]=0,this.disabled[0]=1);if(X(n)||!0===n)f[p]=0;else if(M(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[p]=e}else!1===n&&(f[p]=0,this.disabled[1]=1);this.animate=new Ie(this.$target,f),this.xProp=d,this.yProp=p,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-u,u,u,-u],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=O(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new Qe(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new se({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new se({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!X(m),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?d:p,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=at(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new se({autoplay:!1,duration:150*A.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=e,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),M(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=O(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,h=this.maxVelocity,l=this.velocityStackIndex;n[l]=ut(ct(J(t*t+e*e)/r*o,a,h),5);const c=ot(n[0],n[1],n[2]);return this.velocity=c,this.velocityStackIndex=(l+1)%3,c}setX(t,e=!1){if(this.disabled[0])return;const s=ut(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=pt(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=ut(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=pt(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return ut(this.animate[this.xProp](),A.precision)}set x(t){this.setX(t,!1)}get y(){return ut(this.animate[this.yProp](),A.precision)}set y(t){this.setY(t,!1)}get progressX(){return Ye(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(Ye(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return Ye(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(Ye(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=ut(this.useWin?s.scrollX:this.$container.scrollLeft,0),e=ut(this.useWin?s.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=e,this.scrollBounds[0]=e-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=e-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const e=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=s.innerWidth,h=this.window[1]=s.innerHeight,l=this.useWin,c=t.scrollWidth,d=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,_]=this.containerPadding;this.dragArea[0]=l?0:p.left,this.dragArea[1]=l?0:p.top,this.scrollView[0]=l?ct(c,a,c):c,this.scrollView[1]=l?ct(d,h,d):d,this.updateScrollCoords();const{width:y,height:v,left:b,top:S,right:T,bottom:w}=t.getBoundingClientRect();this.dragArea[2]=ut(l?ct(y,a,a):y,0),this.dragArea[3]=ut(l?ct(v,h,h):v,0);const x=Fe(t,"overflow"),k="visible"===x,$="hidden"===x;if(this.canScroll=!u&&this.contained&&(t===i.body&&k||!$&&!k)&&(c>this.dragArea[2]+_-f||d>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!R(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?l?0:t.scrollLeft:0,o=i?l?0:t.scrollTop:0,c=i?this.scrollView[0]-n-y:0,d=i?this.scrollView[1]-o-v:0;this.targetBounds[0]=ut(r.top+s-(l?0:S),0),this.targetBounds[1]=ut(r.right+e-(l?a:T),0),this.targetBounds[2]=ut(r.bottom+s-(l?h:w),0),this.targetBounds[3]=ut(r.left+e-(l?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+_):(this.containerBounds[0]=-ut(r.top-(u?ct(S,0,h):S)+o-m,0),this.containerBounds[1]=-ut(r.right-(u?ct(T,0,a):T)-c+f,0),this.containerBounds[2]=-ut(r.bottom-(u?ct(w,0,h):w)-d+g,0),this.containerBounds[3]=-ut(r.left-(u?ct(b,0,a):b)+n-_,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(e,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,h]=this.disabled,l=!a&&e<o||!a&&e>r,c=!h&&s<i||!h&&s>n;return l&&!c?1:!l&&c?2:l&&c?3:0}refresh(){const t=this.parameters,e=t.x,r=t.y,n=Ge(t.container,this),o=Ge(t.containerPadding,this)||0,a=R(o)?o:[o,o,o,o],h=this.x,l=this.y,c=Ge(t.cursor,this),d={onHover:"grab",onGrab:"grabbing"};if(c){const{onHover:t,onGrab:e}=c;t&&(d.onHover=t),e&&(d.onGrab=e)}this.containerArray=R(n)?n:null,this.$container=n&&!this.containerArray?re(n)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=wt(a,[0,0,0,0]),this.containerFriction=ct(wt(Ge(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=ct(wt(Ge(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=Ge(M(e)&&!X(e.snap)?e.snap:t.snap,this),this.snapY=Ge(M(r)&&!X(r.snap)?r.snap:t.snap,this),this.scrollSpeed=wt(Ge(t.scrollSpeed,this),1.5),this.scrollThreshold=wt(Ge(t.scrollThreshold,this),20),this.dragSpeed=wt(Ge(t.dragSpeed,this),1),this.minVelocity=wt(Ge(t.minVelocity,this),0),this.maxVelocity=wt(Ge(t.maxVelocity,this),50),this.velocityMultiplier=wt(Ge(t.velocityMultiplier,this),1),this.cursor=!1!==c&&d,this.updateBoundingValues();const[u,p,m,f]=this.containerBounds;this.setX(ct(h,f,p),!0),this.setY(ct(l,u,m),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],h=this.scroll.x,l=this.scroll.y,c=this.$container.scrollWidth,d=this.$container.scrollHeight,u=this.useWin?ct(c,this.window[0],c):c,p=this.useWin?ct(d,this.window[1],d):d,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,_=this.scrollThreshold,[y,v]=this.coords,[b,S,T,w]=this.scrollBounds,x=ut(ct((v-b+t)/_,-1,0)*g,0),k=ut(ct((y-S-e)/_,0,1)*g,0),$=ut(ct((v-T-s)/_,0,1)*g,0),E=ut(ct((y-w+i)/_,-1,0)*g,0);if(x||$||E||k){const[t,e]=this.disabled;let s=h,i=l;t||(s=ut(ct(h+(E||k),0,r-o),0),this.coords[0]-=h-s),e||(i=ut(ct(l+(x||$),0,n-a),0),this.coords[1]-=l-i),this.useWin?this.$scrollContainer.scrollBy(-(h-s),-(l-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,h,l]=this.pointer;this.coords[0]+=(r-h)*this.dragSpeed,this.coords[1]+=(n-l)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[c,d]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(c>e?e+(c-e)*m:c<i?i+(c-i)*m:c,!1),this.setY(d>s?s+(d-s)*m:d<t?t+(d-t)*m:d,!1),this.computeVelocity(r-h,n-l),this.angle=at(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return Jt([this],null,"x"),Jt([this],null,"y"),Jt([this],null,"progressX"),Jt([this],null,"progressY"),Jt([this.scroll]),Jt([this.overshootCoords]),this}scrollInView(t,e=0,s=fe.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[h,l,c,d]=o,p=ut(ct(r-h,-u,0),0),m=ut(ct(i-l,0,u),0),f=ut(ct(r-c,0,u),0),g=ut(ct(i-d,-u,0),0);new Be(n,{x:ut(n.x+(g?g-e:m?m+e:0),0),y:ut(n.y+(p?p-e:f?f+e:0),0),duration:X(t)?350*A.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Pe(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=fe.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,h]=this.containerPadding,l=this.scroll.y-this.targetBounds[0]+n+e,c=this.scroll.x-this.targetBounds[1]-o-e,d=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+h+e,p=this.isOutOfBounds([l,c,d,u],i,r);if(p){const[e,n]=this.disabled,o=ct(pt(i,this.snapX),u,c),a=ct(pt(r,this.snapY),l,d),h=X(t)?350*A.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,h,s),n||2!==p&&3!==p||this.animate[this.yProp](a,h,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const s=t.changedTouches,r=s?s[0].clientX:t.clientX,n=s?s[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[h,l,c,d]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>l?l+(p-l)/u:p<d?d+(p-d)/u:p:p,this.coords[1]=this.coords[3]=u?m>c?c+(m-c)/u:m<h?h+(m-h)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Fe(this.$target,"zIndex",!1);Ze=(f>Ze?f:Ze)+1,this.targetStyles=Pe(this.$target,{zIndex:Ze}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Pe(i.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,fe.out(3)),this.onGrab(this),i.addEventListener("touchmove",this),i.addEventListener("touchend",this),i.addEventListener("touchcancel",this),i.addEventListener("mousemove",this),i.addEventListener("mouseup",this),i.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let h=t.target,l=!1,c=!1,d=!1;for(;e&&h&&h!==this.$trigger;){const t=Fe(h,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=h;if(e>s){d=!0,l=t<=3,c=t>=e-s-3;break}}h=h.parentElement}d&&(!l&&!c||l&&a<0||c&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(qe(t),this.triggerStyles||(this.triggerStyles=Pe(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",qe,{passive:!1}),this.$trigger.addEventListener("touchmove",qe,{passive:!1}),this.$trigger.addEventListener("touchend",qe),(this.dragged||!this.disabled[0]&&et(o)>3||!this.disabled[1]&&et(a)>3)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[s,n,o,a,h,l]=this.pointer,[c,d,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,_=this.releaseYSpring,y=this.releaseEase,v=this.hasReleaseSpring,b=this.overshootCoords,S=this.x,T=this.y,w=this.computeVelocity(s-h,n-l),x=this.angle=at(n-a,s-o),k=150*w,$=(1-this.releaseContainerFriction)*this.dragSpeed,E=S+tt(x)*k,C=T+K(x)*k,D=E>d?d+(E-d)*$:E<p?p+(E-p)*$:E,B=C>u?u+(C-u)*$:C<c?c+(C-c)*$:C,L=this.destX=ct(ut(pt(D,this.snapX),5),p,d),N=this.destY=ct(ut(pt(B,this.snapY),5),c,u),F=this.isOutOfBounds(this.containerBounds,E,C);let P=0,O=0,R=y,M=y,z=0;if(b.x=S,b.y=T,!t){const t=L===d?S>d?-1:1:S<p?-1:1,s=ut(S-L,0);g.velocity=e&&v?s?k*t/et(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=g;P=S===L?0:v?r:r-n*A.timeScale,v&&(R=i),P>z&&(z=P)}if(!e){const e=N===u?T>u?-1:1:T<c?-1:1,s=ut(T-N,0);_.velocity=t&&v?s?k*e/et(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=_;O=T===N?0:v?r:r-n*A.timeScale,v&&(M=i),O>z&&(z=O)}if(!v&&F&&$&&(P||O)){const t=r.blend;new Be(b,{x:{to:D,duration:.65*P},y:{to:B,duration:.65*O},ease:y,composition:t}).init(),new Be(b,{x:{to:L,duration:P},y:{to:N,duration:O},ease:y,composition:t}).init(),this.overshootTicker.stretch(ot(P,O)).restart()}else t||this.animate[this.xProp](L,P,R),e||this.animate[this.yProp](N,O,M);this.scrollInView(z,this.scrollThreshold,y);let I=!1;L!==m&&(this.snapped[0]=L,this.snapX&&(I=!0)),N!==f&&this.snapY&&(this.snapped[1]=N,this.snapY&&(I=!0)),I&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",qe),this.$trigger.removeEventListener("touchmove",qe),this.$trigger.removeEventListener("touchend",qe),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Pe(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":qe(t)}}}const Ke=(t=y)=>new se({duration:1*A.timeScale,onComplete:t},null,0).resume(),ts=t=>{let e;return(...s)=>{let i,r,n,o;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,e.revert());const a=t(...s);return a&&!Y(a)&&a.revert&&(e=a),X(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r),a||y}};class es{constructor(t={}){L.current&&L.current.register(this);const e=t.root;let r=i;e&&(r=e.current||e.nativeElement||re(e)[0]||i);const n=t.defaults,o=A.defaults,a=t.mediaQueries;if(this.defaults=n?yt(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const e=s.matchMedia(a[t]);this.mediaQueryLists[t]=e,e.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=L.current,s=L.root,i=A.defaults;L.current=this,L.root=this.root,A.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return L.current=e,L.root=s,A.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);Y(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,Y(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);Y(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,Y(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);Y(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(Y(s))return s(this);const i=ts(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,h=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;h--;)i[h](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const ss=(t,e)=>t&&Y(t)?t(e):t,is=new Map;class rs{constructor(t){this.element=t,this.useWin=this.element===i.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new se({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;vt(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new se({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=ut(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new se({autoplay:!1,duration:250*A.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new se({autoplay:!1,duration:500*A.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?s:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,e=this.element;this.scrollX=ut(t?s.scrollX:e.scrollLeft,0),this.scrollY=ut(t?s.scrollY:e.scrollTop,0)}updateWindowBounds(){this.winWidth=s.innerWidth,this.winHeight=(()=>{const t=i.createElement("div");i.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return i.body.removeChild(t),e})()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left}this.width=s,this.height=i}refreshScrollObservers(){vt(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),vt(this,t=>{t.refresh(),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?s:this.element).removeEventListener("scroll",this),is.delete(this.element)}}const ns=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:h,u:l}=Dt(a,Lt);let c=h;return"%"===l?c=h/100*s:l&&(c=he(t,Lt,"px",!0).n),o&&i<0&&(c+=i),n&&r>0&&(c+=r),c},os=(t,e,s,i,r)=>{let n;if(I(e)){const o=C.exec(e);if(o){const a=o[0],h=a[0],l=e.split(a),c="min"===l[0],d="max"===l[0],u=ns(t,l[0],s,i,r),p=ns(t,l[1],s,i,r);if(c){const e=Ct(ns(t,"min",s),p,h);n=e<u?u:e}else if(d){const e=Ct(ns(t,"max",s),p,h);n=e>u?u:e}else n=Ct(u,p,h)}else n=ns(t,e,s,i,r)}else n=e;return ut(n,0)},as=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[o]){e=i;break}}return e};let hs=0;const ls=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class cs{constructor(t={}){L.current&&L.current.register(this);const e=wt(t.sync,"play pause"),s=e?ve(e):null,r=e&&("linear"===e||e===le),n=e&&!(s===le&&!r),o=e&&(z(e)||!0===e||r),a=e&&I(e)&&!n&&!o,h=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,l=a&&h.length>2;this.index=hs++,this.id=X(t.id)?this.index:t.id,this.container=(t=>{const e=t&&re(t)[0]||i.body;let s=is.get(e);return s||(s=new rs(e),is.set(e,s)),s})(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!h,this.syncEase=n?s:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=h&&!l&&h[0]?h[0]:y,this.onSyncLeave=h&&!l&&h[1]?h[1]:y,this.onSyncEnterForward=h&&l&&h[0]?h[0]:y,this.onSyncLeaveForward=h&&l&&h[1]?h[1]:y,this.onSyncEnterBackward=h&&l&&h[2]?h[2]:y,this.onSyncLeaveBackward=h&&l&&h[3]?h[3]:y,this.onEnter=t.onEnter||y,this.onLeave=t.onLeave||y,this.onEnterForward=t.onEnterForward||y,this.onLeaveForward=t.onLeaveForward||y,this.onEnterBackward=t.onEnterBackward||y,this.onLeaveBackward=t.onLeaveBackward||y,this.onUpdate=t.onUpdate||y,this.onSyncComplete=t.onSyncComplete||y,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=wt(t.debug,!1),this._next=null,this._prev=null,St(this.container,this),Ke(()=>{if(!this.reverted){if(!this.target){const e=re(t.target)[0];this.target=e||i.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,X(t)||(t.persist=!0),!this._params.target)){let e;X(t.targets)?vt(t,t=>{t.targets&&!e&&(e=as(t))}):e=as(t),this.target=e||i.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:ut(ct(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=wt(ss(t.repeat,this),!0),this.horizontal="x"===wt(ss(t.axis,this),"y"),this.enter=wt(ss(t.enter,this),"end start"),this.leave=wt(ss(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,s=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=i.createElement("div"),n=i.createElement("div"),o=i.createElement("div"),a=ls[this.index%ls.length],h=t.useWin,l=h?t.winWidth:t.width,c=h?t.winHeight:t.height,d=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,_=e?g:15,y=e?60:g,v=e?y:_,b=e?"repeat-x":"repeat-y",S=t=>e?"0px "+t+"px":t+"px 2px",T=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,w=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${w("absolute",m,f,e?d:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${w("sticky",0,0,e?l:g,e?g:c)}`,s||(n.style.cssText+=`background:\n ${T("#FFFF")}${S(g-10)} / 100px 100px ${b},\n ${T("#FFF8")}${S(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${w("relative",0,0,e?d:g,e?g:u)}`,s||(o.style.cssText+=`background:\n ${T("#FFFF")}${S(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${T("#FFF8")}${S(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const x=[" enter: "," leave: "];this.coords.forEach((t,s)=>{const r=s>1,h=(r?0:this.offset)+t,m=s%2,f=h<v,g=h>(r?e?l:c:e?d:u)-v,b=(r?m&&!f:!m&&!f)||g,S=i.createElement("div"),T=i.createElement("div"),k=e?b?"right":"left":b?"bottom":"top",$=b?(e?y:_)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;T.innerHTML=`${this.id}${x[m]}${this.thresholds[s]}`,S.style.cssText=`${w("absolute",0,0,y,_)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${k}: 2px solid ${a};\n `,T.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${_};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,S.appendChild(T);let E=h-$+(e?1:0);S.style[e?"left":"top"]=`${E}px`,(r?n:o).appendChild(S)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),s||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Fe(t.element,"position")&&(this.debugStyles=Pe(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,s=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0)),a.parentElement;a&&a!==s.element&&a!==i.body;){const e="sticky"===Fe(a,"position")&&Pe(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const h=e.getBoundingClientRect(),l=r?h.left+s.scrollX-s.left:h.top+s.scrollY-s.top,c=r?h.width:h.height,d=r?s.width:s.height,u=(r?s.scrollWidth:s.scrollHeight)-d,p=this.enter,m=this.leave;let f="start",g="end",_="end",y="start";if(I(p)){const t=p.split(" ");_=t[0],f=t.length>1?t[1]:f}else if(M(p)){const t=p;X(t.container)||(_=t.container),X(t.target)||(f=t.target)}else z(p)&&(_=p);if(I(m)){const t=m.split(" ");y=t[0],g=t.length>1?t[1]:g}else if(M(m)){const t=m;X(t.container)||(y=t.container),X(t.target)||(g=t.target)}else z(m)&&(y=m);const v=os(e,f,c),b=os(e,g,c),S=v+l-d,T=b+l-u,w=os(e,_,d,S,T),x=os(e,y,d,S,T),k=v+l-w,$=b+l-x,E=$-k;this.offset=l,this.offsetStart=k,this.offsetEnd=$,this.distance=E<=0?0:E,this.thresholds=[f,g,_,y],this.coords=[v,b,w,x],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,h=a<=this.offsetStart,l=a>=this.offsetEnd,c=!h&&!l,d=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&d,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(h&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&z(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=ut(mt(e,g,mt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(c&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(c&&(this.isInView=!0),this.forceEnter&&this.hasEntered?c&&(this.forceEnter=!1):(p&&c&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(c||!c&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!c&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return bt(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const ds=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,us=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?le:r=>0===r||1===r?r:ds(((t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=ds(r,e,s)-t,i>0?o=r:n=r}while(et(i)>1e-7&&++a<100);return r})(r,t,s),e,i),ps=(t=10,e)=>{const s=e?it:rt;return e=>s(ct(e,0,1)*t)*(1/t)},ms=(...t)=>{const e=t.length;if(!e)return le;const s=e-1,i=t[0],r=t[s],n=[0],o=[G(i)];for(let e=1;e<s;e++){const i=t[e],r=I(i)?i.trim().split(" "):[i],a=r[0],h=r[1];n.push(X(h)?e/s:G(h)/100),o.push(G(a))}return o.push(G(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},fs=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(ct(o,r,1))}return s.push(1),ms(...s)};var gs=Object.freeze({__proto__:null,Spring:Ve,createSpring:Ue,cubicBezier:us,eases:fe,irregular:fs,linear:ms,spring:He,steps:ps});const _s=Xe,ys={},vs=t=>(...e)=>{const s=t(...e);return new Proxy(y,{apply:(t,e,[i])=>s(i),get:(t,e)=>vs((...t)=>{const i=ys[e](...t);return t=>i(s(t))})})},bs=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?vs(((t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s))(e,s)):e)(...t);return ys[t]||(ys[t]=i),i},Ss=bs("roundPad",_s.roundPad),Ts=bs("padStart",_s.padStart),ws=bs("padEnd",_s.padEnd),xs=bs("wrap",_s.wrap),ks=bs("mapRange",_s.mapRange),$s=bs("degToRad",_s.degToRad),Es=bs("radToDeg",_s.radToDeg),Cs=bs("snap",_s.snap),Ds=bs("clamp",_s.clamp),Bs=bs("round",_s.round),Ls=bs("lerp",_s.lerp,1),As=bs("damp",_s.damp,1),Ns=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let Fs=0;const Ps=(t,e=0,s=1,i=0)=>{let r=void 0===t?Fs++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},Os=t=>t[Ns(0,t.length-1)],Rs=t=>{let e,s,i=t.length;for(;i;)s=Ns(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},Ms=(t,e={})=>{let s=[],i=0;const r=e.from,n=e.reversed,o=e.ease,a=!X(o),h=a&&!X(o.ease)?o.ease:a?ve(o):null,l=e.grid,c=e.axis,d=e.total,u=X(r)||0===r||"first"===r,p="center"===r,f="last"===r,g="random"===r,_=R(t),y=e.use,v=G(_?t[0]:t),b=_?G(t[1]):0,S=k.exec((_?t[1]:t)+m),T=e.start||0+(_?v:0);let w=u?0:z(r)?r:0;return(t,r,o,a)=>{const[u]=ne(t),m=X(d)?o:d,x=!X(y)&&(Y(y)?y(u,r,m):Et(u,y)),k=z(x)||I(x)&&z(+x)?+x:r;if(p&&(w=(m-1)/2),f&&(w=m-1),!s.length){for(let t=0;t<m;t++){if(l){const e=p?(l[0]-1)/2:w%l[0],i=p?(l[1]-1)/2:rt(w/l[0]),r=e-t%l[0],n=i-rt(t/l[0]);let o=J(r*r+n*n);"x"===c&&(o=-r),"y"===c&&(o=-n),s.push(o)}else s.push(et(w-t));i=ot(...s)}h&&(s=s.map(t=>h(t/i)*i)),n&&(s=s.map(t=>c?t<0?-1*t:-t:et(i-t))),g&&(s=Rs(s))}const $=_?(b-v)/i:v;let E=(a?Re(a,X(e.start)?a.iterationDuration:T):T)+($*ut(s[k],2)||0);return e.modifier&&(E=e.modifier(E)),S&&(E=`${E}${S[2]}`),E}};var zs=Object.freeze({__proto__:null,$:ne,clamp:Ds,cleanInlineStyles:Ot,createSeededRandom:Ps,damp:As,degToRad:$s,get:Fe,keepTime:ts,lerp:Ls,mapRange:ks,padEnd:ws,padStart:Ts,radToDeg:Es,random:Ns,randomPick:Os,remove:Oe,round:Bs,roundPad:Ss,set:Pe,shuffle:Rs,snap:Cs,stagger:Ms,sync:Ke,wrap:xs});const Is=t=>{const e=re(t)[0];return e&&V(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},Ys=(t,e,s=0)=>t.getPointAtLength(e+s>=1?e+s:0),Xs=(t,e)=>s=>{const i=+t.getTotalLength(),r=s[a],n=t.getCTM();return{from:0,to:i,modifier:s=>{if("a"===e){const e=Ys(t,s,-1),i=Ys(t,s,1);return 180*at(i.y-e.y,i.x-e.x)/ht}{const i=Ys(t,s,0);return"x"===e?r||!n?i.x:i.x*n.a+i.y*n.c+n.e:r||!n?i.y:i.x*n.b+i.y*n.d+n.f}}}},Ws=t=>{const e=Is(t);if(e)return{translateX:Xs(e,"x"),translateY:Xs(e,"y"),rotate:Xs(e,"a")}},Vs=(t,e=0,s=0)=>re(t).map(t=>((t,e,s)=>{const i=p,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const h=new Proxy(t,{get(t,e){const s=t[e];return e===c?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],h=+s[1],l=(t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(J(s.a*s.a+s.b*s.b)+J(s.c*s.c+s.d*s.d))/2)}return e})(o),c=-1e3*r*l,d=h*i*l+c,u=i*l+(0===r&&1===h||1===r&&0===h?0:10*l)-d;if("butt"!==n){const e=r===h?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${c}`),t.setAttribute("stroke-dasharray",`${d} ${u}`)}return Reflect.apply(s,t,e)}:Y(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),h.setAttribute("draw",`${e} ${s}`)),h})(t,e,s)),Hs=(t,e=.33)=>s=>{const i=Is(t);if(!i)return;const r="path"===s.tagName,n=r?" ":",",o=s[l];o&&s.setAttribute(r?"d":"points",o);let a="",h="";if(e){const t=s.getTotalLength(),o=i.getTotalLength(),l=Math.max(Math.ceil(t*e),Math.ceil(o*e));for(let e=0;e<l;e++){const c=e/(l-1),d=s.getPointAtLength(t*c),u=i.getPointAtLength(o*c),p=r?0===e?"M":"L":"";a+=p+ut(d.x,3)+n+d.y+" ",h+=p+ut(u.x,3)+n+u.y+" "}}else a=s.getAttribute(r?"d":"points"),h=i.getAttribute(r?"d":"points");return s[l]=h,[a,h]};var Us=Object.freeze({__proto__:null,createDrawable:Vs,createMotionPath:Ws,morphTo:Hs});const qs="undefined"!=typeof Intl&&Intl.Segmenter,js=/\{value\}/g,Qs=/\{i\}/g,Gs=/(\s+)/,Zs=/^\s+$/,Js="line",Ks="word",ti="char",ei="data-line";let si=null,ii=null,ri=null;const ni=t=>t.isWordLike||" "===t.segment||z(+t.segment),oi=t=>t.setAttribute("aria-hidden","true"),ai=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],hi={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},li=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&li(e)}},ci=(t,e,s)=>{const i=t.getAttribute(ei);(null!==i&&+i!==e||"BR"===t.tagName)&&s.add(t);let r=t.childElementCount;for(;r--;)ci(t.children[r],e,s);return s},di=(t,e={})=>{let s="";const i=I(e.class)?` class="${e.class}"`:"",r=wt(e.clone,!1),n=wt(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},ui=(t,e,s,i,r,n,o,a,h)=>{const l=r===Js,c=r===ti,d=`_${r}_`,u=Y(t)?t(s):t,p=l?"block":"inline-block";ri.innerHTML=u.replace(js,`<i class="${d}"></i>`).replace(Qs,`${c?h:l?o:a}`);const m=ri.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,_=m.querySelectorAll(`i.${d}`),y=_.length;if(y){f.style.display=p,g.style.display=p,g.setAttribute(ei,`${o}`),l||(g.setAttribute("data-word",`${a}`),c&&g.setAttribute("data-char",`${h}`));let t=y;for(;t--;){const e=_[t],i=e.parentElement;i.style.display=p,l?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${hi[r]}`),f};class pi{constructor(t,s={}){si||(si=qs?new qs([],{granularity:Ks}):{segment:t=>{const e=[],s=t.split(Gs);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!Zs.test(i)})}return e}}),ii||(ii=qs?new qs([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!ri&&e&&(ri=i.createElement("template")),L.current&&L.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:h,debug:l}=s,c=(t=R(t)?t[0]:t)&&t.nodeType?t:(ie(t)||[])[0],d=!0===o?{}:o,u=!0===r||X(r)?{}:r,p=!0===n?{}:n;this.debug=wt(l,!1),this.includeSpaces=wt(h,!1),this.accessible=wt(a,!0),this.linesOnly=d&&!u&&!p,this.lineTemplate=M(d)?di(Js,d):d,this.wordTemplate=M(u)||this.linesOnly?di(Ks,u):u,this.charTemplate=M(p)?di(ti,p):p,this.$target=c,this.html=c&&c.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(d||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=c.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?i.fonts.ready.then(m):m(),c?this.resizeObserver.observe(c):console.warn("No Text Splitter target found.")}addEffect(t){if(!Y(t))return console.warn("Effect must return a function.");const e=ts(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>Y(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,s=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],h=this.words,l=this.chars,c=si.segment(o),d=i.createDocumentFragment();let u=null;for(const t of c){const e=t.segment,s=ni(t);if(!u||s&&u&&ni(u))a.push(e);else{const t=a.length-1;a[t].includes(" ")||e.includes(" ")?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const c=a[t+1],u=r&&c&&!c.trim(),p=o,m=s?ii.segment(p):null,f=s?i.createDocumentFragment():i.createTextNode(u?o+" ":o);if(s){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,c=i.createTextNode(a);ui(s,l,c,f,ti,n,-1,h.length,l.length)}}e?ui(e,h,f,d,Ks,n,-1,h.length,l.length):s?d.appendChild(f):d.appendChild(i.createTextNode(o)),u&&t++}else{if(t&&r)continue;d.appendChild(i.createTextNode(o))}}t.parentNode.replaceChild(d,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,s=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==i.fonts.status,h=r&&a;this.ready=!r||a,(h||t)&&this.effectsCleanups.forEach(t=>Y(t)&&t(this)),s||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),h&&(s&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=ai(e,Ks))),o&&(h||n)&&(this.chars=ai(e,ti));const l=this.words.length?this.words:this.chars;let c,d=0;for(let t=0,e=l.length;t<e;t++){const e=l[t],{top:s,height:i}=e.getBoundingClientRect();c&&s-c>.5*i&&d++,e.setAttribute(ei,`${d}`);const r=e.querySelectorAll(`[${ei}]`);let n=r.length;for(;n--;)r[n].setAttribute(ei,`${d}`);c=s}if(h){const t=i.createDocumentFragment(),s=new Set,a=[];for(let t=0;t<d+1;t++){const i=e.cloneNode(!0);ci(i,t,new Set).forEach(t=>{const e=t.parentElement;e&&s.add(e),t.remove()}),a.push(i)}s.forEach(li);for(let e=0,s=a.length;e<s;e++)ui(r,this.lines,a[e],t,Js,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=ai(e,Ks)),o&&(this.chars=ai(e,ti))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(h||!s)){const t=i.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(oi),this.words.forEach(oi),this.chars.forEach(oi)}return this.width=e.offsetWidth,(h||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const mi=(t,e)=>new pi(t,e),fi=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new pi(t,e));var gi=Object.freeze({__proto__:null,TextSplitter:pi,split:fi,splitText:mi});const _i=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(ut(t(i/e),4));return`linear(${s.join(", ")})`},yi={},vi=t=>{let e=yi[t];if(e)return e;if(e="linear",I(t)){if(P(t,"linear")||P(t,"cubic-")||P(t,"steps")||P(t,"ease"))e=t;else if(P(t,"cubicB"))e=F(t);else{const s=_e(t);Y(s)&&(e=s===le?"linear":_i(s))}yi[t]=e}else if(Y(t)){const s=_i(t);s&&(e=s)}else t.ease&&(e=_i(t.ease));return e},bi=["x","y","z"],Si=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...bi],Ti=(()=>[...bi,...g.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let wi=null;const xi=(t,e,s,i,r)=>{let n=I(e)?e:xt(e,s,i,r);return z(n)?Si.includes(t)||P(t,"translate")?`${n}px`:P(t,"rotate")||P(t,"skew")?`${n}deg`:`${n}`:n},ki=(t,e,s,i,r,n)=>{let o="0";const a=X(i)?getComputedStyle(t)[e]:xi(e,i,t,r,n);return o=X(s)?R(i)?i.map(s=>xi(e,s,t,r,n)):a:[xi(e,s,t,r,n),a],o};class $i{constructor(t,s){L.current&&L.current.register(this),W(wi)&&(!e||!X(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(g.forEach(t=>{const e=P(t,"skew"),s=P(t,"scale"),i=P(t,"rotate"),r=P(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),wi=!0):wi=!1);const i=ne(t),r=i.length;r||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const n=wt(s.ease,vi(A.defaults.ease)),o=n.ease&&n,a=wt(s.autoplay,A.defaults.autoplay),l=!(!a||!a.link)&&a,c=s.alternate&&!0===s.alternate,d=s.reversed&&!0===s.reversed,u=wt(s.loop,A.defaults.loop),v=!0===u||u===1/0?1/0:z(u)?u+1:1,b=c?d?"alternate-reverse":"alternate":d?"reverse":"normal",S=vi(n),T=1===A.timeScale?1:p;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||A.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!a||!1!==l,this.reversed=d,this.persist=wt(s.persist,A.defaults.persist),this.autoplay=a,this._speed=wt(s.playbackRate,A.defaults.playbackRate),this._resolve=y,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const i=t[h],a=Ti.some(t=>s.hasOwnProperty(t)),l=t.style,c=this._inlineStyles[e]={},d=(o?o.settlingDuration:xt(wt(s.duration,A.defaults.duration),t,e,r))*T,u=xt(wt(s.delay,A.defaults.delay),t,e,r)*T,p=wt(s.composition,"replace");for(let o in s){if(!j(o))continue;const h={},m={iterations:v,direction:b,fill:"both",easing:S,duration:d,delay:u,composite:p},_=s[o],y=!!a&&(g.includes(o)?o:f.get(o)),w=y?"transform":o;let x;if(c[w]||(c[w]=l[w]),M(_)){const s=_,a=wt(s.ease,n),c=a.ease&&a,f=s.to,g=s.from;if(m.duration=(c?c.settlingDuration:xt(wt(s.duration,d),t,e,r))*T,m.delay=xt(wt(s.delay,u),t,e,r)*T,m.composite=wt(s.composition,p),m.easing=vi(a),x=ki(t,o,g,f,e,r),y?(h[`--${y}`]=x,i[y]=x):h[o]=ki(t,o,g,f,e,r),Ne(this,t,o,h,m),!X(g))if(y){const t=`--${y}`;l.setProperty(t,h[t][0])}else l[o]=h[o][0]}else x=R(_)?_.map(s=>xi(o,s,t,e,r)):xi(o,_,t,e,r),y?(h[`--${y}`]=x,i[y]=x):h[o]=x,Ne(this,t,o,h,m)}if(a){let t=m;for(let e in i)t+=`${_[e]}var(--${e})) `;l.transform=t}}),l&&this.autoplay.link(this)}forEach(t){const e=I(t)?e=>e[t]():t;return this.animations.forEach(e),this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=A.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===A.timeScale?1:p);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel")}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let t in i){const e=i[t];X(e)||e===m?s.removeProperty(F(t)):s[t]=e}t.getAttribute("style")===m&&t.removeAttribute("style")}),this}then(t=y){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=y};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const Ei={animate:(t,e)=>new $i(t,e),convertEase:_i};t.$=ne,t.Animatable=Ie,t.Draggable=Je,t.JSAnimation=Be,t.Scope=es,t.ScrollObserver=cs,t.Spring=Ve,t.TextSplitter=pi,t.Timeline=ze,t.Timer=se,t.WAAPIAnimation=$i,t.animate=(t,e)=>new Be(t,e,null,0,!1).init(),t.clamp=Ds,t.cleanInlineStyles=Ot,t.createAnimatable=(t,e)=>new Ie(t,e),t.createDraggable=(t,e)=>new Je(t,e),t.createDrawable=Vs,t.createMotionPath=Ws,t.createScope=t=>new es(t),t.createSeededRandom=Ps,t.createSpring=Ue,t.createTimeline=t=>new ze(t).init(),t.createTimer=t=>new se(t,null,0).init(),t.cubicBezier=us,t.damp=As,t.degToRad=$s,t.eases=fe,t.easings=gs,t.engine=Xt,t.get=Fe,t.irregular=fs,t.keepTime=ts,t.lerp=Ls,t.linear=ms,t.mapRange=ks,t.morphTo=Hs,t.onScroll=(t={})=>new cs(t),t.padEnd=ws,t.padStart=Ts,t.radToDeg=Es,t.random=Ns,t.randomPick=Os,t.remove=Oe,t.round=Bs,t.roundPad=Ss,t.scrollContainers=is,t.set=Pe,t.shuffle=Rs,t.snap=Cs,t.split=fi,t.splitText=mi,t.spring=He,t.stagger=Ms,t.steps=ps,t.svg=Us,t.sync=Ke,t.text=gi,t.utils=zs,t.waapi=Ei,t.wrap=xs});
diff --git a/dist/modules/animatable/animatable.cjs b/dist/modules/animatable/animatable.cjs
index 83eee4fa..6ac9da35 100644
--- a/dist/modules/animatable/animatable.cjs
+++ b/dist/modules/animatable/animatable.cjs
@@ -11,7 +11,7 @@ var consts = require('../core/consts.cjs');
var globals = require('../core/globals.cjs');
var helpers = require('../core/helpers.cjs');
var animation = require('../animation/animation.cjs');
-var eases = require('../easings/eases.cjs');
+var parser = require('../easings/eases/parser.cjs');
/**
* @import {
@@ -116,7 +116,7 @@ class Animatable {
tween._fromNumber = /** @type {Number} */(tween._modifier(tween._number));
tween._toNumber = /** @type {Number} */(to);
}
- if (!helpers.isUnd(ease)) tween._ease = eases.parseEase(ease);
+ if (!helpers.isUnd(ease)) tween._ease = parser.parseEase(ease);
tween._currentTime = 0;
});
if (!helpers.isUnd(duration)) animation$1.stretch(duration);
diff --git a/dist/modules/animatable/animatable.js b/dist/modules/animatable/animatable.js
index 44385b0f..39fed719 100644
--- a/dist/modules/animatable/animatable.js
+++ b/dist/modules/animatable/animatable.js
@@ -9,7 +9,7 @@ import { compositionTypes, noop } from '../core/consts.js';
import { scope } from '../core/globals.js';
import { isUnd, isKey, stringStartsWith, isObj, mergeObjects, forEachChildren, isStr, isArr } from '../core/helpers.js';
import { JSAnimation } from '../animation/animation.js';
-import { parseEase } from '../easings/eases.js';
+import { parseEase } from '../easings/eases/parser.js';
/**
* @import {
diff --git a/dist/modules/animation/animation.cjs b/dist/modules/animation/animation.cjs
index dfb8be21..8019a21e 100644
--- a/dist/modules/animation/animation.cjs
+++ b/dist/modules/animation/animation.cjs
@@ -14,7 +14,7 @@ var targets = require('../core/targets.cjs');
var values = require('../core/values.cjs');
var styles = require('../core/styles.cjs');
var units = require('../core/units.cjs');
-var eases = require('../easings/eases.cjs');
+var parser = require('../easings/eases/parser.cjs');
var timer = require('../timer/timer.cjs');
var composition = require('./composition.cjs');
var additive = require('./additive.cjs');
@@ -45,13 +45,14 @@ var additive = require('./additive.cjs');
*
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
// Defines decomposed values target objects only once and mutate their properties later to avoid GC
// TODO: Maybe move the objects creation to values.js and use the decompose function to create the base object
const fromTargetObject = values.createDecomposedValueTargetObject();
const toTargetObject = values.createDecomposedValueTargetObject();
+const inlineStylesStore = {};
const toFunctionStore = { func: null };
const keyframesTargetArray = [null];
const fastSetValuesArray = [null, null];
@@ -193,18 +194,18 @@ class JSAnimation extends timer.Timer {
const animDefaults = parent ? parent.defaults : globals.globals.defaults;
const animaPlaybackEase = values.setValue(playbackEase, animDefaults.playbackEase);
- const animEase = animaPlaybackEase ? eases.parseEase(animaPlaybackEase) : null;
+ const animEase = animaPlaybackEase ? parser.parseEase(animaPlaybackEase) : null;
const hasSpring = !helpers.isUnd(ease) && !helpers.isUnd(/** @type {Spring} */(ease).ease);
const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : values.setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */(ease).duration : values.setValue(duration, animDefaults.duration);
+ const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : values.setValue(duration, animDefaults.duration);
const tDelay = values.setValue(delay, animDefaults.delay);
const tModifier = modifier || animDefaults.modifier;
// If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
const tComposition = helpers.isUnd(composition$1) && targetsLength >= consts.K ? consts.compositionTypes.none : !helpers.isUnd(composition$1) ? composition$1 : animDefaults.composition;
- // TODO: Do not create an empty object until we know the animation will generate inline styles
- const animInlineStyles = {};
// const absoluteOffsetTime = this._offset;
const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
+ // This allows targeting the current animation in the spring onComplete callback
+ if (hasSpring) /** @type {Spring} */(ease).parent = this;
let iterationDuration = NaN;
let iterationDelay = NaN;
@@ -306,7 +307,7 @@ class JSAnimation extends timer.Timer {
// Easing are treated differently and don't accept function based value to prevent having to pass a function wrapper that returns an other function all the time
const tweenEasing = hasSpring ? /** @type {Spring} */(keyEasing).ease : keyEasing || tEasing;
// Calculate default individual keyframe duration by dividing the tl of keyframes
- const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).duration : values.getFunctionValue(values.setValue(key.duration, (l > 1 ? values.getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
+ const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).settlingDuration : values.getFunctionValue(values.setValue(key.duration, (l > 1 ? values.getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
// Default delay value should only be applied to the first tween
const tweenDelay = values.getFunctionValue(values.setValue(key.delay, (!tweenIndex ? tDelay : 0)), target, ti, tl);
const computedComposition = values.getFunctionValue(values.setValue(key.composition, tComposition), target, ti, tl);
@@ -356,7 +357,7 @@ class JSAnimation extends timer.Timer {
}
} else {
values.decomposeRawValue(
- values.getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
values.decomposedOriginalValue
);
if (values.decomposedOriginalValue.t === consts.valueTypes.UNIT) {
@@ -374,7 +375,7 @@ class JSAnimation extends timer.Timer {
} else {
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
values.decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
- values.getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), toTargetObject);
+ values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), toTargetObject);
}
}
if (hasFromvalue) {
@@ -385,7 +386,7 @@ class JSAnimation extends timer.Timer {
} else {
values.decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
- values.getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), fromTargetObject);
+ values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
}
@@ -394,7 +395,7 @@ class JSAnimation extends timer.Timer {
if (fromTargetObject.o) {
fromTargetObject.n = values.getRelativeValue(
!prevSibling ? values.decomposeRawValue(
- values.getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
values.decomposedOriginalValue
).n : prevSibling._toNumber,
fromTargetObject.n,
@@ -450,6 +451,10 @@ class JSAnimation extends timer.Timer {
// Rounding is necessary here to minimize floating point errors when working in seconds
const tweenUpdateDuration = helpers.round(+tweenDuration || consts.minValue, 12);
+ // Copy the value of the iniline style if it exist and imediatly nullify it to prevents false positive on other targets
+ let inlineValue = inlineStylesStore[propName];
+ if (!helpers.isNil(inlineValue)) inlineStylesStore[propName] = null;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -458,7 +463,7 @@ class JSAnimation extends timer.Timer {
target: target,
_value: null,
_func: toFunctionStore.func,
- _ease: eases.parseEase(tweenEasing),
+ _ease: parser.parseEase(tweenEasing),
_fromNumbers: helpers.cloneArray(fromTargetObject.d),
_toNumbers: helpers.cloneArray(toTargetObject.d),
_strings: helpers.cloneArray(toTargetObject.s),
@@ -481,6 +486,7 @@ class JSAnimation extends timer.Timer {
_isOverlapped: 0,
_isOverridden: 0,
_renderTransforms: 0,
+ _inlineValue: inlineValue,
_prevRep: null, // For replaced tween
_nextRep: null, // For replaced tween
_prevAdd: null, // For additive tween
@@ -583,8 +589,6 @@ class JSAnimation extends timer.Timer {
// this._offset += parent ? iterationDelay : 0;
/** @type {Number} */
this.iterationDuration = iterationDuration;
- /** @type {{}} */
- this._inlineStyles = animInlineStyles;
if (!this._autoplay && shouldTriggerRender) this.onRender(this);
}
@@ -618,6 +622,7 @@ class JSAnimation extends timer.Timer {
if (tweenFunc) {
const ogValue = values.getOriginalAnimatableValue(tween.target, tween.property, tween._tweenType);
values.decomposeRawValue(ogValue, values.decomposedOriginalValue);
+ // TODO: Check for from / to Array based values here,
values.decomposeRawValue(tweenFunc(), toTargetObject);
tween._fromNumbers = helpers.cloneArray(values.decomposedOriginalValue.d);
tween._fromNumber = values.decomposedOriginalValue.n;
@@ -627,6 +632,8 @@ class JSAnimation extends timer.Timer {
tween._toNumber = toTargetObject.o ? values.getRelativeValue(values.decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
}
});
+ // This forces setter animations to render once
+ if (this.duration === consts.minValue) this.restart();
return this;
}
diff --git a/dist/modules/animation/animation.d.ts b/dist/modules/animation/animation.d.ts
index c5f060d0..b184cf76 100644
--- a/dist/modules/animation/animation.d.ts
+++ b/dist/modules/animation/animation.d.ts
@@ -15,8 +15,6 @@ export class JSAnimation extends Timer {
onRender: Callback<this>;
/** @type {EasingFunction} */
_ease: EasingFunction;
- /** @type {{}} */
- _inlineStyles: {};
/**
* @param {Number} newDuration
* @return {this}
diff --git a/dist/modules/animation/animation.js b/dist/modules/animation/animation.js
index 327a5167..42ef32ce 100644
--- a/dist/modules/animation/animation.js
+++ b/dist/modules/animation/animation.js
@@ -6,13 +6,13 @@
*/
import { K, compositionTypes, valueTypes, minValue, tweenTypes } from '../core/consts.js';
-import { mergeObjects, isUnd, isKey, isObj, round, cloneArray, addChild, forEachChildren, clampInfinity, normalizeTime, isArr, isNum } from '../core/helpers.js';
+import { mergeObjects, isUnd, isKey, isObj, round, cloneArray, isNil, addChild, forEachChildren, clampInfinity, normalizeTime, isArr, isNum } from '../core/helpers.js';
import { globals } from '../core/globals.js';
import { registerTargets } from '../core/targets.js';
import { setValue, getTweenType, getFunctionValue, decomposeRawValue, createDecomposedValueTargetObject, getOriginalAnimatableValue, decomposedOriginalValue, getRelativeValue, decomposeTweenValue } from '../core/values.js';
import { sanitizePropertyName, cleanInlineStyles } from '../core/styles.js';
import { convertValueUnit } from '../core/units.js';
-import { parseEase } from '../easings/eases.js';
+import { parseEase } from '../easings/eases/parser.js';
import { Timer } from '../timer/timer.js';
import { getTweenSiblings, overrideTween, composeTween } from './composition.js';
import { additive } from './additive.js';
@@ -43,13 +43,14 @@ import { additive } from './additive.js';
*
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
// Defines decomposed values target objects only once and mutate their properties later to avoid GC
// TODO: Maybe move the objects creation to values.js and use the decompose function to create the base object
const fromTargetObject = createDecomposedValueTargetObject();
const toTargetObject = createDecomposedValueTargetObject();
+const inlineStylesStore = {};
const toFunctionStore = { func: null };
const keyframesTargetArray = [null];
const fastSetValuesArray = [null, null];
@@ -194,15 +195,15 @@ class JSAnimation extends Timer {
const animEase = animaPlaybackEase ? parseEase(animaPlaybackEase) : null;
const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */(ease).ease);
const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */(ease).duration : setValue(duration, animDefaults.duration);
+ const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : setValue(duration, animDefaults.duration);
const tDelay = setValue(delay, animDefaults.delay);
const tModifier = modifier || animDefaults.modifier;
// If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
const tComposition = isUnd(composition) && targetsLength >= K ? compositionTypes.none : !isUnd(composition) ? composition : animDefaults.composition;
- // TODO: Do not create an empty object until we know the animation will generate inline styles
- const animInlineStyles = {};
// const absoluteOffsetTime = this._offset;
const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
+ // This allows targeting the current animation in the spring onComplete callback
+ if (hasSpring) /** @type {Spring} */(ease).parent = this;
let iterationDuration = NaN;
let iterationDelay = NaN;
@@ -304,7 +305,7 @@ class JSAnimation extends Timer {
// Easing are treated differently and don't accept function based value to prevent having to pass a function wrapper that returns an other function all the time
const tweenEasing = hasSpring ? /** @type {Spring} */(keyEasing).ease : keyEasing || tEasing;
// Calculate default individual keyframe duration by dividing the tl of keyframes
- const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).duration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
+ const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).settlingDuration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
// Default delay value should only be applied to the first tween
const tweenDelay = getFunctionValue(setValue(key.delay, (!tweenIndex ? tDelay : 0)), target, ti, tl);
const computedComposition = getFunctionValue(setValue(key.composition, tComposition), target, ti, tl);
@@ -354,7 +355,7 @@ class JSAnimation extends Timer {
}
} else {
decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
decomposedOriginalValue
);
if (decomposedOriginalValue.t === valueTypes.UNIT) {
@@ -372,7 +373,7 @@ class JSAnimation extends Timer {
} else {
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), toTargetObject);
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), toTargetObject);
}
}
if (hasFromvalue) {
@@ -383,7 +384,7 @@ class JSAnimation extends Timer {
} else {
decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), fromTargetObject);
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
}
@@ -392,7 +393,7 @@ class JSAnimation extends Timer {
if (fromTargetObject.o) {
fromTargetObject.n = getRelativeValue(
!prevSibling ? decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
decomposedOriginalValue
).n : prevSibling._toNumber,
fromTargetObject.n,
@@ -448,6 +449,10 @@ class JSAnimation extends Timer {
// Rounding is necessary here to minimize floating point errors when working in seconds
const tweenUpdateDuration = round(+tweenDuration || minValue, 12);
+ // Copy the value of the iniline style if it exist and imediatly nullify it to prevents false positive on other targets
+ let inlineValue = inlineStylesStore[propName];
+ if (!isNil(inlineValue)) inlineStylesStore[propName] = null;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -479,6 +484,7 @@ class JSAnimation extends Timer {
_isOverlapped: 0,
_isOverridden: 0,
_renderTransforms: 0,
+ _inlineValue: inlineValue,
_prevRep: null, // For replaced tween
_nextRep: null, // For replaced tween
_prevAdd: null, // For additive tween
@@ -581,8 +587,6 @@ class JSAnimation extends Timer {
// this._offset += parent ? iterationDelay : 0;
/** @type {Number} */
this.iterationDuration = iterationDuration;
- /** @type {{}} */
- this._inlineStyles = animInlineStyles;
if (!this._autoplay && shouldTriggerRender) this.onRender(this);
}
@@ -616,6 +620,7 @@ class JSAnimation extends Timer {
if (tweenFunc) {
const ogValue = getOriginalAnimatableValue(tween.target, tween.property, tween._tweenType);
decomposeRawValue(ogValue, decomposedOriginalValue);
+ // TODO: Check for from / to Array based values here,
decomposeRawValue(tweenFunc(), toTargetObject);
tween._fromNumbers = cloneArray(decomposedOriginalValue.d);
tween._fromNumber = decomposedOriginalValue.n;
@@ -625,6 +630,8 @@ class JSAnimation extends Timer {
tween._toNumber = toTargetObject.o ? getRelativeValue(decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
}
});
+ // This forces setter animations to render once
+ if (this.duration === minValue) this.restart();
return this;
}
diff --git a/dist/modules/core/consts.cjs b/dist/modules/core/consts.cjs
index b6d6832f..a22c5bbf 100644
--- a/dist/modules/core/consts.cjs
+++ b/dist/modules/core/consts.cjs
@@ -70,6 +70,8 @@ const maxFps = 120;
// Strings
const emptyString = '';
+const cssVarPrefix = 'var(';
+
const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -93,9 +95,9 @@ const validTransforms = [
'skew',
'skewX',
'skewY',
- 'perspective',
'matrix',
'matrix3d',
+ 'perspective',
];
const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) => ({...a, [v]: v + '('}), {});
@@ -119,9 +121,12 @@ const unitsExecRgx = /^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i;
const lowerCaseRgx = /([a-z])([A-Z])/g;
const transformsExecRgx = /(\w+)(\([^)]+\)+)/g; // Match inline transforms with cacl() values, returns the value wrapped in ()
const relativeValuesExecRgx = /(\*=|\+=|-=)/;
+const cssVariableMatchRgx = /var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/;
exports.K = K;
exports.compositionTypes = compositionTypes;
+exports.cssVarPrefix = cssVarPrefix;
+exports.cssVariableMatchRgx = cssVariableMatchRgx;
exports.digitWithExponentRgx = digitWithExponentRgx;
exports.doc = doc;
exports.emptyString = emptyString;
diff --git a/dist/modules/core/consts.d.ts b/dist/modules/core/consts.d.ts
index 6f31bde6..aa4347f7 100644
--- a/dist/modules/core/consts.d.ts
+++ b/dist/modules/core/consts.d.ts
@@ -43,6 +43,7 @@ export const maxValue: 1000000000000;
export const K: 1000;
export const maxFps: 120;
export const emptyString: "";
+export const cssVarPrefix: "var(";
export const shortTransforms: Map<any, any>;
export const validTransforms: string[];
export const transformsFragmentStrings: {};
@@ -57,3 +58,4 @@ export const unitsExecRgx: RegExp;
export const lowerCaseRgx: RegExp;
export const transformsExecRgx: RegExp;
export const relativeValuesExecRgx: RegExp;
+export const cssVariableMatchRgx: RegExp;
diff --git a/dist/modules/core/consts.js b/dist/modules/core/consts.js
index ade70d3e..d6a8e8a2 100644
--- a/dist/modules/core/consts.js
+++ b/dist/modules/core/consts.js
@@ -68,6 +68,8 @@ const maxFps = 120;
// Strings
const emptyString = '';
+const cssVarPrefix = 'var(';
+
const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -91,9 +93,9 @@ const validTransforms = [
'skew',
'skewX',
'skewY',
- 'perspective',
'matrix',
'matrix3d',
+ 'perspective',
];
const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) => ({...a, [v]: v + '('}), {});
@@ -117,5 +119,6 @@ const unitsExecRgx = /^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i;
const lowerCaseRgx = /([a-z])([A-Z])/g;
const transformsExecRgx = /(\w+)(\([^)]+\)+)/g; // Match inline transforms with cacl() values, returns the value wrapped in ()
const relativeValuesExecRgx = /(\*=|\+=|-=)/;
+const cssVariableMatchRgx = /var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/;
-export { K, compositionTypes, digitWithExponentRgx, doc, emptyString, hexTestRgx, hslExecRgx, hslaExecRgx, isBrowser, isDomSymbol, isRegisteredTargetSymbol, isSvgSymbol, lowerCaseRgx, maxFps, maxValue, minValue, morphPointsSymbol, noop, proxyTargetSymbol, relativeValuesExecRgx, rgbExecRgx, rgbaExecRgx, shortTransforms, tickModes, transformsExecRgx, transformsFragmentStrings, transformsSymbol, tweenTypes, unitsExecRgx, validTransforms, valueTypes, win };
+export { K, compositionTypes, cssVarPrefix, cssVariableMatchRgx, digitWithExponentRgx, doc, emptyString, hexTestRgx, hslExecRgx, hslaExecRgx, isBrowser, isDomSymbol, isRegisteredTargetSymbol, isSvgSymbol, lowerCaseRgx, maxFps, maxValue, minValue, morphPointsSymbol, noop, proxyTargetSymbol, relativeValuesExecRgx, rgbExecRgx, rgbaExecRgx, shortTransforms, tickModes, transformsExecRgx, transformsFragmentStrings, transformsSymbol, tweenTypes, unitsExecRgx, validTransforms, valueTypes, win };
diff --git a/dist/modules/core/globals.cjs b/dist/modules/core/globals.cjs
index c4028ca0..bc1f3eb1 100644
--- a/dist/modules/core/globals.cjs
+++ b/dist/modules/core/globals.cjs
@@ -31,6 +31,7 @@ const defaults = {
reversed: false,
alternate: false,
autoplay: true,
+ persist: false,
duration: consts.K,
delay: 0,
loopDelay: 0,
diff --git a/dist/modules/core/globals.js b/dist/modules/core/globals.js
index 0b2e065a..6decea57 100644
--- a/dist/modules/core/globals.js
+++ b/dist/modules/core/globals.js
@@ -29,6 +29,7 @@ const defaults = {
reversed: false,
alternate: false,
autoplay: true,
+ persist: false,
duration: K,
delay: 0,
loopDelay: 0,
diff --git a/dist/modules/core/render.cjs b/dist/modules/core/render.cjs
index b34f27cd..4fd98b54 100644
--- a/dist/modules/core/render.cjs
+++ b/dist/modules/core/render.cjs
@@ -283,7 +283,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
// Handle setters on timeline differently and allow re-trigering the onComplete callback when seeking backwards
if (parent && isSetter) {
if (!muteCallbacks && (
- (parent.began && !isRunningBackwards && tickableAbsoluteTime >= duration && !completed) ||
+ // (tickableAbsoluteTime > 0 instead) of (tickableAbsoluteTime >= duration) to prevent floating point precision issues
+ // see: https://github.com/juliangarnier/anime/issues/1088
+ (parent.began && !isRunningBackwards && tickableAbsoluteTime > 0 && !completed) ||
(isRunningBackwards && tickableAbsoluteTime <= consts.minValue && completed)
)) {
tickable.onComplete(/** @type {CallbackArgument} */(tickable));
diff --git a/dist/modules/core/render.js b/dist/modules/core/render.js
index 49ef8287..29054935 100644
--- a/dist/modules/core/render.js
+++ b/dist/modules/core/render.js
@@ -281,7 +281,9 @@ const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
// Handle setters on timeline differently and allow re-trigering the onComplete callback when seeking backwards
if (parent && isSetter) {
if (!muteCallbacks && (
- (parent.began && !isRunningBackwards && tickableAbsoluteTime >= duration && !completed) ||
+ // (tickableAbsoluteTime > 0 instead) of (tickableAbsoluteTime >= duration) to prevent floating point precision issues
+ // see: https://github.com/juliangarnier/anime/issues/1088
+ (parent.began && !isRunningBackwards && tickableAbsoluteTime > 0 && !completed) ||
(isRunningBackwards && tickableAbsoluteTime <= minValue && completed)
)) {
tickable.onComplete(/** @type {CallbackArgument} */(tickable));
diff --git a/dist/modules/core/styles.cjs b/dist/modules/core/styles.cjs
index 6122d629..816a7205 100644
--- a/dist/modules/core/styles.cjs
+++ b/dist/modules/core/styles.cjs
@@ -10,9 +10,6 @@
var consts = require('./consts.cjs');
var helpers = require('./helpers.cjs');
-const propertyNamesCache = {};
-
-
/**
* @import {
* JSAnimation,
@@ -28,6 +25,8 @@ const propertyNamesCache = {};
* } from '../types/index.js'
*/
+const propertyNamesCache = {};
+
/**
* @param {String} propertyName
* @param {Target} target
@@ -74,10 +73,11 @@ const cleanInlineStyles = renderable => {
const tweenTarget = tween.target;
if (tweenTarget[consts.isDomSymbol]) {
const targetStyle = /** @type {DOMTarget} */(tweenTarget).style;
- const originalInlinedValue = animation._inlineStyles[tweenProperty];
+ const originalInlinedValue = tween._inlineValue;
+ const tweenHadNoInlineValue = helpers.isNil(originalInlinedValue) || originalInlinedValue === consts.emptyString;
if (tween._tweenType === consts.tweenTypes.TRANSFORM) {
const cachedTransforms = tweenTarget[consts.transformsSymbol];
- if (helpers.isUnd(originalInlinedValue) || originalInlinedValue === consts.emptyString) {
+ if (tweenHadNoInlineValue) {
delete cachedTransforms[tweenProperty];
} else {
cachedTransforms[tweenProperty] = originalInlinedValue;
@@ -94,8 +94,8 @@ const cleanInlineStyles = renderable => {
}
}
} else {
- if (helpers.isUnd(originalInlinedValue) || originalInlinedValue === consts.emptyString) {
- targetStyle.removeProperty(tweenProperty);
+ if (tweenHadNoInlineValue) {
+ targetStyle.removeProperty(helpers.toLowerCase(tweenProperty));
} else {
targetStyle[tweenProperty] = originalInlinedValue;
}
diff --git a/dist/modules/core/styles.js b/dist/modules/core/styles.js
index c55c2093..ea4f2429 100644
--- a/dist/modules/core/styles.js
+++ b/dist/modules/core/styles.js
@@ -5,11 +5,8 @@
* @copyright 2025 - Julian Garnier
*/
-import { tweenTypes, shortTransforms, isDomSymbol, transformsSymbol, emptyString, transformsFragmentStrings } from './consts.js';
-import { forEachChildren, isSvg, toLowerCase, isUnd } from './helpers.js';
-
-const propertyNamesCache = {};
-
+import { tweenTypes, shortTransforms, isDomSymbol, transformsSymbol, transformsFragmentStrings, emptyString } from './consts.js';
+import { forEachChildren, isSvg, toLowerCase, isNil } from './helpers.js';
/**
* @import {
@@ -26,6 +23,8 @@ const propertyNamesCache = {};
* } from '../types/index.js'
*/
+const propertyNamesCache = {};
+
/**
* @param {String} propertyName
* @param {Target} target
@@ -72,10 +71,11 @@ const cleanInlineStyles = renderable => {
const tweenTarget = tween.target;
if (tweenTarget[isDomSymbol]) {
const targetStyle = /** @type {DOMTarget} */(tweenTarget).style;
- const originalInlinedValue = animation._inlineStyles[tweenProperty];
+ const originalInlinedValue = tween._inlineValue;
+ const tweenHadNoInlineValue = isNil(originalInlinedValue) || originalInlinedValue === emptyString;
if (tween._tweenType === tweenTypes.TRANSFORM) {
const cachedTransforms = tweenTarget[transformsSymbol];
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ if (tweenHadNoInlineValue) {
delete cachedTransforms[tweenProperty];
} else {
cachedTransforms[tweenProperty] = originalInlinedValue;
@@ -92,8 +92,8 @@ const cleanInlineStyles = renderable => {
}
}
} else {
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
- targetStyle.removeProperty(tweenProperty);
+ if (tweenHadNoInlineValue) {
+ targetStyle.removeProperty(toLowerCase(tweenProperty));
} else {
targetStyle[tweenProperty] = originalInlinedValue;
}
diff --git a/dist/modules/core/values.cjs b/dist/modules/core/values.cjs
index 0844803c..57c67e95 100644
--- a/dist/modules/core/values.cjs
+++ b/dist/modules/core/values.cjs
@@ -41,19 +41,30 @@ const setValue = (targetValue, defaultValue) => {
* @return {any}
*/
const getFunctionValue = (value, target, index, total, store) => {
+ let func;
if (helpers.isFnc(value)) {
- const func = () => {
+ func = () => {
const computed = /** @type {Function} */(value)(target, index, total);
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed || 0;
};
- if (store) {
- store.func = func;
- }
- return func();
+ } else if (helpers.isStr(value) && helpers.stringStartsWith(value, consts.cssVarPrefix)) {
+ func = () => {
+ const match = value.match(consts.cssVariableMatchRgx);
+ const cssVarName = match[1];
+ const fallbackValue = match[2];
+ let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
+ // Use fallback if CSS variable is not set or empty
+ if ((!computed || computed.trim() === consts.emptyString) && fallbackValue) {
+ computed = fallbackValue.trim();
+ }
+ return computed || 0;
+ };
} else {
return value;
}
+ if (store) store.func = func;
+ return func();
};
/**
diff --git a/dist/modules/core/values.js b/dist/modules/core/values.js
index 58b311ae..9c43a215 100644
--- a/dist/modules/core/values.js
+++ b/dist/modules/core/values.js
@@ -5,8 +5,8 @@
* @copyright 2025 - Julian Garnier
*/
-import { tweenTypes, isDomSymbol, isSvgSymbol, validTransforms, shortTransforms, valueTypes, unitsExecRgx, digitWithExponentRgx, proxyTargetSymbol } from './consts.js';
-import { isValidSVGAttribute, stringStartsWith, isUnd, isCol, isFnc, cloneArray } from './helpers.js';
+import { tweenTypes, isDomSymbol, isSvgSymbol, validTransforms, shortTransforms, valueTypes, unitsExecRgx, digitWithExponentRgx, proxyTargetSymbol, cssVarPrefix, cssVariableMatchRgx, emptyString } from './consts.js';
+import { isUnd, isValidSVGAttribute, stringStartsWith, isCol, isFnc, isStr, cloneArray } from './helpers.js';
import { parseInlineTransforms } from './transforms.js';
import { convertColorStringValuesToRgbaArray } from './colors.js';
@@ -39,19 +39,30 @@ const setValue = (targetValue, defaultValue) => {
* @return {any}
*/
const getFunctionValue = (value, target, index, total, store) => {
+ let func;
if (isFnc(value)) {
- const func = () => {
+ func = () => {
const computed = /** @type {Function} */(value)(target, index, total);
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed || 0;
};
- if (store) {
- store.func = func;
- }
- return func();
+ } else if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
+ func = () => {
+ const match = value.match(cssVariableMatchRgx);
+ const cssVarName = match[1];
+ const fallbackValue = match[2];
+ let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
+ // Use fallback if CSS variable is not set or empty
+ if ((!computed || computed.trim() === emptyString) && fallbackValue) {
+ computed = fallbackValue.trim();
+ }
+ return computed || 0;
+ };
} else {
return value;
}
+ if (store) store.func = func;
+ return func();
};
/**
diff --git a/dist/modules/draggable/draggable.cjs b/dist/modules/draggable/draggable.cjs
index 56a65cfa..5dcc95c5 100644
--- a/dist/modules/draggable/draggable.cjs
+++ b/dist/modules/draggable/draggable.cjs
@@ -17,8 +17,8 @@ var timer = require('../timer/timer.cjs');
var animation = require('../animation/animation.cjs');
var composition = require('../animation/composition.cjs');
var animatable = require('../animatable/animatable.cjs');
-var eases = require('../easings/eases.cjs');
-var spring = require('../spring/spring.cjs');
+var parser = require('../easings/eases/parser.cjs');
+var index = require('../easings/spring/index.cjs');
var target = require('../utils/target.cjs');
/**
@@ -40,7 +40,7 @@ var target = require('../utils/target.cjs');
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
@@ -178,7 +178,7 @@ class Draggable {
const trigger = parameters.trigger;
const modifier = parameters.modifier;
const ease = parameters.releaseEase;
- const customEase = ease && eases.parseEase(ease);
+ const customEase = ease && parser.parseEase(ease);
const hasSpring = !helpers.isUnd(ease) && !helpers.isUnd(/** @type {Spring} */(ease).ease);
const xProp = /** @type {String} */(helpers.isObj(paramX) && !helpers.isUnd(/** @type {Object} */(paramX).mapTo) ? /** @type {Object} */(paramX).mapTo : 'translateX');
const yProp = /** @type {String} */(helpers.isObj(paramY) && !helpers.isUnd(/** @type {Object} */(paramY).mapTo) ? /** @type {Object} */(paramY).mapTo : 'translateY');
@@ -218,19 +218,19 @@ class Draggable {
/** @type {Boolean|DraggableCursorParams} */
this.cursor = false;
/** @type {Spring} */
- this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : spring.createSpring({
+ this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : index.spring({
mass: values.setValue(parameters.releaseMass, 1),
stiffness: values.setValue(parameters.releaseStiffness, 80),
damping: values.setValue(parameters.releaseDamping, 20),
});
/** @type {Spring} */
- this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : spring.createSpring({
+ this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : index.spring({
mass: values.setValue(parameters.releaseMass, 1),
stiffness: values.setValue(parameters.releaseStiffness, 80),
damping: values.setValue(parameters.releaseDamping, 20),
});
/** @type {EasingFunction} */
- this.releaseEase = customEase || eases.eases.outQuint;
+ this.releaseEase = customEase || parser.eases.outQuint;
/** @type {Boolean} */
this.hasReleaseSpring = hasSpring;
/** @type {Callback<this>} */
@@ -753,7 +753,7 @@ class Draggable {
* @param {EasingParam} [ease]
* @return {this}
*/
- scrollInView(duration, gap = 0, ease = eases.eases.inOutQuad) {
+ scrollInView(duration, gap = 0, ease = parser.eases.inOutQuad) {
this.updateScrollCoords();
const x = this.destX;
const y = this.destY;
@@ -796,7 +796,7 @@ class Draggable {
* @param {EasingParam} [ease]
* @return {this}
*/
- animateInView(duration, gap = 0, ease = eases.eases.inOutQuad) {
+ animateInView(duration, gap = 0, ease = parser.eases.inOutQuad) {
this.stop();
this.updateBoundingValues();
const x = this.x;
@@ -877,7 +877,7 @@ class Draggable {
cursor: /** @type {DraggableCursorParams} */(this.cursor).onGrab
});
}
- this.scrollInView(100, 0, eases.eases.out(3));
+ this.scrollInView(100, 0, parser.eases.out(3));
this.onGrab(this);
consts.doc.addEventListener('touchmove', this);
@@ -941,8 +941,8 @@ class Draggable {
this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
this.$trigger.addEventListener('touchend', preventDefault);
-
- if ((!this.disabled[0] && helpers.abs(movedX) > 3) || (!this.disabled[1] && helpers.abs(movedY) > 3)) {
+ // Don't check for a miminim distance move if already dragging
+ if (this.dragged || (!this.disabled[0] && helpers.abs(movedX) > 3) || (!this.disabled[1] && helpers.abs(movedY) > 3)) {
this.updateTicker.resume();
this.pointer[2] = this.pointer[0];
@@ -1008,8 +1008,8 @@ class Draggable {
const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
const distanceX = helpers.round(cx - dx, 0);
springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / helpers.abs(distanceX) : 0 : pv;
- const { ease, duration, restDuration } = springX;
- durationX = cx === dx ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springX;
+ durationX = cx === dx ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.globals.timeScale);
if (hasReleaseSpring) easeX = ease;
if (durationX > longestReleaseDuration) longestReleaseDuration = durationX;
}
@@ -1018,8 +1018,8 @@ class Draggable {
const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
const distanceY = helpers.round(cy - dy, 0);
springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / helpers.abs(distanceY) : 0 : pv;
- const { ease, duration, restDuration } = springY;
- durationY = cy === dy ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springY;
+ durationY = cy === dy ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.globals.timeScale);
if (hasReleaseSpring) easeY = ease;
if (durationY > longestReleaseDuration) longestReleaseDuration = durationY;
}
diff --git a/dist/modules/draggable/draggable.d.ts b/dist/modules/draggable/draggable.d.ts
index f1807895..2bbd0b0f 100644
--- a/dist/modules/draggable/draggable.d.ts
+++ b/dist/modules/draggable/draggable.d.ts
@@ -206,7 +206,7 @@ export class Draggable {
}
export function createDraggable(target: TargetsParam, parameters?: DraggableParams): Draggable;
import type { DraggableCursorParams } from '../types/index.js';
-import type { Spring } from '../spring/spring.js';
+import type { Spring } from '../easings/spring/index.js';
import type { EasingFunction } from '../types/index.js';
import type { Callback } from '../types/index.js';
import type { AnimatableObject } from '../types/index.js';
diff --git a/dist/modules/draggable/draggable.js b/dist/modules/draggable/draggable.js
index eee2ab05..2c732b41 100644
--- a/dist/modules/draggable/draggable.js
+++ b/dist/modules/draggable/draggable.js
@@ -15,8 +15,8 @@ import { Timer } from '../timer/timer.js';
import { JSAnimation } from '../animation/animation.js';
import { removeTargetsFromRenderable } from '../animation/composition.js';
import { Animatable } from '../animatable/animatable.js';
-import { parseEase, eases } from '../easings/eases.js';
-import { createSpring } from '../spring/spring.js';
+import { parseEase, eases } from '../easings/eases/parser.js';
+import { spring } from '../easings/spring/index.js';
import { get, set } from '../utils/target.js';
/**
@@ -38,7 +38,7 @@ import { get, set } from '../utils/target.js';
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
@@ -216,13 +216,13 @@ class Draggable {
/** @type {Boolean|DraggableCursorParams} */
this.cursor = false;
/** @type {Spring} */
- this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : createSpring({
+ this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
mass: setValue(parameters.releaseMass, 1),
stiffness: setValue(parameters.releaseStiffness, 80),
damping: setValue(parameters.releaseDamping, 20),
});
/** @type {Spring} */
- this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : createSpring({
+ this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
mass: setValue(parameters.releaseMass, 1),
stiffness: setValue(parameters.releaseStiffness, 80),
damping: setValue(parameters.releaseDamping, 20),
@@ -939,8 +939,8 @@ class Draggable {
this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
this.$trigger.addEventListener('touchend', preventDefault);
-
- if ((!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
+ // Don't check for a miminim distance move if already dragging
+ if (this.dragged || (!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
this.updateTicker.resume();
this.pointer[2] = this.pointer[0];
@@ -1006,8 +1006,8 @@ class Draggable {
const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
const distanceX = round(cx - dx, 0);
springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / abs(distanceX) : 0 : pv;
- const { ease, duration, restDuration } = springX;
- durationX = cx === dx ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springX;
+ durationX = cx === dx ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
if (hasReleaseSpring) easeX = ease;
if (durationX > longestReleaseDuration) longestReleaseDuration = durationX;
}
@@ -1016,8 +1016,8 @@ class Draggable {
const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
const distanceY = round(cy - dy, 0);
springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / abs(distanceY) : 0 : pv;
- const { ease, duration, restDuration } = springY;
- durationY = cy === dy ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springY;
+ durationY = cy === dy ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
if (hasReleaseSpring) easeY = ease;
if (durationY > longestReleaseDuration) longestReleaseDuration = durationY;
}
diff --git a/dist/modules/easings/cubic-bezier.cjs b/dist/modules/easings/cubic-bezier/index.cjs
similarity index 92%
rename from dist/modules/easings/cubic-bezier.cjs
rename to dist/modules/easings/cubic-bezier/index.cjs
index 8947b525..cd6200d6 100644
--- a/dist/modules/easings/cubic-bezier.cjs
+++ b/dist/modules/easings/cubic-bezier/index.cjs
@@ -7,13 +7,13 @@
'use strict';
-var helpers = require('../core/helpers.cjs');
-var none = require('./none.cjs');
+var helpers = require('../../core/helpers.cjs');
+var none = require('../none.cjs');
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/dist/modules/easings/cubic-bezier.d.ts b/dist/modules/easings/cubic-bezier/index.d.ts
similarity index 62%
rename from dist/modules/easings/cubic-bezier.d.ts
rename to dist/modules/easings/cubic-bezier/index.d.ts
index 31c52a3c..ec46bb95 100644
--- a/dist/modules/easings/cubic-bezier.d.ts
+++ b/dist/modules/easings/cubic-bezier/index.d.ts
@@ -1,2 +1,2 @@
export function cubicBezier(mX1?: number, mY1?: number, mX2?: number, mY2?: number): EasingFunction;
-import type { EasingFunction } from '../types/index.js';
+import type { EasingFunction } from '../../types/index.js';
diff --git a/dist/modules/easings/cubic-bezier.js b/dist/modules/easings/cubic-bezier/index.js
similarity index 92%
rename from dist/modules/easings/cubic-bezier.js
rename to dist/modules/easings/cubic-bezier/index.js
index 02144717..ab84bdd3 100644
--- a/dist/modules/easings/cubic-bezier.js
+++ b/dist/modules/easings/cubic-bezier/index.js
@@ -5,13 +5,13 @@
* @copyright 2025 - Julian Garnier
*/
-import { abs } from '../core/helpers.js';
-import { none } from './none.js';
+import { abs } from '../../core/helpers.js';
+import { none } from '../none.js';
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/dist/modules/easings/eases/index.cjs b/dist/modules/easings/eases/index.cjs
new file mode 100644
index 00000000..34a50d68
--- /dev/null
+++ b/dist/modules/easings/eases/index.cjs
@@ -0,0 +1,14 @@
+/**
+ * Anime.js - easings - CJS
+ * @version v4.2.0
+ * @license MIT
+ * @copyright 2025 - Julian Garnier
+ */
+
+'use strict';
+
+var parser = require('./parser.cjs');
+
+
+
+exports.eases = parser.eases;
diff --git a/dist/modules/easings/eases/index.d.ts b/dist/modules/easings/eases/index.d.ts
new file mode 100644
index 00000000..ad1f238e
--- /dev/null
+++ b/dist/modules/easings/eases/index.d.ts
@@ -0,0 +1 @@
+export { eases } from "./parser.js";
diff --git a/dist/modules/spring/index.js b/dist/modules/easings/eases/index.js
similarity index 50%
rename from dist/modules/spring/index.js
rename to dist/modules/easings/eases/index.js
index 7dffbca5..17977df8 100644
--- a/dist/modules/spring/index.js
+++ b/dist/modules/easings/eases/index.js
@@ -1,8 +1,8 @@
/**
- * Anime.js - spring - ESM
+ * Anime.js - easings - ESM
* @version v4.2.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
-export { Spring, createSpring } from './spring.js';
+export { eases } from './parser.js';
diff --git a/dist/modules/easings/eases.cjs b/dist/modules/easings/eases/parser.cjs
similarity index 59%
rename from dist/modules/easings/eases.cjs
rename to dist/modules/easings/eases/parser.cjs
index 6ccb1715..9db91473 100644
--- a/dist/modules/easings/eases.cjs
+++ b/dist/modules/easings/eases/parser.cjs
@@ -7,14 +7,9 @@
'use strict';
-var consts = require('../core/consts.cjs');
-var helpers = require('../core/helpers.cjs');
-var parser = require('./parser.cjs');
-var none = require('./none.cjs');
-var cubicBezier = require('./cubic-bezier.cjs');
-var steps = require('./steps.cjs');
-var linear = require('./linear.cjs');
-var irregular = require('./irregular.cjs');
+var consts = require('../../core/consts.cjs');
+var helpers = require('../../core/helpers.cjs');
+var none = require('../none.cjs');
/**
* @import {
@@ -24,9 +19,27 @@ var irregular = require('./irregular.cjs');
* BackEasing,
* ElasticEasing,
* PowerEasing,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
+
+/** @type {PowerEasing} */
+const easeInPower = (p = 1.68) => t => helpers.pow(t, +p);
+
+/**
+ * @callback EaseType
+ * @param {EasingFunction} Ease
+ * @return {EasingFunction}
+ */
+
+/** @type {Record<String, EaseType>} */
+const easeTypes = {
+ in: easeIn => t => easeIn(t),
+ out: easeIn => t => 1 - easeIn(1 - t),
+ inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
+ outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
+};
+
/**
* Easing functions adapted and simplified from https://robertpenner.com/easing/
* (c) 2001 Robert Penner
@@ -37,11 +50,11 @@ const doublePI = helpers.PI * 2;
/** @type {Record<String, EasingFunctionWithParams|EasingFunction>} */
const easeInFunctions = {
- [consts.emptyString]: parser.easeInPower,
- Quad: parser.easeInPower(2),
- Cubic: parser.easeInPower(3),
- Quart: parser.easeInPower(4),
- Quint: parser.easeInPower(5),
+ [consts.emptyString]: easeInPower,
+ Quad: easeInPower(2),
+ Cubic: easeInPower(3),
+ Quart: easeInPower(4),
+ Quint: easeInPower(5),
/** @type {EasingFunction} */
Sine: t => 1 - helpers.cos(t * halfPI),
/** @type {EasingFunction} */
@@ -55,7 +68,7 @@ const easeInFunctions = {
return 1 / helpers.pow(4, 3 - b) - 7.5625 * helpers.pow((pow2 * 3 - 2) / 22 - t, 2);
},
/** @type {BackEasing} */
- Back: (overshoot = 1.70158) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
+ Back: (overshoot = 1.7) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
/** @type {ElasticEasing} */
Elastic: (amplitude = 1, period = .3) => {
const a = helpers.clamp(+amplitude, 1, 10);
@@ -68,10 +81,8 @@ const easeInFunctions = {
/**
* @typedef {Object} EasesFunctions
- * @property {typeof linear} linear
- * @property {typeof irregular} irregular
- * @property {typeof steps} steps
- * @property {typeof cubicBezier} cubicBezier
+ * @property {typeof none} linear
+ * @property {typeof none} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
@@ -119,11 +130,11 @@ const easeInFunctions = {
*/
const eases = (/*#__PURE__ */ (() => {
- const list = { linear: linear.linear, irregular: irregular.irregular, steps: steps.steps, cubicBezier: cubicBezier.cubicBezier };
- for (let type in parser.easeTypes) {
+ const list = { linear: none.none, none: none.none };
+ for (let type in easeTypes) {
for (let name in easeInFunctions) {
const easeIn = easeInFunctions[name];
- const easeType = parser.easeTypes[type];
+ const easeType = easeTypes[type];
list[type + name] = /** @type {EasingFunctionWithParams|EasingFunction} */(
name === consts.emptyString || name === 'Back' || name === 'Elastic' ?
(a, b) => easeType(/** @type {EasingFunctionWithParams} */(easeIn)(a, b)) :
@@ -135,15 +146,46 @@ const eases = (/*#__PURE__ */ (() => {
})());
/** @type {Record<String, EasingFunction>} */
-const JSEasesLookups = { linear: none.none };
+const easesLookups = { linear: none.none, none: none.none };
+
+/**
+ * @param {String} string
+ * @return {EasingFunction}
+ */
+const parseEaseString = (string) => {
+ if (easesLookups[string]) return easesLookups[string];
+ if (string.indexOf('(') <= -1) {
+ const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
+ const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(eases[string])() : eases[string]);
+ return parsedFn ? easesLookups[string] = parsedFn : none.none;
+ } else {
+ const split = string.slice(0, -1).split('(');
+ const parsedFn = /** @type {EasingFunctionWithParams} */(eases[split[0]]);
+ return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none.none;
+ }
+};
+
+const deprecated = ['steps(', 'irregular(', 'linear(', 'cubicBezier('];
/**
* @param {EasingParam} ease
* @return {EasingFunction}
*/
-const parseEase = ease => helpers.isFnc(ease) ? ease :
- helpers.isStr(ease) ? parser.parseEaseString(/** @type {String} */(ease), eases, JSEasesLookups) :
- none.none;
+const parseEase = ease => {
+ if (helpers.isStr(ease)) {
+ for (let i = 0, l = deprecated.length; i < l; i++) {
+ if (helpers.stringStartsWith(ease, deprecated[i])) {
+ console.warn(`String syntax for \`ease: "${ease}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${ease}\``);
+ return none.none;
+ }
+ }
+ }
+ const easeFunc = helpers.isFnc(ease) ? ease : helpers.isStr(ease) ? parseEaseString(/** @type {String} */(ease)) : none.none;
+ return easeFunc;
+};
+exports.easeInPower = easeInPower;
+exports.easeTypes = easeTypes;
exports.eases = eases;
exports.parseEase = parseEase;
+exports.parseEaseString = parseEaseString;
diff --git a/dist/modules/easings/eases.d.ts b/dist/modules/easings/eases/parser.d.ts
similarity index 75%
rename from dist/modules/easings/eases.d.ts
rename to dist/modules/easings/eases/parser.d.ts
index bf7bf304..de449643 100644
--- a/dist/modules/easings/eases.d.ts
+++ b/dist/modules/easings/eases/parser.d.ts
@@ -1,8 +1,25 @@
+/**
+ * @import {
+ * EasingFunction,
+ * EasingFunctionWithParams,
+ * EasingParam,
+ * BackEasing,
+ * ElasticEasing,
+ * PowerEasing,
+ * } from '../../types/index.js'
+*/
+/** @type {PowerEasing} */
+export const easeInPower: PowerEasing;
+/**
+ * @callback EaseType
+ * @param {EasingFunction} Ease
+ * @return {EasingFunction}
+ */
+/** @type {Record<String, EaseType>} */
+export const easeTypes: Record<string, EaseType>;
export namespace eases {
- export let linear: typeof import("./linear.js").linear;
- export let irregular: typeof import("./irregular.js").irregular;
- export let steps: typeof import("./steps.js").steps;
- export let cubicBezier: typeof import("./cubic-bezier.js").cubicBezier;
+ export let linear: typeof import("../none.js").none;
+ export let none: typeof import("../none.js").none;
let _in: PowerEasing;
export { _in as in };
export let out: PowerEasing;
@@ -49,12 +66,12 @@ export namespace eases {
export let inOutElastic: ElasticEasing;
export let outInElastic: ElasticEasing;
}
+export function parseEaseString(string: string): EasingFunction;
export function parseEase(ease: EasingParam): EasingFunction;
+export type EaseType = (Ease: EasingFunction) => EasingFunction;
export type EasesFunctions = {
- linear: typeof linear;
- irregular: typeof irregular;
- steps: typeof steps;
- cubicBezier: typeof cubicBezier;
+ linear: typeof none;
+ none: typeof none;
in: PowerEasing;
out: PowerEasing;
inOut: PowerEasing;
@@ -100,12 +117,9 @@ export type EasesFunctions = {
inOutElastic: ElasticEasing;
outInElastic: ElasticEasing;
};
-import type { PowerEasing } from '../types/index.js';
-import type { EasingFunction } from '../types/index.js';
-import type { BackEasing } from '../types/index.js';
-import type { ElasticEasing } from '../types/index.js';
-import type { EasingParam } from '../types/index.js';
-import { linear as linear_1 } from './linear.js';
-import { irregular as irregular_1 } from './irregular.js';
-import { steps as steps_1 } from './steps.js';
-import { cubicBezier as cubicBezier_1 } from './cubic-bezier.js';
+import type { PowerEasing } from '../../types/index.js';
+import type { EasingFunction } from '../../types/index.js';
+import type { BackEasing } from '../../types/index.js';
+import type { ElasticEasing } from '../../types/index.js';
+import type { EasingParam } from '../../types/index.js';
+import { none as none_1 } from '../none.js';
diff --git a/dist/modules/easings/eases.js b/dist/modules/easings/eases/parser.js
similarity index 62%
rename from dist/modules/easings/eases.js
rename to dist/modules/easings/eases/parser.js
index 1638b9ad..bb5539c9 100644
--- a/dist/modules/easings/eases.js
+++ b/dist/modules/easings/eases/parser.js
@@ -5,14 +5,9 @@
* @copyright 2025 - Julian Garnier
*/
-import { emptyString, minValue } from '../core/consts.js';
-import { pow, sin, sqrt, cos, isFnc, isStr, clamp, asin, PI } from '../core/helpers.js';
-import { easeTypes, easeInPower, parseEaseString } from './parser.js';
-import { none } from './none.js';
-import { cubicBezier } from './cubic-bezier.js';
-import { steps } from './steps.js';
-import { linear } from './linear.js';
-import { irregular } from './irregular.js';
+import { emptyString, minValue } from '../../core/consts.js';
+import { pow, sin, sqrt, cos, isStr, stringStartsWith, isFnc, clamp, asin, PI } from '../../core/helpers.js';
+import { none } from '../none.js';
/**
* @import {
@@ -22,9 +17,27 @@ import { irregular } from './irregular.js';
* BackEasing,
* ElasticEasing,
* PowerEasing,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
+
+/** @type {PowerEasing} */
+const easeInPower = (p = 1.68) => t => pow(t, +p);
+
+/**
+ * @callback EaseType
+ * @param {EasingFunction} Ease
+ * @return {EasingFunction}
+ */
+
+/** @type {Record<String, EaseType>} */
+const easeTypes = {
+ in: easeIn => t => easeIn(t),
+ out: easeIn => t => 1 - easeIn(1 - t),
+ inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
+ outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
+};
+
/**
* Easing functions adapted and simplified from https://robertpenner.com/easing/
* (c) 2001 Robert Penner
@@ -53,7 +66,7 @@ const easeInFunctions = {
return 1 / pow(4, 3 - b) - 7.5625 * pow((pow2 * 3 - 2) / 22 - t, 2);
},
/** @type {BackEasing} */
- Back: (overshoot = 1.70158) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
+ Back: (overshoot = 1.7) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
/** @type {ElasticEasing} */
Elastic: (amplitude = 1, period = .3) => {
const a = clamp(+amplitude, 1, 10);
@@ -66,10 +79,8 @@ const easeInFunctions = {
/**
* @typedef {Object} EasesFunctions
- * @property {typeof linear} linear
- * @property {typeof irregular} irregular
- * @property {typeof steps} steps
- * @property {typeof cubicBezier} cubicBezier
+ * @property {typeof none} linear
+ * @property {typeof none} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
@@ -117,7 +128,7 @@ const easeInFunctions = {
*/
const eases = (/*#__PURE__ */ (() => {
- const list = { linear, irregular, steps, cubicBezier };
+ const list = { linear: none, none: none };
for (let type in easeTypes) {
for (let name in easeInFunctions) {
const easeIn = easeInFunctions[name];
@@ -133,14 +144,42 @@ const eases = (/*#__PURE__ */ (() => {
})());
/** @type {Record<String, EasingFunction>} */
-const JSEasesLookups = { linear: none };
+const easesLookups = { linear: none, none: none };
+
+/**
+ * @param {String} string
+ * @return {EasingFunction}
+ */
+const parseEaseString = (string) => {
+ if (easesLookups[string]) return easesLookups[string];
+ if (string.indexOf('(') <= -1) {
+ const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
+ const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(eases[string])() : eases[string]);
+ return parsedFn ? easesLookups[string] = parsedFn : none;
+ } else {
+ const split = string.slice(0, -1).split('(');
+ const parsedFn = /** @type {EasingFunctionWithParams} */(eases[split[0]]);
+ return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
+ }
+};
+
+const deprecated = ['steps(', 'irregular(', 'linear(', 'cubicBezier('];
/**
* @param {EasingParam} ease
* @return {EasingFunction}
*/
-const parseEase = ease => isFnc(ease) ? ease :
- isStr(ease) ? parseEaseString(/** @type {String} */(ease), eases, JSEasesLookups) :
- none;
+const parseEase = ease => {
+ if (isStr(ease)) {
+ for (let i = 0, l = deprecated.length; i < l; i++) {
+ if (stringStartsWith(ease, deprecated[i])) {
+ console.warn(`String syntax for \`ease: "${ease}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${ease}\``);
+ return none;
+ }
+ }
+ }
+ const easeFunc = isFnc(ease) ? ease : isStr(ease) ? parseEaseString(/** @type {String} */(ease)) : none;
+ return easeFunc;
+};
-export { eases, parseEase };
+export { easeInPower, easeTypes, eases, parseEase, parseEaseString };
diff --git a/dist/modules/easings/index.cjs b/dist/modules/easings/index.cjs
index 92bdd6b7..1c93b393 100644
--- a/dist/modules/easings/index.cjs
+++ b/dist/modules/easings/index.cjs
@@ -7,18 +7,20 @@
'use strict';
-var none = require('./none.cjs');
-var cubicBezier = require('./cubic-bezier.cjs');
-var steps = require('./steps.cjs');
-var linear = require('./linear.cjs');
-var irregular = require('./irregular.cjs');
-var eases = require('./eases.cjs');
+var index = require('./cubic-bezier/index.cjs');
+var index$1 = require('./steps/index.cjs');
+var index$2 = require('./linear/index.cjs');
+var index$3 = require('./irregular/index.cjs');
+var index$4 = require('./spring/index.cjs');
+var parser = require('./eases/parser.cjs');
-exports.none = none.none;
-exports.cubicBezier = cubicBezier.cubicBezier;
-exports.steps = steps.steps;
-exports.linear = linear.linear;
-exports.irregular = irregular.irregular;
-exports.eases = eases.eases;
+exports.cubicBezier = index.cubicBezier;
+exports.steps = index$1.steps;
+exports.linear = index$2.linear;
+exports.irregular = index$3.irregular;
+exports.Spring = index$4.Spring;
+exports.createSpring = index$4.createSpring;
+exports.spring = index$4.spring;
+exports.eases = parser.eases;
diff --git a/dist/modules/easings/index.d.ts b/dist/modules/easings/index.d.ts
index 418a27e5..e6b04850 100644
--- a/dist/modules/easings/index.d.ts
+++ b/dist/modules/easings/index.d.ts
@@ -1,6 +1,6 @@
-export { none } from "./none.js";
-export { cubicBezier } from "./cubic-bezier.js";
-export { steps } from "./steps.js";
-export { linear } from "./linear.js";
-export { irregular } from "./irregular.js";
-export { eases } from "./eases.js";
+export * from "./cubic-bezier/index.js";
+export * from "./steps/index.js";
+export * from "./linear/index.js";
+export * from "./irregular/index.js";
+export * from "./spring/index.js";
+export * from "./eases/index.js";
diff --git a/dist/modules/easings/index.js b/dist/modules/easings/index.js
index 38b22a4a..dc42558b 100644
--- a/dist/modules/easings/index.js
+++ b/dist/modules/easings/index.js
@@ -5,9 +5,9 @@
* @copyright 2025 - Julian Garnier
*/
-export { none } from './none.js';
-export { cubicBezier } from './cubic-bezier.js';
-export { steps } from './steps.js';
-export { linear } from './linear.js';
-export { irregular } from './irregular.js';
-export { eases } from './eases.js';
+export { cubicBezier } from './cubic-bezier/index.js';
+export { steps } from './steps/index.js';
+export { linear } from './linear/index.js';
+export { irregular } from './irregular/index.js';
+export { Spring, createSpring, spring } from './spring/index.js';
+export { eases } from './eases/parser.js';
diff --git a/dist/modules/easings/irregular.cjs b/dist/modules/easings/irregular/index.cjs
similarity index 85%
rename from dist/modules/easings/irregular.cjs
rename to dist/modules/easings/irregular/index.cjs
index acaeadcb..f1cc6bda 100644
--- a/dist/modules/easings/irregular.cjs
+++ b/dist/modules/easings/irregular/index.cjs
@@ -7,13 +7,13 @@
'use strict';
-var helpers = require('../core/helpers.cjs');
-var linear = require('./linear.cjs');
+var helpers = require('../../core/helpers.cjs');
+var index = require('../linear/index.cjs');
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
@@ -35,7 +35,7 @@ const irregular = (length = 10, randomness = 1) => {
values.push(helpers.clamp(randomValue, previousValue, 1));
}
values.push(1);
- return linear.linear(...values);
+ return index.linear(...values);
};
exports.irregular = irregular;
diff --git a/dist/modules/easings/irregular.d.ts b/dist/modules/easings/irregular/index.d.ts
similarity index 57%
rename from dist/modules/easings/irregular.d.ts
rename to dist/modules/easings/irregular/index.d.ts
index e56b1247..58cce3ce 100644
--- a/dist/modules/easings/irregular.d.ts
+++ b/dist/modules/easings/irregular/index.d.ts
@@ -1,2 +1,2 @@
export function irregular(length?: number, randomness?: number): EasingFunction;
-import type { EasingFunction } from '../types/index.js';
+import type { EasingFunction } from '../../types/index.js';
diff --git a/dist/modules/easings/irregular.js b/dist/modules/easings/irregular/index.js
similarity index 88%
rename from dist/modules/easings/irregular.js
rename to dist/modules/easings/irregular/index.js
index 6525d087..bf0f01fa 100644
--- a/dist/modules/easings/irregular.js
+++ b/dist/modules/easings/irregular/index.js
@@ -5,13 +5,13 @@
* @copyright 2025 - Julian Garnier
*/
-import { clamp } from '../core/helpers.js';
-import { linear } from './linear.js';
+import { clamp } from '../../core/helpers.js';
+import { linear } from '../linear/index.js';
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/dist/modules/easings/linear.cjs b/dist/modules/easings/linear/index.cjs
similarity index 93%
rename from dist/modules/easings/linear.cjs
rename to dist/modules/easings/linear/index.cjs
index a7182d7a..f6156b72 100644
--- a/dist/modules/easings/linear.cjs
+++ b/dist/modules/easings/linear/index.cjs
@@ -7,13 +7,13 @@
'use strict';
-var helpers = require('../core/helpers.cjs');
-var none = require('./none.cjs');
+var helpers = require('../../core/helpers.cjs');
+var none = require('../none.cjs');
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/dist/modules/easings/linear.d.ts b/dist/modules/easings/linear/index.d.ts
similarity index 53%
rename from dist/modules/easings/linear.d.ts
rename to dist/modules/easings/linear/index.d.ts
index 7916864f..a80d57d4 100644
--- a/dist/modules/easings/linear.d.ts
+++ b/dist/modules/easings/linear/index.d.ts
@@ -1,2 +1,2 @@
export function linear(...args: (string | number)[]): EasingFunction;
-import type { EasingFunction } from '../types/index.js';
+import type { EasingFunction } from '../../types/index.js';
diff --git a/dist/modules/easings/linear.js b/dist/modules/easings/linear/index.js
similarity index 91%
rename from dist/modules/easings/linear.js
rename to dist/modules/easings/linear/index.js
index c18f1b82..b198c386 100644
--- a/dist/modules/easings/linear.js
+++ b/dist/modules/easings/linear/index.js
@@ -5,13 +5,13 @@
* @copyright 2025 - Julian Garnier
*/
-import { isStr, parseNumber, isUnd } from '../core/helpers.js';
-import { none } from './none.js';
+import { isStr, parseNumber, isUnd } from '../../core/helpers.js';
+import { none } from '../none.js';
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/dist/modules/easings/parser.cjs b/dist/modules/easings/parser.cjs
deleted file mode 100644
index 2ebe5cfb..00000000
--- a/dist/modules/easings/parser.cjs
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Anime.js - easings - CJS
- * @version v4.2.0
- * @license MIT
- * @copyright 2025 - Julian Garnier
- */
-
-'use strict';
-
-var helpers = require('../core/helpers.cjs');
-var none = require('./none.cjs');
-
-/**
- * @import {
- * EasingFunction,
- * PowerEasing,
- * EasingFunctionWithParams,
- * } from '../types/index.js'
-*/
-
-/** @type {PowerEasing} */
-const easeInPower = (p = 1.68) => t => helpers.pow(t, +p);
-
-/**
- * @callback EaseType
- * @param {EasingFunction} Ease
- * @return {EasingFunction}
- */
-
-/** @type {Record<String, EaseType>} */
-const easeTypes = {
- in: easeIn => t => easeIn(t),
- out: easeIn => t => 1 - easeIn(1 - t),
- inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
- outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
-};
-
-/**
- * @param {String} string
- * @param {Record<String, EasingFunctionWithParams|EasingFunction>} easesFunctions
- * @param {Object} easesLookups
- * @return {EasingFunction}
- */
-const parseEaseString = (string, easesFunctions, easesLookups) => {
- if (easesLookups[string]) return easesLookups[string];
- if (string.indexOf('(') <= -1) {
- const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
- const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(easesFunctions[string])() : easesFunctions[string]);
- return parsedFn ? easesLookups[string] = parsedFn : none.none;
- } else {
- const split = string.slice(0, -1).split('(');
- const parsedFn = /** @type {EasingFunctionWithParams} */(easesFunctions[split[0]]);
- return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none.none;
- }
-};
-
-exports.easeInPower = easeInPower;
-exports.easeTypes = easeTypes;
-exports.parseEaseString = parseEaseString;
diff --git a/dist/modules/easings/parser.d.ts b/dist/modules/easings/parser.d.ts
deleted file mode 100644
index 4213dcfe..00000000
--- a/dist/modules/easings/parser.d.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * @import {
- * EasingFunction,
- * PowerEasing,
- * EasingFunctionWithParams,
- * } from '../types/index.js'
-*/
-/** @type {PowerEasing} */
-export const easeInPower: PowerEasing;
-/**
- * @callback EaseType
- * @param {EasingFunction} Ease
- * @return {EasingFunction}
- */
-/** @type {Record<String, EaseType>} */
-export const easeTypes: Record<string, EaseType>;
-export function parseEaseString(string: string, easesFunctions: Record<string, EasingFunctionWithParams | EasingFunction>, easesLookups: any): EasingFunction;
-export type EaseType = (Ease: EasingFunction) => EasingFunction;
-import type { PowerEasing } from '../types/index.js';
-import type { EasingFunctionWithParams } from '../types/index.js';
-import type { EasingFunction } from '../types/index.js';
diff --git a/dist/modules/easings/parser.js b/dist/modules/easings/parser.js
deleted file mode 100644
index 9409bf57..00000000
--- a/dist/modules/easings/parser.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Anime.js - easings - ESM
- * @version v4.2.0
- * @license MIT
- * @copyright 2025 - Julian Garnier
- */
-
-import { pow } from '../core/helpers.js';
-import { none } from './none.js';
-
-/**
- * @import {
- * EasingFunction,
- * PowerEasing,
- * EasingFunctionWithParams,
- * } from '../types/index.js'
-*/
-
-/** @type {PowerEasing} */
-const easeInPower = (p = 1.68) => t => pow(t, +p);
-
-/**
- * @callback EaseType
- * @param {EasingFunction} Ease
- * @return {EasingFunction}
- */
-
-/** @type {Record<String, EaseType>} */
-const easeTypes = {
- in: easeIn => t => easeIn(t),
- out: easeIn => t => 1 - easeIn(1 - t),
- inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
- outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
-};
-
-/**
- * @param {String} string
- * @param {Record<String, EasingFunctionWithParams|EasingFunction>} easesFunctions
- * @param {Object} easesLookups
- * @return {EasingFunction}
- */
-const parseEaseString = (string, easesFunctions, easesLookups) => {
- if (easesLookups[string]) return easesLookups[string];
- if (string.indexOf('(') <= -1) {
- const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
- const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(easesFunctions[string])() : easesFunctions[string]);
- return parsedFn ? easesLookups[string] = parsedFn : none;
- } else {
- const split = string.slice(0, -1).split('(');
- const parsedFn = /** @type {EasingFunctionWithParams} */(easesFunctions[split[0]]);
- return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
- }
-};
-
-export { easeInPower, easeTypes, parseEaseString };
diff --git a/dist/modules/easings/spring/index.cjs b/dist/modules/easings/spring/index.cjs
new file mode 100644
index 00000000..d7661799
--- /dev/null
+++ b/dist/modules/easings/spring/index.cjs
@@ -0,0 +1,255 @@
+/**
+ * Anime.js - easings - CJS
+ * @version v4.2.0
+ * @license MIT
+ * @copyright 2025 - Julian Garnier
+ */
+
+'use strict';
+
+var consts = require('../../core/consts.cjs');
+var globals = require('../../core/globals.cjs');
+var helpers = require('../../core/helpers.cjs');
+var values = require('../../core/values.cjs');
+
+/**
+ * @import {
+ * JSAnimation,
+ * } from '../../animation/animation.js'
+ */
+
+/**
+ * @import {
+ * EasingFunction,
+ * SpringParams,
+ * Callback,
+ * } from '../../types/index.js'
+*/
+
+/*
+ * Spring easing solver adapted from https://webkit.org/demos/spring/spring.js
+ * (c) 2016 Webkit - Apple Inc
+ */
+
+const maxSpringParamValue = consts.K * 10;
+
+class Spring {
+ /**
+ * @param {SpringParams} [parameters]
+ */
+ constructor(parameters = {}) {
+ const hasBounceOrDuration = !helpers.isUnd(parameters.bounce) || !helpers.isUnd(parameters.duration);
+ this.timeStep = .02; // Interval fed to the solver to calculate duration
+ this.restThreshold = .0005; // Values below this threshold are considered resting position
+ this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
+ this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
+ this.maxRestSteps = this.restDuration / this.timeStep / consts.K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
+ this.maxIterations = this.maxDuration / this.timeStep / consts.K; // Calculate the maximum iterations allowed based on maxDuration
+ this.bn = helpers.clamp(values.setValue(parameters.bounce, .5), -1, 1); // The bounce percentage between -1 and 1.
+ this.pd = helpers.clamp(values.setValue(parameters.duration, 628), 10 * globals.globals.timeScale, maxSpringParamValue * globals.globals.timeScale); // The perceived duration
+ this.m = helpers.clamp(values.setValue(parameters.mass, 1), 1, maxSpringParamValue);
+ this.s = helpers.clamp(values.setValue(parameters.stiffness, 100), consts.minValue, maxSpringParamValue);
+ this.d = helpers.clamp(values.setValue(parameters.damping, 10), consts.minValue, maxSpringParamValue);
+ this.v = helpers.clamp(values.setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
+ this.w0 = 0;
+ this.zeta = 0;
+ this.wd = 0;
+ this.b = 0;
+ this.completed = false;
+ this.solverDuration = 0;
+ this.settlingDuration = 0;
+ /** @type {JSAnimation} */
+ this.parent = null;
+ /** @type {Callback<JSAnimation>} */
+ this.onComplete = parameters.onComplete || consts.noop;
+ if (hasBounceOrDuration) this.calculateSDFromBD();
+ this.compute();
+ /** @type {EasingFunction} */
+ this.ease = t => {
+ const currentTime = t * this.settlingDuration;
+ const completed = this.completed;
+ const perceivedTime = this.pd;
+ if (currentTime >= perceivedTime && !completed) {
+ this.completed = true;
+ this.onComplete(this.parent);
+ }
+ if (currentTime < perceivedTime && completed) {
+ this.completed = false;
+ }
+ return t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
+ };
+ }
+
+ /** @type {EasingFunction} */
+ solve(time) {
+ const { zeta, w0, wd, b } = this;
+ let t = time;
+ if (zeta < 1) {
+ // Underdamped
+ t = helpers.exp(-t * zeta * w0) * (1 * helpers.cos(wd * t) + b * helpers.sin(wd * t));
+ } else if (zeta === 1) {
+ // Critically damped
+ t = (1 + b * t) * helpers.exp(-t * w0);
+ } else {
+ // Overdamped
+ // Using exponential instead of cosh and sinh functions to prevent Infinity
+ // Original exp(-zeta * w0 * t) * (cosh(wd * t) + b * sinh(wd * t))
+ t = ((1 + b) * helpers.exp((-zeta * w0 + wd) * t) + (1 - b) * helpers.exp((-zeta * w0 - wd) * t)) / 2;
+ }
+ return 1 - t;
+ }
+
+ calculateSDFromBD() {
+ // Apple's SwiftUI perceived spring duration implementation https://developer.apple.com/videos/play/wwdc2023/10158/?time=1010
+ // Equations taken from Kevin Grajeda's article https://www.kvin.me/posts/effortless-ui-spring-animations
+ const pds = globals.globals.timeScale === 1 ? this.pd / consts.K : this.pd;
+ // Mass and velocity should be set to their default values
+ this.m = 1;
+ this.v = 0;
+ // Stiffness = (2π ÷ perceptualDuration)²
+ this.s = helpers.pow((2 * helpers.PI) / pds, 2);
+ if (this.bn >= 0) {
+ // For bounce ≥ 0 (critically damped to underdamped)
+ // damping = ((1 - bounce) × 4π) ÷ perceptualDuration
+ this.d = ((1 - this.bn) * 4 * helpers.PI) / pds;
+ } else {
+ // For bounce < 0 (overdamped)
+ // damping = 4π ÷ (perceptualDuration × (1 + bounce))
+ // Note: (1 + bounce) is positive since bounce is negative
+ this.d = (4 * helpers.PI) / (pds * (1 + this.bn));
+ }
+ this.s = helpers.round(helpers.clamp(this.s, consts.minValue, maxSpringParamValue), 3);
+ this.d = helpers.round(helpers.clamp(this.d, consts.minValue, 300), 3); // Clamping to 300 is needed to prevent insane values in the solver
+ }
+
+ calculateBDFromSD() {
+ // Calculate perceived duration and bounce from stiffness and damping
+ // Note: We assumes m = 1 and v = 0 for these calculations
+ const pds = (2 * helpers.PI) / helpers.sqrt(this.s);
+ this.pd = pds * (globals.globals.timeScale === 1 ? consts.K : 1);
+ const zeta = this.d / (2 * helpers.sqrt(this.s));
+ if (zeta <= 1) {
+ // Critically damped to underdamped
+ this.bn = 1 - (this.d * pds) / (4 * helpers.PI);
+ } else {
+ // Overdamped
+ this.bn = (4 * helpers.PI) / (this.d * pds) - 1;
+ }
+ this.bn = helpers.round(helpers.clamp(this.bn, -1, 1), 3);
+ this.pd = helpers.round(helpers.clamp(this.pd, 10 * globals.globals.timeScale, maxSpringParamValue * globals.globals.timeScale), 3);
+ }
+
+ compute() {
+ const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
+ const w0 = this.w0 = helpers.clamp(helpers.sqrt(s / m), consts.minValue, consts.K);
+ const bouncedZeta = this.zeta = d / (2 * helpers.sqrt(s * m));
+ // Calculate wd based on damping type
+ if (bouncedZeta < 1) {
+ // Underdamped
+ this.wd = w0 * helpers.sqrt(1 - bouncedZeta * bouncedZeta);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ } else if (bouncedZeta === 1) {
+ // Critically damped
+ this.wd = 0;
+ this.b = -v + w0;
+ } else {
+ // Overdamped
+ this.wd = w0 * helpers.sqrt(bouncedZeta * bouncedZeta - 1);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ }
+
+ let solverTime = 0;
+ let restSteps = 0;
+ let iterations = 0;
+ while (restSteps <= maxRestSteps && iterations <= maxIterations) {
+ if (helpers.abs(1 - this.solve(solverTime)) < restThreshold) {
+ restSteps++;
+ } else {
+ restSteps = 0;
+ }
+ this.solverDuration = solverTime;
+ solverTime += timeStep;
+ iterations++;
+ }
+ this.settlingDuration = helpers.round(this.solverDuration * consts.K, 0) * globals.globals.timeScale;
+ }
+
+ get bounce() {
+ return this.bn;
+ }
+
+ set bounce(v) {
+ this.bn = helpers.clamp(values.setValue(v, 1), -1, 1);
+ this.calculateSDFromBD();
+ this.compute();
+ }
+
+ get duration() {
+ return this.pd;
+ }
+
+ set duration(v) {
+ this.pd = helpers.clamp(values.setValue(v, 1), 10 * globals.globals.timeScale, maxSpringParamValue * globals.globals.timeScale);
+ this.calculateSDFromBD();
+ this.compute();
+ }
+
+ get stiffness() {
+ return this.s;
+ }
+
+ set stiffness(v) {
+ this.s = helpers.clamp(values.setValue(v, 100), consts.minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
+ this.compute();
+ }
+
+ get damping() {
+ return this.d;
+ }
+
+ set damping(v) {
+ this.d = helpers.clamp(values.setValue(v, 10), consts.minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
+ this.compute();
+ }
+
+ get mass() {
+ return this.m;
+ }
+
+ set mass(v) {
+ this.m = helpers.clamp(values.setValue(v, 1), 1, maxSpringParamValue);
+ this.compute();
+ }
+
+ get velocity() {
+ return this.v;
+ }
+
+ set velocity(v) {
+ this.v = helpers.clamp(values.setValue(v, 0), -maxSpringParamValue, maxSpringParamValue);
+ this.compute();
+ }
+}
+
+/**
+ * @param {SpringParams} [parameters]
+ * @returns {Spring}
+ */
+const spring = (parameters) => new Spring(parameters);
+
+/**
+ * @deprecated createSpring() is deprecated use spring() instead
+ *
+ * @param {SpringParams} [parameters]
+ * @returns {Spring}
+ */
+const createSpring = (parameters) => {
+ console.warn('createSpring() is deprecated use spring() instead');
+ return new Spring(parameters);
+};
+
+exports.Spring = Spring;
+exports.createSpring = createSpring;
+exports.spring = spring;
diff --git a/dist/modules/spring/spring.d.ts b/dist/modules/easings/spring/index.d.ts
similarity index 54%
rename from dist/modules/spring/spring.d.ts
rename to dist/modules/easings/spring/index.d.ts
index 2b00317f..889c3e9d 100644
--- a/dist/modules/spring/spring.d.ts
+++ b/dist/modules/easings/spring/index.d.ts
@@ -9,6 +9,8 @@ export class Spring {
maxDuration: number;
maxRestSteps: number;
maxIterations: number;
+ bn: number;
+ pd: number;
m: number;
s: number;
d: number;
@@ -17,21 +19,35 @@ export class Spring {
zeta: number;
wd: number;
b: number;
+ completed: boolean;
solverDuration: number;
- duration: number;
+ settlingDuration: number;
+ /** @type {JSAnimation} */
+ parent: JSAnimation;
+ /** @type {Callback<JSAnimation>} */
+ onComplete: Callback<JSAnimation>;
/** @type {EasingFunction} */
ease: EasingFunction;
solve(time: number): number;
+ calculateSDFromBD(): void;
+ calculateBDFromSD(): void;
compute(): void;
- set mass(v: number);
- get mass(): number;
+ set bounce(v: number);
+ get bounce(): number;
+ set duration(v: number);
+ get duration(): number;
set stiffness(v: number);
get stiffness(): number;
set damping(v: number);
get damping(): number;
+ set mass(v: number);
+ get mass(): number;
set velocity(v: number);
get velocity(): number;
}
+export function spring(parameters?: SpringParams): Spring;
export function createSpring(parameters?: SpringParams): Spring;
-import type { EasingFunction } from '../types/index.js';
-import type { SpringParams } from '../types/index.js';
+import type { JSAnimation } from '../../animation/animation.js';
+import type { Callback } from '../../types/index.js';
+import type { EasingFunction } from '../../types/index.js';
+import type { SpringParams } from '../../types/index.js';
diff --git a/dist/modules/easings/spring/index.js b/dist/modules/easings/spring/index.js
new file mode 100644
index 00000000..a03de8c5
--- /dev/null
+++ b/dist/modules/easings/spring/index.js
@@ -0,0 +1,251 @@
+/**
+ * Anime.js - easings - ESM
+ * @version v4.2.0
+ * @license MIT
+ * @copyright 2025 - Julian Garnier
+ */
+
+import { K, minValue, noop } from '../../core/consts.js';
+import { globals } from '../../core/globals.js';
+import { isUnd, clamp, pow, PI, round, sqrt, abs, exp, cos, sin } from '../../core/helpers.js';
+import { setValue } from '../../core/values.js';
+
+/**
+ * @import {
+ * JSAnimation,
+ * } from '../../animation/animation.js'
+ */
+
+/**
+ * @import {
+ * EasingFunction,
+ * SpringParams,
+ * Callback,
+ * } from '../../types/index.js'
+*/
+
+/*
+ * Spring easing solver adapted from https://webkit.org/demos/spring/spring.js
+ * (c) 2016 Webkit - Apple Inc
+ */
+
+const maxSpringParamValue = K * 10;
+
+class Spring {
+ /**
+ * @param {SpringParams} [parameters]
+ */
+ constructor(parameters = {}) {
+ const hasBounceOrDuration = !isUnd(parameters.bounce) || !isUnd(parameters.duration);
+ this.timeStep = .02; // Interval fed to the solver to calculate duration
+ this.restThreshold = .0005; // Values below this threshold are considered resting position
+ this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
+ this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
+ this.maxRestSteps = this.restDuration / this.timeStep / K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
+ this.maxIterations = this.maxDuration / this.timeStep / K; // Calculate the maximum iterations allowed based on maxDuration
+ this.bn = clamp(setValue(parameters.bounce, .5), -1, 1); // The bounce percentage between -1 and 1.
+ this.pd = clamp(setValue(parameters.duration, 628), 10 * globals.timeScale, maxSpringParamValue * globals.timeScale); // The perceived duration
+ this.m = clamp(setValue(parameters.mass, 1), 1, maxSpringParamValue);
+ this.s = clamp(setValue(parameters.stiffness, 100), minValue, maxSpringParamValue);
+ this.d = clamp(setValue(parameters.damping, 10), minValue, maxSpringParamValue);
+ this.v = clamp(setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
+ this.w0 = 0;
+ this.zeta = 0;
+ this.wd = 0;
+ this.b = 0;
+ this.completed = false;
+ this.solverDuration = 0;
+ this.settlingDuration = 0;
+ /** @type {JSAnimation} */
+ this.parent = null;
+ /** @type {Callback<JSAnimation>} */
+ this.onComplete = parameters.onComplete || noop;
+ if (hasBounceOrDuration) this.calculateSDFromBD();
+ this.compute();
+ /** @type {EasingFunction} */
+ this.ease = t => {
+ const currentTime = t * this.settlingDuration;
+ const completed = this.completed;
+ const perceivedTime = this.pd;
+ if (currentTime >= perceivedTime && !completed) {
+ this.completed = true;
+ this.onComplete(this.parent);
+ }
+ if (currentTime < perceivedTime && completed) {
+ this.completed = false;
+ }
+ return t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
+ };
+ }
+
+ /** @type {EasingFunction} */
+ solve(time) {
+ const { zeta, w0, wd, b } = this;
+ let t = time;
+ if (zeta < 1) {
+ // Underdamped
+ t = exp(-t * zeta * w0) * (1 * cos(wd * t) + b * sin(wd * t));
+ } else if (zeta === 1) {
+ // Critically damped
+ t = (1 + b * t) * exp(-t * w0);
+ } else {
+ // Overdamped
+ // Using exponential instead of cosh and sinh functions to prevent Infinity
+ // Original exp(-zeta * w0 * t) * (cosh(wd * t) + b * sinh(wd * t))
+ t = ((1 + b) * exp((-zeta * w0 + wd) * t) + (1 - b) * exp((-zeta * w0 - wd) * t)) / 2;
+ }
+ return 1 - t;
+ }
+
+ calculateSDFromBD() {
+ // Apple's SwiftUI perceived spring duration implementation https://developer.apple.com/videos/play/wwdc2023/10158/?time=1010
+ // Equations taken from Kevin Grajeda's article https://www.kvin.me/posts/effortless-ui-spring-animations
+ const pds = globals.timeScale === 1 ? this.pd / K : this.pd;
+ // Mass and velocity should be set to their default values
+ this.m = 1;
+ this.v = 0;
+ // Stiffness = (2π ÷ perceptualDuration)²
+ this.s = pow((2 * PI) / pds, 2);
+ if (this.bn >= 0) {
+ // For bounce ≥ 0 (critically damped to underdamped)
+ // damping = ((1 - bounce) × 4π) ÷ perceptualDuration
+ this.d = ((1 - this.bn) * 4 * PI) / pds;
+ } else {
+ // For bounce < 0 (overdamped)
+ // damping = 4π ÷ (perceptualDuration × (1 + bounce))
+ // Note: (1 + bounce) is positive since bounce is negative
+ this.d = (4 * PI) / (pds * (1 + this.bn));
+ }
+ this.s = round(clamp(this.s, minValue, maxSpringParamValue), 3);
+ this.d = round(clamp(this.d, minValue, 300), 3); // Clamping to 300 is needed to prevent insane values in the solver
+ }
+
+ calculateBDFromSD() {
+ // Calculate perceived duration and bounce from stiffness and damping
+ // Note: We assumes m = 1 and v = 0 for these calculations
+ const pds = (2 * PI) / sqrt(this.s);
+ this.pd = pds * (globals.timeScale === 1 ? K : 1);
+ const zeta = this.d / (2 * sqrt(this.s));
+ if (zeta <= 1) {
+ // Critically damped to underdamped
+ this.bn = 1 - (this.d * pds) / (4 * PI);
+ } else {
+ // Overdamped
+ this.bn = (4 * PI) / (this.d * pds) - 1;
+ }
+ this.bn = round(clamp(this.bn, -1, 1), 3);
+ this.pd = round(clamp(this.pd, 10 * globals.timeScale, maxSpringParamValue * globals.timeScale), 3);
+ }
+
+ compute() {
+ const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
+ const w0 = this.w0 = clamp(sqrt(s / m), minValue, K);
+ const bouncedZeta = this.zeta = d / (2 * sqrt(s * m));
+ // Calculate wd based on damping type
+ if (bouncedZeta < 1) {
+ // Underdamped
+ this.wd = w0 * sqrt(1 - bouncedZeta * bouncedZeta);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ } else if (bouncedZeta === 1) {
+ // Critically damped
+ this.wd = 0;
+ this.b = -v + w0;
+ } else {
+ // Overdamped
+ this.wd = w0 * sqrt(bouncedZeta * bouncedZeta - 1);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ }
+
+ let solverTime = 0;
+ let restSteps = 0;
+ let iterations = 0;
+ while (restSteps <= maxRestSteps && iterations <= maxIterations) {
+ if (abs(1 - this.solve(solverTime)) < restThreshold) {
+ restSteps++;
+ } else {
+ restSteps = 0;
+ }
+ this.solverDuration = solverTime;
+ solverTime += timeStep;
+ iterations++;
+ }
+ this.settlingDuration = round(this.solverDuration * K, 0) * globals.timeScale;
+ }
+
+ get bounce() {
+ return this.bn;
+ }
+
+ set bounce(v) {
+ this.bn = clamp(setValue(v, 1), -1, 1);
+ this.calculateSDFromBD();
+ this.compute();
+ }
+
+ get duration() {
+ return this.pd;
+ }
+
+ set duration(v) {
+ this.pd = clamp(setValue(v, 1), 10 * globals.timeScale, maxSpringParamValue * globals.timeScale);
+ this.calculateSDFromBD();
+ this.compute();
+ }
+
+ get stiffness() {
+ return this.s;
+ }
+
+ set stiffness(v) {
+ this.s = clamp(setValue(v, 100), minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
+ this.compute();
+ }
+
+ get damping() {
+ return this.d;
+ }
+
+ set damping(v) {
+ this.d = clamp(setValue(v, 10), minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
+ this.compute();
+ }
+
+ get mass() {
+ return this.m;
+ }
+
+ set mass(v) {
+ this.m = clamp(setValue(v, 1), 1, maxSpringParamValue);
+ this.compute();
+ }
+
+ get velocity() {
+ return this.v;
+ }
+
+ set velocity(v) {
+ this.v = clamp(setValue(v, 0), -maxSpringParamValue, maxSpringParamValue);
+ this.compute();
+ }
+}
+
+/**
+ * @param {SpringParams} [parameters]
+ * @returns {Spring}
+ */
+const spring = (parameters) => new Spring(parameters);
+
+/**
+ * @deprecated createSpring() is deprecated use spring() instead
+ *
+ * @param {SpringParams} [parameters]
+ * @returns {Spring}
+ */
+const createSpring = (parameters) => {
+ console.warn('createSpring() is deprecated use spring() instead');
+ return new Spring(parameters);
+};
+
+export { Spring, createSpring, spring };
diff --git a/dist/modules/easings/steps.cjs b/dist/modules/easings/steps/index.cjs
similarity index 88%
rename from dist/modules/easings/steps.cjs
rename to dist/modules/easings/steps/index.cjs
index 484abaed..d1c1141f 100644
--- a/dist/modules/easings/steps.cjs
+++ b/dist/modules/easings/steps/index.cjs
@@ -7,12 +7,12 @@
'use strict';
-var helpers = require('../core/helpers.cjs');
+var helpers = require('../../core/helpers.cjs');
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/dist/modules/easings/steps.d.ts b/dist/modules/easings/steps/index.d.ts
similarity index 55%
rename from dist/modules/easings/steps.d.ts
rename to dist/modules/easings/steps/index.d.ts
index 89fce078..0737a942 100644
--- a/dist/modules/easings/steps.d.ts
+++ b/dist/modules/easings/steps/index.d.ts
@@ -1,2 +1,2 @@
export function steps(steps?: number, fromStart?: boolean): EasingFunction;
-import type { EasingFunction } from '../types/index.js';
+import type { EasingFunction } from '../../types/index.js';
diff --git a/dist/modules/easings/steps.js b/dist/modules/easings/steps/index.js
similarity index 85%
rename from dist/modules/easings/steps.js
rename to dist/modules/easings/steps/index.js
index 9d6e476c..8399f20d 100644
--- a/dist/modules/easings/steps.js
+++ b/dist/modules/easings/steps/index.js
@@ -5,12 +5,12 @@
* @copyright 2025 - Julian Garnier
*/
-import { ceil, floor, clamp } from '../core/helpers.js';
+import { ceil, floor, clamp } from '../../core/helpers.js';
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/dist/modules/events/scroll.cjs b/dist/modules/events/scroll.cjs
index 99fb1992..c33a9473 100644
--- a/dist/modules/events/scroll.cjs
+++ b/dist/modules/events/scroll.cjs
@@ -17,7 +17,7 @@ var timer = require('../timer/timer.cjs');
var target = require('../utils/target.cjs');
var time = require('../utils/time.cjs');
var none = require('../easings/none.cjs');
-var eases = require('../easings/eases.cjs');
+var parser = require('../easings/eases/parser.cjs');
/**
* @import {
@@ -368,7 +368,7 @@ class ScrollObserver {
constructor(parameters = {}) {
if (globals.scope.current) globals.scope.current.register(this);
const syncMode = values.setValue(parameters.sync, 'play pause');
- const ease = syncMode ? eases.parseEase(/** @type {EasingParam} */(syncMode)) : null;
+ const ease = syncMode ? parser.parseEase(/** @type {EasingParam} */(syncMode)) : null;
const isLinear = syncMode && (syncMode === 'linear' || syncMode === none.none);
const isEase = syncMode && !(ease === none.none && !isLinear);
const isSmooth = syncMode && (helpers.isNum(syncMode) || syncMode === true || isLinear);
@@ -435,6 +435,8 @@ class ScrollObserver {
/** @type {Boolean} */
this.reverted = false;
/** @type {Boolean} */
+ this.ready = false;
+ /** @type {Boolean} */
this.completed = false;
/** @type {Boolean} */
this.began = false;
@@ -444,8 +446,6 @@ class ScrollObserver {
this.forceEnter = false;
/** @type {Boolean} */
this.hasEntered = false;
- // /** @type {Array.<Number>} */
- // this.offsets = [];
/** @type {Number} */
this.offset = 0;
/** @type {Number} */
@@ -493,6 +493,8 @@ class ScrollObserver {
// Make sure to pause the linked object in case it's added later
linked.pause();
this.linked = linked;
+ // Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
+ if (!helpers.isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
// Try to use a target of the linked object if no target parameters specified
if (!this._params.target) {
/** @type {HTMLElement} */
@@ -532,6 +534,8 @@ class ScrollObserver {
}
refresh() {
+ // This flag is used to prevent running handleScroll() outside of this.refresh() with values not yet calculated
+ this.ready = true;
this.reverted = false;
const params = this._params;
this.repeat = values.setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
@@ -777,8 +781,6 @@ class ScrollObserver {
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
const scrollDelta = offsetEnd - offsetStart;
- // this.offsets[0] = offsetX;
- // this.offsets[1] = offsetY;
this.offset = offset;
this.offsetStart = offsetStart;
this.offsetEnd = offsetEnd;
@@ -797,6 +799,7 @@ class ScrollObserver {
}
handleScroll() {
+ if (!this.ready) return;
const linked = this.linked;
const sync = this.sync;
const syncEase = this.syncEase;
@@ -920,6 +923,7 @@ class ScrollObserver {
this.removeDebug();
}
this.reverted = true;
+ this.ready = false;
return this;
}
diff --git a/dist/modules/events/scroll.d.ts b/dist/modules/events/scroll.d.ts
index 6a06436b..14f0261c 100644
--- a/dist/modules/events/scroll.d.ts
+++ b/dist/modules/events/scroll.d.ts
@@ -59,6 +59,8 @@ export class ScrollObserver {
/** @type {Boolean} */
reverted: boolean;
/** @type {Boolean} */
+ ready: boolean;
+ /** @type {Boolean} */
completed: boolean;
/** @type {Boolean} */
began: boolean;
diff --git a/dist/modules/events/scroll.js b/dist/modules/events/scroll.js
index 02b95054..b2184e50 100644
--- a/dist/modules/events/scroll.js
+++ b/dist/modules/events/scroll.js
@@ -15,7 +15,7 @@ import { Timer } from '../timer/timer.js';
import { get, set } from '../utils/target.js';
import { sync } from '../utils/time.js';
import { none } from '../easings/none.js';
-import { parseEase } from '../easings/eases.js';
+import { parseEase } from '../easings/eases/parser.js';
/**
* @import {
@@ -433,6 +433,8 @@ class ScrollObserver {
/** @type {Boolean} */
this.reverted = false;
/** @type {Boolean} */
+ this.ready = false;
+ /** @type {Boolean} */
this.completed = false;
/** @type {Boolean} */
this.began = false;
@@ -442,8 +444,6 @@ class ScrollObserver {
this.forceEnter = false;
/** @type {Boolean} */
this.hasEntered = false;
- // /** @type {Array.<Number>} */
- // this.offsets = [];
/** @type {Number} */
this.offset = 0;
/** @type {Number} */
@@ -491,6 +491,8 @@ class ScrollObserver {
// Make sure to pause the linked object in case it's added later
linked.pause();
this.linked = linked;
+ // Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
+ if (!isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
// Try to use a target of the linked object if no target parameters specified
if (!this._params.target) {
/** @type {HTMLElement} */
@@ -530,6 +532,8 @@ class ScrollObserver {
}
refresh() {
+ // This flag is used to prevent running handleScroll() outside of this.refresh() with values not yet calculated
+ this.ready = true;
this.reverted = false;
const params = this._params;
this.repeat = setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
@@ -775,8 +779,6 @@ class ScrollObserver {
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
const scrollDelta = offsetEnd - offsetStart;
- // this.offsets[0] = offsetX;
- // this.offsets[1] = offsetY;
this.offset = offset;
this.offsetStart = offsetStart;
this.offsetEnd = offsetEnd;
@@ -795,6 +797,7 @@ class ScrollObserver {
}
handleScroll() {
+ if (!this.ready) return;
const linked = this.linked;
const sync = this.sync;
const syncEase = this.syncEase;
@@ -918,6 +921,7 @@ class ScrollObserver {
this.removeDebug();
}
this.reverted = true;
+ this.ready = false;
return this;
}
diff --git a/dist/modules/index.cjs b/dist/modules/index.cjs
index 44d05bc3..ad04e20d 100644
--- a/dist/modules/index.cjs
+++ b/dist/modules/index.cjs
@@ -14,19 +14,18 @@ var animatable = require('./animatable/animatable.cjs');
var draggable = require('./draggable/draggable.cjs');
var scope = require('./scope/scope.cjs');
var scroll = require('./events/scroll.cjs');
-var spring = require('./spring/spring.cjs');
var engine = require('./engine/engine.cjs');
var index = require('./easings/index.cjs');
var index$1 = require('./utils/index.cjs');
var index$2 = require('./svg/index.cjs');
var index$3 = require('./text/index.cjs');
var waapi = require('./waapi/waapi.cjs');
-var none = require('./easings/none.cjs');
-var cubicBezier = require('./easings/cubic-bezier.cjs');
-var steps = require('./easings/steps.cjs');
-var linear = require('./easings/linear.cjs');
-var irregular = require('./easings/irregular.cjs');
-var eases = require('./easings/eases.cjs');
+var index$4 = require('./easings/cubic-bezier/index.cjs');
+var index$5 = require('./easings/steps/index.cjs');
+var index$6 = require('./easings/linear/index.cjs');
+var index$7 = require('./easings/irregular/index.cjs');
+var index$8 = require('./easings/spring/index.cjs');
+var parser = require('./easings/eases/parser.cjs');
var chainable = require('./utils/chainable.cjs');
var random = require('./utils/random.cjs');
var time = require('./utils/time.cjs');
@@ -56,8 +55,6 @@ exports.createScope = scope.createScope;
exports.ScrollObserver = scroll.ScrollObserver;
exports.onScroll = scroll.onScroll;
exports.scrollContainers = scroll.scrollContainers;
-exports.Spring = spring.Spring;
-exports.createSpring = spring.createSpring;
exports.engine = engine.engine;
exports.easings = index;
exports.utils = index$1;
@@ -65,12 +62,14 @@ exports.svg = index$2;
exports.text = index$3;
exports.WAAPIAnimation = waapi.WAAPIAnimation;
exports.waapi = waapi.waapi;
-exports.none = none.none;
-exports.cubicBezier = cubicBezier.cubicBezier;
-exports.steps = steps.steps;
-exports.linear = linear.linear;
-exports.irregular = irregular.irregular;
-exports.eases = eases.eases;
+exports.cubicBezier = index$4.cubicBezier;
+exports.steps = index$5.steps;
+exports.linear = index$6.linear;
+exports.irregular = index$7.irregular;
+exports.Spring = index$8.Spring;
+exports.createSpring = index$8.createSpring;
+exports.spring = index$8.spring;
+exports.eases = parser.eases;
exports.clamp = chainable.clamp;
exports.damp = chainable.damp;
exports.degToRad = chainable.degToRad;
diff --git a/dist/modules/index.d.ts b/dist/modules/index.d.ts
index f11be9dc..36082f82 100644
--- a/dist/modules/index.d.ts
+++ b/dist/modules/index.d.ts
@@ -5,7 +5,6 @@ export * from "./animatable/index.js";
export * from "./draggable/index.js";
export * from "./scope/index.js";
export * from "./events/index.js";
-export * from "./spring/index.js";
export * from "./engine/index.js";
export * from "./easings/index.js";
export * from "./utils/index.js";
diff --git a/dist/modules/index.js b/dist/modules/index.js
index f98e9dff..8c184357 100644
--- a/dist/modules/index.js
+++ b/dist/modules/index.js
@@ -12,7 +12,6 @@ export { Animatable, createAnimatable } from './animatable/animatable.js';
export { Draggable, createDraggable } from './draggable/draggable.js';
export { Scope, createScope } from './scope/scope.js';
export { ScrollObserver, onScroll, scrollContainers } from './events/scroll.js';
-export { Spring, createSpring } from './spring/spring.js';
export { engine } from './engine/engine.js';
import * as index from './easings/index.js';
export { index as easings };
@@ -23,12 +22,12 @@ export { index$2 as svg };
import * as index$3 from './text/index.js';
export { index$3 as text };
export { WAAPIAnimation, waapi } from './waapi/waapi.js';
-export { none } from './easings/none.js';
-export { cubicBezier } from './easings/cubic-bezier.js';
-export { steps } from './easings/steps.js';
-export { linear } from './easings/linear.js';
-export { irregular } from './easings/irregular.js';
-export { eases } from './easings/eases.js';
+export { cubicBezier } from './easings/cubic-bezier/index.js';
+export { steps } from './easings/steps/index.js';
+export { linear } from './easings/linear/index.js';
+export { irregular } from './easings/irregular/index.js';
+export { Spring, createSpring, spring } from './easings/spring/index.js';
+export { eases } from './easings/eases/parser.js';
export { clamp, damp, degToRad, lerp, mapRange, padEnd, padStart, radToDeg, round, roundPad, snap, wrap } from './utils/chainable.js';
export { createSeededRandom, random, randomPick, shuffle } from './utils/random.js';
export { keepTime, sync } from './utils/time.js';
diff --git a/dist/modules/spring/index.cjs b/dist/modules/spring/index.cjs
deleted file mode 100644
index 9638c053..00000000
--- a/dist/modules/spring/index.cjs
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Anime.js - spring - CJS
- * @version v4.2.0
- * @license MIT
- * @copyright 2025 - Julian Garnier
- */
-
-'use strict';
-
-var spring = require('./spring.cjs');
-
-
-
-exports.Spring = spring.Spring;
-exports.createSpring = spring.createSpring;
diff --git a/dist/modules/spring/index.d.ts b/dist/modules/spring/index.d.ts
deleted file mode 100644
index b0e21f92..00000000
--- a/dist/modules/spring/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./spring.js";
diff --git a/dist/modules/spring/spring.cjs b/dist/modules/spring/spring.cjs
deleted file mode 100644
index 0acba085..00000000
--- a/dist/modules/spring/spring.cjs
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Anime.js - spring - CJS
- * @version v4.2.0
- * @license MIT
- * @copyright 2025 - Julian Garnier
- */
-
-'use strict';
-
-var consts = require('../core/consts.cjs');
-var globals = require('../core/globals.cjs');
-var helpers = require('../core/helpers.cjs');
-var values = require('../core/values.cjs');
-
-/**
- * @import {
- * EasingFunction,
- * SpringParams,
- * } from '../types/index.js'
-*/
-
-/*
- * Spring ease solver adapted from https://webkit.org/demos/spring/spring.js
- * (c) 2016 Webkit - Apple Inc
- */
-
-const maxSpringParamValue = consts.K * 10;
-
-class Spring {
- /**
- * @param {SpringParams} [parameters]
- */
- constructor(parameters = {}) {
- this.timeStep = .02; // Interval fed to the solver to calculate duration
- this.restThreshold = .0005; // Values below this threshold are considered resting position
- this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
- this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
- this.maxRestSteps = this.restDuration / this.timeStep / consts.K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
- this.maxIterations = this.maxDuration / this.timeStep / consts.K; // Calculate the maximum iterations allowed based on maxDuration
- this.m = helpers.clamp(values.setValue(parameters.mass, 1), 0, maxSpringParamValue);
- this.s = helpers.clamp(values.setValue(parameters.stiffness, 100), 1, maxSpringParamValue);
- this.d = helpers.clamp(values.setValue(parameters.damping, 10), .1, maxSpringParamValue);
- this.v = helpers.clamp(values.setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
- this.w0 = 0;
- this.zeta = 0;
- this.wd = 0;
- this.b = 0;
- this.solverDuration = 0;
- this.duration = 0;
- this.compute();
- /** @type {EasingFunction} */
- this.ease = t => t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
- }
-
- /** @type {EasingFunction} */
- solve(time) {
- const { zeta, w0, wd, b } = this;
- let t = time;
- if (zeta < 1) {
- t = helpers.exp(-t * zeta * w0) * (1 * helpers.cos(wd * t) + b * helpers.sin(wd * t));
- } else {
- t = (1 + b * t) * helpers.exp(-t * w0);
- }
- return 1 - t;
- }
-
- compute() {
- const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
- const w0 = this.w0 = helpers.clamp(helpers.sqrt(s / m), consts.minValue, consts.K);
- const zeta = this.zeta = d / (2 * helpers.sqrt(s * m));
- const wd = this.wd = zeta < 1 ? w0 * helpers.sqrt(1 - zeta * zeta) : 0;
- this.b = zeta < 1 ? (zeta * w0 + -v) / wd : -v + w0;
- let solverTime = 0;
- let restSteps = 0;
- let iterations = 0;
- while (restSteps < maxRestSteps && iterations < maxIterations) {
- if (helpers.abs(1 - this.solve(solverTime)) < restThreshold) {
- restSteps++;
- } else {
- restSteps = 0;
- }
- this.solverDuration = solverTime;
- solverTime += timeStep;
- iterations++;
- }
- this.duration = helpers.round(this.solverDuration * consts.K, 0) * globals.globals.timeScale;
- }
-
- get mass() {
- return this.m;
- }
-
- set mass(v) {
- this.m = helpers.clamp(values.setValue(v, 1), 0, maxSpringParamValue);
- this.compute();
- }
-
- get stiffness() {
- return this.s;
- }
-
- set stiffness(v) {
- this.s = helpers.clamp(values.setValue(v, 100), 1, maxSpringParamValue);
- this.compute();
- }
-
- get damping() {
- return this.d;
- }
-
- set damping(v) {
- this.d = helpers.clamp(values.setValue(v, 10), .1, maxSpringParamValue);
- this.compute();
- }
-
- get velocity() {
- return this.v;
- }
-
- set velocity(v) {
- this.v = helpers.clamp(values.setValue(v, 0), -maxSpringParamValue, maxSpringParamValue);
- this.compute();
- }
-}
-
-/**
- * @param {SpringParams} [parameters]
- * @returns {Spring}
- */
-const createSpring = (parameters) => new Spring(parameters);
-
-exports.Spring = Spring;
-exports.createSpring = createSpring;
diff --git a/dist/modules/spring/spring.js b/dist/modules/spring/spring.js
deleted file mode 100644
index 4028b209..00000000
--- a/dist/modules/spring/spring.js
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * Anime.js - spring - ESM
- * @version v4.2.0
- * @license MIT
- * @copyright 2025 - Julian Garnier
- */
-
-import { K, minValue } from '../core/consts.js';
-import { globals } from '../core/globals.js';
-import { clamp, sqrt, abs, round, exp, cos, sin } from '../core/helpers.js';
-import { setValue } from '../core/values.js';
-
-/**
- * @import {
- * EasingFunction,
- * SpringParams,
- * } from '../types/index.js'
-*/
-
-/*
- * Spring ease solver adapted from https://webkit.org/demos/spring/spring.js
- * (c) 2016 Webkit - Apple Inc
- */
-
-const maxSpringParamValue = K * 10;
-
-class Spring {
- /**
- * @param {SpringParams} [parameters]
- */
- constructor(parameters = {}) {
- this.timeStep = .02; // Interval fed to the solver to calculate duration
- this.restThreshold = .0005; // Values below this threshold are considered resting position
- this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
- this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
- this.maxRestSteps = this.restDuration / this.timeStep / K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
- this.maxIterations = this.maxDuration / this.timeStep / K; // Calculate the maximum iterations allowed based on maxDuration
- this.m = clamp(setValue(parameters.mass, 1), 0, maxSpringParamValue);
- this.s = clamp(setValue(parameters.stiffness, 100), 1, maxSpringParamValue);
- this.d = clamp(setValue(parameters.damping, 10), .1, maxSpringParamValue);
- this.v = clamp(setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
- this.w0 = 0;
- this.zeta = 0;
- this.wd = 0;
- this.b = 0;
- this.solverDuration = 0;
- this.duration = 0;
- this.compute();
- /** @type {EasingFunction} */
- this.ease = t => t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
- }
-
- /** @type {EasingFunction} */
- solve(time) {
- const { zeta, w0, wd, b } = this;
- let t = time;
- if (zeta < 1) {
- t = exp(-t * zeta * w0) * (1 * cos(wd * t) + b * sin(wd * t));
- } else {
- t = (1 + b * t) * exp(-t * w0);
- }
- return 1 - t;
- }
-
- compute() {
- const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
- const w0 = this.w0 = clamp(sqrt(s / m), minValue, K);
- const zeta = this.zeta = d / (2 * sqrt(s * m));
- const wd = this.wd = zeta < 1 ? w0 * sqrt(1 - zeta * zeta) : 0;
- this.b = zeta < 1 ? (zeta * w0 + -v) / wd : -v + w0;
- let solverTime = 0;
- let restSteps = 0;
- let iterations = 0;
- while (restSteps < maxRestSteps && iterations < maxIterations) {
- if (abs(1 - this.solve(solverTime)) < restThreshold) {
- restSteps++;
- } else {
- restSteps = 0;
- }
- this.solverDuration = solverTime;
- solverTime += timeStep;
- iterations++;
- }
- this.duration = round(this.solverDuration * K, 0) * globals.timeScale;
- }
-
- get mass() {
- return this.m;
- }
-
- set mass(v) {
- this.m = clamp(setValue(v, 1), 0, maxSpringParamValue);
- this.compute();
- }
-
- get stiffness() {
- return this.s;
- }
-
- set stiffness(v) {
- this.s = clamp(setValue(v, 100), 1, maxSpringParamValue);
- this.compute();
- }
-
- get damping() {
- return this.d;
- }
-
- set damping(v) {
- this.d = clamp(setValue(v, 10), .1, maxSpringParamValue);
- this.compute();
- }
-
- get velocity() {
- return this.v;
- }
-
- set velocity(v) {
- this.v = clamp(setValue(v, 0), -maxSpringParamValue, maxSpringParamValue);
- this.compute();
- }
-}
-
-/**
- * @param {SpringParams} [parameters]
- * @returns {Spring}
- */
-const createSpring = (parameters) => new Spring(parameters);
-
-export { Spring, createSpring };
diff --git a/dist/modules/timeline/timeline.cjs b/dist/modules/timeline/timeline.cjs
index fe45cb0b..ff6c1390 100644
--- a/dist/modules/timeline/timeline.cjs
+++ b/dist/modules/timeline/timeline.cjs
@@ -17,7 +17,7 @@ var styles = require('../core/styles.cjs');
var composition = require('../animation/composition.cjs');
var animation = require('../animation/animation.cjs');
var timer = require('../timer/timer.cjs');
-var eases = require('../easings/eases.cjs');
+var parser = require('../easings/eases/parser.cjs');
var position = require('./position.cjs');
/**
@@ -111,7 +111,7 @@ class Timeline extends timer.Timer {
/** @type {Callback<this>} */
this.onRender = parameters.onRender || globalDefaults.onRender;
const tlPlaybackEase = values.setValue(parameters.playbackEase, globalDefaults.playbackEase);
- this._ease = tlPlaybackEase ? eases.parseEase(tlPlaybackEase) : null;
+ this._ease = tlPlaybackEase ? parser.parseEase(tlPlaybackEase) : null;
/** @type {Number} */
this.iterationDuration = 0;
}
diff --git a/dist/modules/timeline/timeline.js b/dist/modules/timeline/timeline.js
index 5357eadd..aa8e9095 100644
--- a/dist/modules/timeline/timeline.js
+++ b/dist/modules/timeline/timeline.js
@@ -15,7 +15,7 @@ import { cleanInlineStyles } from '../core/styles.js';
import { removeTargetsFromRenderable } from '../animation/composition.js';
import { JSAnimation } from '../animation/animation.js';
import { Timer } from '../timer/timer.js';
-import { parseEase } from '../easings/eases.js';
+import { parseEase } from '../easings/eases/parser.js';
import { parseTimelinePosition } from './position.js';
/**
diff --git a/dist/modules/types/index.d.ts b/dist/modules/types/index.d.ts
index 9e4fbeac..e5b903f9 100644
--- a/dist/modules/types/index.d.ts
+++ b/dist/modules/types/index.d.ts
@@ -7,6 +7,7 @@ export type DefaultsParams = {
loop?: number | boolean;
reversed?: boolean;
alternate?: boolean;
+ persist?: boolean;
autoplay?: boolean | ScrollObserver;
duration?: number | FunctionValue;
delay?: number | FunctionValue;
@@ -14,13 +15,13 @@ export type DefaultsParams = {
ease?: EasingParam;
composition?: "none" | "replace" | "blend" | compositionTypes;
modifier?: (v: any) => any;
- onBegin?: (tickable: Tickable) => void;
- onBeforeUpdate?: (tickable: Tickable) => void;
- onUpdate?: (tickable: Tickable) => void;
- onLoop?: (tickable: Tickable) => void;
- onPause?: (tickable: Tickable) => void;
- onComplete?: (tickable: Tickable) => void;
- onRender?: (renderable: Renderable) => void;
+ onBegin?: Callback<Tickable>;
+ onBeforeUpdate?: Callback<Tickable>;
+ onUpdate?: Callback<Tickable>;
+ onLoop?: Callback<Tickable>;
+ onPause?: Callback<Tickable>;
+ onComplete?: Callback<Tickable>;
+ onRender?: Callback<Renderable>;
};
export type Renderable = JSAnimation | Timeline;
export type Tickable = Timer | Renderable;
@@ -50,12 +51,14 @@ export type JSTargetsArray = Array<JSTarget>;
export type TargetsParam = Array<TargetSelector> | TargetSelector;
export type TargetsArray = Array<Target>;
export type EasingFunction = (time: number) => number;
-export type EaseStringParamNames = ("linear" | "linear(x1, x2 25%, x3)" | "in" | "out" | "inOut" | "inQuad" | "outQuad" | "inOutQuad" | "inCubic" | "outCubic" | "inOutCubic" | "inQuart" | "outQuart" | "inOutQuart" | "inQuint" | "outQuint" | "inOutQuint" | "inSine" | "outSine" | "inOutSine" | "inCirc" | "outCirc" | "inOutCirc" | "inExpo" | "outExpo" | "inOutExpo" | "inBounce" | "outBounce" | "inOutBounce" | "inBack" | "outBack" | "inOutBack" | "inElastic" | "outElastic" | "inOutElastic" | "irregular" | "cubicBezier" | "steps" | "in(p = 1.675)" | "out(p = 1.675)" | "inOut(p = 1.675)" | "inBack(overshoot = 1.70158)" | "outBack(overshoot = 1.70158)" | "inOutBack(overshoot = 1.70158)" | "inElastic(amplitude = 1, period = .3)" | "outElastic(amplitude = 1, period = .3)" | "inOutElastic(amplitude = 1, period = .3)" | "irregular(length = 10, randomness = 1)" | "cubicBezier(x1, y1, x2, y2)" | "steps(steps = 10)");
+export type EaseStringParamNames = ("linear" | "none" | "in" | "out" | "inOut" | "inQuad" | "outQuad" | "inOutQuad" | "inCubic" | "outCubic" | "inOutCubic" | "inQuart" | "outQuart" | "inOutQuart" | "inQuint" | "outQuint" | "inOutQuint" | "inSine" | "outSine" | "inOutSine" | "inCirc" | "outCirc" | "inOutCirc" | "inExpo" | "outExpo" | "inOutExpo" | "inBounce" | "outBounce" | "inOutBounce" | "inBack" | "outBack" | "inOutBack" | "inElastic" | "outElastic" | "inOutElastic" | "out(p = 1.675)" | "inOut(p = 1.675)" | "inBack(overshoot = 1.7)" | "outBack(overshoot = 1.7)" | "inOutBack(overshoot = 1.7)" | "inElastic(amplitude = 1, period = .3)" | "outElastic(amplitude = 1, period = .3)" | "inOutElastic(amplitude = 1, period = .3)");
+export type WAAPIEaseStringParamNames = ("ease" | "ease-in" | "ease-out" | "ease-in-out" | "linear(0, 0.25, 1)" | "steps" | "steps(6, start)" | "step-start" | "step-end" | "cubic-bezier(0.42, 0, 1, 1)");
export type PowerEasing = (power?: number | string) => EasingFunction;
export type BackEasing = (overshoot?: number | string) => EasingFunction;
export type ElasticEasing = (amplitude?: number | string, period?: number | string) => EasingFunction;
export type EasingFunctionWithParams = PowerEasing | BackEasing | ElasticEasing;
export type EasingParam = (string & {}) | EaseStringParamNames | EasingFunction | Spring;
+export type WAAPIEasingParam = (string & {}) | EaseStringParamNames | WAAPIEaseStringParamNames | EasingFunction | Spring;
export type SpringParams = {
/**
* - Mass, default 1
@@ -73,6 +76,18 @@ export type SpringParams = {
* - Initial velocity, default 0
*/
velocity?: number;
+ /**
+ * - Initial bounce, default 0
+ */
+ bounce?: number;
+ /**
+ * - The perceived duration, default 0
+ */
+ duration?: number;
+ /**
+ * - Callback function called when the spring currentTime hits the perceived duration
+ */
+ onComplete?: Callback<JSAnimation>;
};
export type Callback<T> = (self: T, e?: PointerEvent) => any;
export type TickableCallbacks<T extends unknown> = {
@@ -131,6 +146,7 @@ export type Tween = {
_isOverlapped: number;
_isOverridden: number;
_renderTransforms: number;
+ _inlineValue: string;
_prevRep: Tween;
_nextRep: Tween;
_prevAdd: Tween;
@@ -238,13 +254,13 @@ export type TimelineParams = TimerOptions & TimelineOptions & TickableCallbacks<
export type WAAPITweenValue = string | number | Array<string> | Array<number>;
export type WAAPIFunctionValue = (target: DOMTarget, index: number, length: number) => WAAPITweenValue;
export type WAAPIKeyframeValue = WAAPITweenValue | WAAPIFunctionValue | Array<string | number | WAAPIFunctionValue>;
-export type WAAPICallback = (animation: WAAPIAnimation) => void;
+export type WAAPICallback = Callback<WAAPIAnimation>;
export type WAAPITweenOptions = {
to?: WAAPIKeyframeValue;
from?: WAAPIKeyframeValue;
duration?: number | WAAPIFunctionValue;
delay?: number | WAAPIFunctionValue;
- ease?: EasingParam;
+ ease?: WAAPIEasingParam;
composition?: CompositeOperation;
};
export type WAAPIAnimationOptions = {
@@ -255,11 +271,12 @@ export type WAAPIAnimationOptions = {
playbackRate?: number;
duration?: number | WAAPIFunctionValue;
delay?: number | WAAPIFunctionValue;
- ease?: EasingParam;
+ ease?: WAAPIEasingParam;
composition?: CompositeOperation;
+ persist?: boolean;
onComplete?: WAAPICallback;
};
-export type WAAPIAnimationParams = Record<string, WAAPIKeyframeValue | WAAPIAnimationOptions | boolean | ScrollObserver | WAAPICallback | EasingParam | WAAPITweenOptions> & WAAPIAnimationOptions;
+export type WAAPIAnimationParams = Record<string, WAAPIKeyframeValue | WAAPIAnimationOptions | boolean | ScrollObserver | WAAPICallback | WAAPIEasingParam | WAAPITweenOptions> & WAAPIAnimationOptions;
export type AnimatablePropertySetter = (to: number | Array<number>, duration?: number, ease?: EasingParam) => AnimatableObject;
export type AnimatablePropertyGetter = () => number | Array<number>;
export type AnimatableProperty = AnimatablePropertySetter & AnimatablePropertyGetter;
@@ -382,6 +399,6 @@ import type { WAAPIAnimation } from '../waapi/waapi.js';
import type { Draggable } from '../draggable/draggable.js';
import type { TextSplitter } from '../text/split.js';
import type { Scope } from '../scope/scope.js';
-import type { Spring } from '../spring/spring.js';
+import type { Spring } from '../easings/spring/index.js';
import type { tweenTypes } from '../core/consts.js';
import type { valueTypes } from '../core/consts.js';
diff --git a/dist/modules/utils/stagger.cjs b/dist/modules/utils/stagger.cjs
index d14f8a9d..b333d003 100644
--- a/dist/modules/utils/stagger.cjs
+++ b/dist/modules/utils/stagger.cjs
@@ -9,7 +9,7 @@
var consts = require('../core/consts.cjs');
var helpers = require('../core/helpers.cjs');
-var eases = require('../easings/eases.cjs');
+var parser = require('../easings/eases/parser.cjs');
var position = require('../timeline/position.cjs');
var values = require('../core/values.cjs');
var targets = require('../core/targets.cjs');
@@ -25,7 +25,7 @@ var random = require('./random.cjs');
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
@@ -65,7 +65,7 @@ const stagger = (val, params = {}) => {
const ease = params.ease;
const hasEasing = !helpers.isUnd(ease);
const hasSpring = hasEasing && !helpers.isUnd(/** @type {Spring} */(ease).ease);
- const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? eases.parseEase(ease) : null;
+ const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? parser.parseEase(ease) : null;
const grid = params.grid;
const axis = params.axis;
const customTotal = params.total;
diff --git a/dist/modules/utils/stagger.js b/dist/modules/utils/stagger.js
index 55e982ba..206e2219 100644
--- a/dist/modules/utils/stagger.js
+++ b/dist/modules/utils/stagger.js
@@ -7,7 +7,7 @@
import { unitsExecRgx, emptyString } from '../core/consts.js';
import { isUnd, parseNumber, isFnc, abs, floor, sqrt, round, isArr, isNum, isStr, max } from '../core/helpers.js';
-import { parseEase } from '../easings/eases.js';
+import { parseEase } from '../easings/eases/parser.js';
import { parseTimelinePosition } from '../timeline/position.js';
import { getOriginalAnimatableValue } from '../core/values.js';
import { registerTargets } from '../core/targets.js';
@@ -23,7 +23,7 @@ import { shuffle } from './random.js';
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
diff --git a/dist/modules/waapi/composition.cjs b/dist/modules/waapi/composition.cjs
index ea01842c..c57a2f12 100644
--- a/dist/modules/waapi/composition.cjs
+++ b/dist/modules/waapi/composition.cjs
@@ -30,16 +30,18 @@ const WAAPIAnimationsLookups = {
* @param {DOMTarget} $el
* @param {String} [property]
* @param {WAAPIAnimation} [parent]
+ * @return {globalThis.Animation}
*/
const removeWAAPIAnimation = ($el, property, parent) => {
let nextLookup = WAAPIAnimationsLookups._head;
+ let anim;
while (nextLookup) {
const next = nextLookup._next;
const matchTarget = nextLookup.$el === $el;
const matchProperty = !property || nextLookup.property === property;
const matchParent = !parent || nextLookup.parent === parent;
if (matchTarget && matchProperty && matchParent) {
- const anim = nextLookup.animation;
+ anim = nextLookup.animation;
try { anim.commitStyles(); } catch {} anim.cancel();
helpers.removeChild(WAAPIAnimationsLookups, nextLookup);
const lookupParent = nextLookup.parent;
@@ -47,8 +49,8 @@ const removeWAAPIAnimation = ($el, property, parent) => {
lookupParent._completed++;
if (lookupParent.animations.length === lookupParent._completed) {
lookupParent.completed = true;
+ lookupParent.paused = true;
if (!lookupParent.muteCallbacks) {
- lookupParent.paused = true;
lookupParent.onComplete(lookupParent);
lookupParent._resolve(lookupParent);
}
@@ -57,6 +59,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
}
nextLookup = next;
}
+ return anim;
};
/**
@@ -65,7 +68,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
* @param {String} property
* @param {PropertyIndexedKeyframes} keyframes
* @param {KeyframeAnimationOptions} params
- * @retun {Animation}
+ * @retun {globalThis.Animation}
*/
const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
const animation = $el.animate(keyframes, params);
@@ -80,8 +83,11 @@ const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
removeWAAPIAnimation($el, property);
helpers.addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
+ animation.oncancel = handleRemove;
animation.onremove = handleRemove;
- animation.onfinish = handleRemove;
+ if (!parent.persist) {
+ animation.onfinish = handleRemove;
+ }
return animation;
};
diff --git a/dist/modules/waapi/composition.d.ts b/dist/modules/waapi/composition.d.ts
index 93c35c80..f7900173 100644
--- a/dist/modules/waapi/composition.d.ts
+++ b/dist/modules/waapi/composition.d.ts
@@ -1,4 +1,4 @@
-export function removeWAAPIAnimation($el: DOMTarget, property?: string, parent?: WAAPIAnimation): void;
+export function removeWAAPIAnimation($el: DOMTarget, property?: string, parent?: WAAPIAnimation): globalThis.Animation;
export function addWAAPIAnimation(parent: WAAPIAnimation, $el: DOMTarget, property: string, keyframes: PropertyIndexedKeyframes, params: KeyframeAnimationOptions): Animation;
import type { DOMTarget } from '../types/index.js';
import type { WAAPIAnimation } from '../waapi/waapi.js';
diff --git a/dist/modules/waapi/composition.js b/dist/modules/waapi/composition.js
index 346078c0..74a4d64e 100644
--- a/dist/modules/waapi/composition.js
+++ b/dist/modules/waapi/composition.js
@@ -28,16 +28,18 @@ const WAAPIAnimationsLookups = {
* @param {DOMTarget} $el
* @param {String} [property]
* @param {WAAPIAnimation} [parent]
+ * @return {globalThis.Animation}
*/
const removeWAAPIAnimation = ($el, property, parent) => {
let nextLookup = WAAPIAnimationsLookups._head;
+ let anim;
while (nextLookup) {
const next = nextLookup._next;
const matchTarget = nextLookup.$el === $el;
const matchProperty = !property || nextLookup.property === property;
const matchParent = !parent || nextLookup.parent === parent;
if (matchTarget && matchProperty && matchParent) {
- const anim = nextLookup.animation;
+ anim = nextLookup.animation;
try { anim.commitStyles(); } catch {} anim.cancel();
removeChild(WAAPIAnimationsLookups, nextLookup);
const lookupParent = nextLookup.parent;
@@ -45,8 +47,8 @@ const removeWAAPIAnimation = ($el, property, parent) => {
lookupParent._completed++;
if (lookupParent.animations.length === lookupParent._completed) {
lookupParent.completed = true;
+ lookupParent.paused = true;
if (!lookupParent.muteCallbacks) {
- lookupParent.paused = true;
lookupParent.onComplete(lookupParent);
lookupParent._resolve(lookupParent);
}
@@ -55,6 +57,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
}
nextLookup = next;
}
+ return anim;
};
/**
@@ -63,7 +66,7 @@ const removeWAAPIAnimation = ($el, property, parent) => {
* @param {String} property
* @param {PropertyIndexedKeyframes} keyframes
* @param {KeyframeAnimationOptions} params
- * @retun {Animation}
+ * @retun {globalThis.Animation}
*/
const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
const animation = $el.animate(keyframes, params);
@@ -78,8 +81,11 @@ const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
removeWAAPIAnimation($el, property);
addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
+ animation.oncancel = handleRemove;
animation.onremove = handleRemove;
- animation.onfinish = handleRemove;
+ if (!parent.persist) {
+ animation.onfinish = handleRemove;
+ }
return animation;
};
diff --git a/dist/modules/waapi/waapi.cjs b/dist/modules/waapi/waapi.cjs
index 86fff3dc..6d519363 100644
--- a/dist/modules/waapi/waapi.cjs
+++ b/dist/modules/waapi/waapi.cjs
@@ -13,7 +13,7 @@ var targets = require('../core/targets.cjs');
var values = require('../core/values.cjs');
var consts = require('../core/consts.cjs');
var none = require('../easings/none.cjs');
-var parser = require('../easings/parser.cjs');
+var parser = require('../easings/eases/parser.cjs');
var composition = require('./composition.cjs');
/**
@@ -35,7 +35,7 @@ var composition = require('./composition.cjs');
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
@@ -52,21 +52,11 @@ var composition = require('./composition.cjs');
*/
const easingToLinear = (fn, samples = 100) => {
const points = [];
- for (let i = 0; i <= samples; i++) points.push(fn(i / samples));
+ for (let i = 0; i <= samples; i++) points.push(helpers.round(fn(i / samples), 4));
return `linear(${points.join(', ')})`;
};
-const WAAPIEasesLookups = {
- in: 'ease-in',
- out: 'ease-out',
- inOut: 'ease-in-out',
-};
-
-const WAAPIeases = /*#__PURE__*/(() => {
- const list = {};
- for (let type in parser.easeTypes) list[type] = (/** @type {String|Number} */p) => parser.easeTypes[type](parser.easeInPower(p));
- return /** @type {Record<String, EasingFunction>} */(list);
-})();
+const WAAPIEasesLookups = {};
/**
* @param {EasingParam} ease
@@ -87,9 +77,10 @@ const parseWAAPIEasing = (ease) => {
} else if (helpers.stringStartsWith(ease, 'cubicB')) {
parsedEase = helpers.toLowerCase(ease);
} else {
- const parsed = parser.parseEaseString(ease, WAAPIeases, WAAPIEasesLookups);
+ const parsed = parser.parseEaseString(ease);
if (helpers.isFnc(parsed)) parsedEase = parsed === none.none ? 'linear' : easingToLinear(parsed);
}
+ // Only cache string based easing name, otherwise function arguments get lost
WAAPIEasesLookups[ease] = parsedEase;
} else if (helpers.isFnc(ease)) {
const easing = easingToLinear(ease);
@@ -130,7 +121,8 @@ let transformsPropertiesRegistered = null;
* @return {String}
*/
const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
- let v = values.getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
+ // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
+ let v = helpers.isStr(value) ? value : values.getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
if (!helpers.isNum(v)) return v;
if (commonDefaultPXProperties.includes(propName) || helpers.stringStartsWith(propName, 'translate')) return `${v}px`;
if (helpers.stringStartsWith(propName, 'rotate') || helpers.stringStartsWith(propName, 'skew')) return `${v}deg`;
@@ -210,7 +202,7 @@ class WAAPIAnimation {
/** @type {PlaybackDirection} */
const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
/** @type {FillMode} */
- const fill = 'forwards';
+ const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
/** @type {String} */
const easing = parseWAAPIEasing(ease);
const timeScale = (globals.globals.timeScale === 1 ? 1 : consts.K);
@@ -222,7 +214,7 @@ class WAAPIAnimation {
/** @type {globalThis.Animation}] */
this.controlAnimation = null;
/** @type {Callback<this>} */
- this.onComplete = params.onComplete || consts.noop;
+ this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.globals.defaults.onComplete));
/** @type {Number} */
this.duration = 0;
/** @type {Boolean} */
@@ -233,6 +225,8 @@ class WAAPIAnimation {
this.paused = !autoplay || scroll !== false;
/** @type {Boolean} */
this.reversed = reversed;
+ /** @type {Boolean} */
+ this.persist = values.setValue(params.persist, globals.globals.defaults.persist);
/** @type {Boolean|ScrollObserver} */
this.autoplay = autoplay;
/** @type {Number} */
@@ -241,17 +235,18 @@ class WAAPIAnimation {
this._resolve = consts.noop; // Used by .then()
/** @type {Number} */
this._completed = 0;
- /** @type {Array<Object>}] */
- this._inlineStyles = parsedTargets.map($el => $el.getAttribute('style'));
+ /** @type {Array.<Object>} */
+ this._inlineStyles = [];
parsedTargets.forEach(($el, i) => {
const cachedTransforms = $el[consts.transformsSymbol];
-
const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
+ const elStyle = $el.style;
+ const inlineStyles = this._inlineStyles[i] = {};
/** @type {Number} */
- const duration = (spring ? /** @type {Spring} */(spring).duration : values.getFunctionValue(values.setValue(params.duration, globals.globals.defaults.duration), $el, i, targetsLength)) * timeScale;
+ const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : values.getFunctionValue(values.setValue(params.duration, globals.globals.defaults.duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
const delay = values.getFunctionValue(values.setValue(params.delay, globals.globals.defaults.delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -265,6 +260,12 @@ class WAAPIAnimation {
const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
const propertyValue = params[name];
const individualTransformProperty = hasIndividualTransforms ? consts.validTransforms.includes(name) ? name : consts.shortTransforms.get(name) : false;
+
+ const styleName = individualTransformProperty ? 'transform' : name;
+ if (!inlineStyles[styleName]) {
+ inlineStyles[styleName] = elStyle[styleName];
+ }
+
let parsedPropertyValue;
if (helpers.isObj(propertyValue)) {
const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
@@ -273,7 +274,7 @@ class WAAPIAnimation {
const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
/** @type {Number} */
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).duration : values.getFunctionValue(values.setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
+ tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : values.getFunctionValue(values.setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
tweenParams.delay = values.getFunctionValue(values.setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -290,10 +291,10 @@ class WAAPIAnimation {
composition.addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
if (!helpers.isUnd(from)) {
if (!individualTransformProperty) {
- $el.style[name] = keyframes[name][0];
+ elStyle[name] = keyframes[name][0];
} else {
const key = `--${individualTransformProperty}`;
- $el.style.setProperty(key, keyframes[key][0]);
+ elStyle.setProperty(key, keyframes[key][0]);
}
}
} else {
@@ -314,7 +315,7 @@ class WAAPIAnimation {
for (let t in cachedTransforms) {
transforms += `${consts.transformsFragmentStrings[t]}var(--${t})) `;
}
- $el.style.transform = transforms;
+ elStyle.transform = transforms;
}
});
@@ -359,7 +360,8 @@ class WAAPIAnimation {
// Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
// The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
// https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
- if (t >= this.duration) anim.play();
+ // This is not needed for persisting animations since they never finish.
+ if (!this.persist && t >= this.duration) anim.play();
anim.currentTime = t;
});
}
@@ -429,13 +431,30 @@ class WAAPIAnimation {
}
cancel() {
- this.forEach('cancel');
- return this.pause();
+ this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
+ return this.commitStyles().forEach('cancel');
}
revert() {
- this.cancel();
- this.targets.forEach(($el, i) => $el.setAttribute('style', this._inlineStyles[i]) );
+ // NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
+ // This means if you have multiple animations animating different transforms on the same target,
+ // reverting one of them will also override the transform property of the other animations.
+ // A better approach would be to store the original custom property values is they exist instead of the entire transform value,
+ // and update the CSS variables with the orignal value
+ this.cancel().targets.forEach(($el, i) => {
+ const targetStyle = $el.style;
+ const targetInlineStyles = this._inlineStyles[i];
+ for (let name in targetInlineStyles) {
+ const originalInlinedValue = targetInlineStyles[name];
+ if (helpers.isUnd(originalInlinedValue) || originalInlinedValue === consts.emptyString) {
+ targetStyle.removeProperty(helpers.toLowerCase(name));
+ } else {
+ targetStyle[name] = originalInlinedValue;
+ }
+ }
+ // Remove style attribute if empty
+ if ($el.getAttribute('style') === consts.emptyString) $el.removeAttribute('style');
+ });
return this;
}
diff --git a/dist/modules/waapi/waapi.d.ts b/dist/modules/waapi/waapi.d.ts
index 23ca5efc..6ced2b0b 100644
--- a/dist/modules/waapi/waapi.d.ts
+++ b/dist/modules/waapi/waapi.d.ts
@@ -22,6 +22,8 @@ export class WAAPIAnimation {
paused: boolean;
/** @type {Boolean} */
reversed: boolean;
+ /** @type {Boolean} */
+ persist: boolean;
/** @type {Boolean|ScrollObserver} */
autoplay: boolean | ScrollObserver;
/** @type {Number} */
@@ -30,7 +32,7 @@ export class WAAPIAnimation {
_resolve: Function;
/** @type {Number} */
_completed: number;
- /** @type {Array<Object>}] */
+ /** @type {Array.<Object>} */
_inlineStyles: Array<any>;
/**
* @callback forEachCallback
@@ -96,7 +98,7 @@ import type { WAAPIAnimationParams } from '../types/index.js';
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
* @import {
diff --git a/dist/modules/waapi/waapi.js b/dist/modules/waapi/waapi.js
index a42a617e..9a065ec4 100644
--- a/dist/modules/waapi/waapi.js
+++ b/dist/modules/waapi/waapi.js
@@ -5,13 +5,13 @@
* @copyright 2025 - Julian Garnier
*/
-import { isNil, isUnd, stringStartsWith, isKey, isObj, isArr, isStr, toLowerCase, isFnc, isNum } from '../core/helpers.js';
+import { isNil, isUnd, stringStartsWith, isKey, isObj, isArr, toLowerCase, round, isStr, isFnc, isNum } from '../core/helpers.js';
import { scope, globals } from '../core/globals.js';
import { registerTargets } from '../core/targets.js';
import { setValue, getFunctionValue } from '../core/values.js';
import { isBrowser, validTransforms, noop, transformsSymbol, shortTransforms, transformsFragmentStrings, emptyString, K } from '../core/consts.js';
import { none } from '../easings/none.js';
-import { parseEaseString, easeTypes, easeInPower } from '../easings/parser.js';
+import { parseEaseString } from '../easings/eases/parser.js';
import { addWAAPIAnimation } from './composition.js';
/**
@@ -33,7 +33,7 @@ import { addWAAPIAnimation } from './composition.js';
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
@@ -50,21 +50,11 @@ import { addWAAPIAnimation } from './composition.js';
*/
const easingToLinear = (fn, samples = 100) => {
const points = [];
- for (let i = 0; i <= samples; i++) points.push(fn(i / samples));
+ for (let i = 0; i <= samples; i++) points.push(round(fn(i / samples), 4));
return `linear(${points.join(', ')})`;
};
-const WAAPIEasesLookups = {
- in: 'ease-in',
- out: 'ease-out',
- inOut: 'ease-in-out',
-};
-
-const WAAPIeases = /*#__PURE__*/(() => {
- const list = {};
- for (let type in easeTypes) list[type] = (/** @type {String|Number} */p) => easeTypes[type](easeInPower(p));
- return /** @type {Record<String, EasingFunction>} */(list);
-})();
+const WAAPIEasesLookups = {};
/**
* @param {EasingParam} ease
@@ -85,9 +75,10 @@ const parseWAAPIEasing = (ease) => {
} else if (stringStartsWith(ease, 'cubicB')) {
parsedEase = toLowerCase(ease);
} else {
- const parsed = parseEaseString(ease, WAAPIeases, WAAPIEasesLookups);
+ const parsed = parseEaseString(ease);
if (isFnc(parsed)) parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
}
+ // Only cache string based easing name, otherwise function arguments get lost
WAAPIEasesLookups[ease] = parsedEase;
} else if (isFnc(ease)) {
const easing = easingToLinear(ease);
@@ -128,7 +119,8 @@ let transformsPropertiesRegistered = null;
* @return {String}
*/
const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
- let v = getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
+ // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
+ let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
if (!isNum(v)) return v;
if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
@@ -208,7 +200,7 @@ class WAAPIAnimation {
/** @type {PlaybackDirection} */
const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
/** @type {FillMode} */
- const fill = 'forwards';
+ const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
/** @type {String} */
const easing = parseWAAPIEasing(ease);
const timeScale = (globals.timeScale === 1 ? 1 : K);
@@ -220,7 +212,7 @@ class WAAPIAnimation {
/** @type {globalThis.Animation}] */
this.controlAnimation = null;
/** @type {Callback<this>} */
- this.onComplete = params.onComplete || noop;
+ this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.defaults.onComplete));
/** @type {Number} */
this.duration = 0;
/** @type {Boolean} */
@@ -231,6 +223,8 @@ class WAAPIAnimation {
this.paused = !autoplay || scroll !== false;
/** @type {Boolean} */
this.reversed = reversed;
+ /** @type {Boolean} */
+ this.persist = setValue(params.persist, globals.defaults.persist);
/** @type {Boolean|ScrollObserver} */
this.autoplay = autoplay;
/** @type {Number} */
@@ -239,17 +233,18 @@ class WAAPIAnimation {
this._resolve = noop; // Used by .then()
/** @type {Number} */
this._completed = 0;
- /** @type {Array<Object>}] */
- this._inlineStyles = parsedTargets.map($el => $el.getAttribute('style'));
+ /** @type {Array.<Object>} */
+ this._inlineStyles = [];
parsedTargets.forEach(($el, i) => {
const cachedTransforms = $el[transformsSymbol];
-
const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
+ const elStyle = $el.style;
+ const inlineStyles = this._inlineStyles[i] = {};
/** @type {Number} */
- const duration = (spring ? /** @type {Spring} */(spring).duration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
+ const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -263,6 +258,12 @@ class WAAPIAnimation {
const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
const propertyValue = params[name];
const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
+
+ const styleName = individualTransformProperty ? 'transform' : name;
+ if (!inlineStyles[styleName]) {
+ inlineStyles[styleName] = elStyle[styleName];
+ }
+
let parsedPropertyValue;
if (isObj(propertyValue)) {
const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
@@ -271,7 +272,7 @@ class WAAPIAnimation {
const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
/** @type {Number} */
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).duration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
+ tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -288,10 +289,10 @@ class WAAPIAnimation {
addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
if (!isUnd(from)) {
if (!individualTransformProperty) {
- $el.style[name] = keyframes[name][0];
+ elStyle[name] = keyframes[name][0];
} else {
const key = `--${individualTransformProperty}`;
- $el.style.setProperty(key, keyframes[key][0]);
+ elStyle.setProperty(key, keyframes[key][0]);
}
}
} else {
@@ -312,7 +313,7 @@ class WAAPIAnimation {
for (let t in cachedTransforms) {
transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
}
- $el.style.transform = transforms;
+ elStyle.transform = transforms;
}
});
@@ -357,7 +358,8 @@ class WAAPIAnimation {
// Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
// The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
// https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
- if (t >= this.duration) anim.play();
+ // This is not needed for persisting animations since they never finish.
+ if (!this.persist && t >= this.duration) anim.play();
anim.currentTime = t;
});
}
@@ -427,13 +429,30 @@ class WAAPIAnimation {
}
cancel() {
- this.forEach('cancel');
- return this.pause();
+ this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
+ return this.commitStyles().forEach('cancel');
}
revert() {
- this.cancel();
- this.targets.forEach(($el, i) => $el.setAttribute('style', this._inlineStyles[i]) );
+ // NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
+ // This means if you have multiple animations animating different transforms on the same target,
+ // reverting one of them will also override the transform property of the other animations.
+ // A better approach would be to store the original custom property values is they exist instead of the entire transform value,
+ // and update the CSS variables with the orignal value
+ this.cancel().targets.forEach(($el, i) => {
+ const targetStyle = $el.style;
+ const targetInlineStyles = this._inlineStyles[i];
+ for (let name in targetInlineStyles) {
+ const originalInlinedValue = targetInlineStyles[name];
+ if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ targetStyle.removeProperty(toLowerCase(name));
+ } else {
+ targetStyle[name] = originalInlinedValue;
+ }
+ }
+ // Remove style attribute if empty
+ if ($el.getAttribute('style') === emptyString) $el.removeAttribute('style');
+ });
return this;
}
diff --git a/examples/animejs-v4-logo-animation/index.js b/examples/animejs-v4-logo-animation/index.js
index 3c4e5cfb..f5bff033 100644
--- a/examples/animejs-v4-logo-animation/index.js
+++ b/examples/animejs-v4-logo-animation/index.js
@@ -1,4 +1,4 @@
-import { createTimeline, stagger, svg, utils, eases } from '../../dist/modules/index.js';
+import { createTimeline, stagger, svg, utils, cubicBezier, eases } from '../../dist/modules/index.js';
const [ $dot1 ] = utils.$('#dot-1');
const onions = [];
@@ -31,7 +31,7 @@ utils.set(['#line', '#line-0'], {
opacity: 1,
});
-const splashCurve = eases.cubicBezier(0.225, 1, 0.915, 0.980);
+const splashCurve = cubicBezier(0.225, 1, 0.915, 0.980);
const sweechCurve = eases.outElastic(1.1, 0.9);
const tl = createTimeline({
diff --git a/examples/clock-playback-controls/index.js b/examples/clock-playback-controls/index.js
index 88b4c1c4..3cd76030 100644
--- a/examples/clock-playback-controls/index.js
+++ b/examples/clock-playback-controls/index.js
@@ -1,4 +1,4 @@
-import { animate, createTimeline, utils } from '../../dist/modules/index.js';
+import { animate, createTimeline, utils, cubicBezier } from '../../dist/modules/index.js';
const [ $digitalClock ] = utils.$('#digital');
@@ -25,7 +25,7 @@ const masterTL = createTimeline({ defaults: { ease: 'linear' }, autoplay: false
$el.appendChild($num);
}
const canStop = d > 100;
- const ease = canStop ? 'cubicBezier(1,0,.6,1.2)' : 'linear';
+ const ease = canStop ? cubicBezier(1,0,.6,1.2) : 'linear';
const duration = canStop ? 650 : d;
const position = `+=${canStop ? d - 650 : 0}`;
const numTL = createTimeline({ defaults: { ease }, loop: true });
diff --git a/examples/irregular-playback-typewriter/index.js b/examples/irregular-playback-typewriter/index.js
index 3ac39978..7233c372 100644
--- a/examples/irregular-playback-typewriter/index.js
+++ b/examples/irregular-playback-typewriter/index.js
@@ -3,7 +3,7 @@ import {
createTimeline,
utils,
stagger,
- eases,
+ easings,
} from '../../dist/modules/index.js';
const $spans = utils.$('span');
@@ -12,13 +12,13 @@ const keystrokesSteps = $spans.length - 1;
const keystrokesInterval = 125;
createTimeline({
- playbackEase: eases.irregular(keystrokesSteps, 2),
+ playbackEase: easings.irregular(keystrokesSteps, 2),
})
.set($spans, { opacity: [0, 1] }, stagger(keystrokesInterval))
.add($cursor, {
left: '100%',
duration: keystrokesSteps * keystrokesInterval,
- ease: eases.steps(keystrokesSteps),
+ ease: easings.steps(keystrokesSteps),
}, 0)
.init();
diff --git a/examples/timeline-50K-stars/index.js b/examples/timeline-50K-stars/index.js
index 57bd741f..c9e1b035 100644
--- a/examples/timeline-50K-stars/index.js
+++ b/examples/timeline-50K-stars/index.js
@@ -1,4 +1,4 @@
-import { animate, createTimeline, utils } from '../../dist/modules/index.js';
+import { animate, createTimeline, utils, steps, cubicBezier } from '../../dist/modules/index.js';
const [$animation] = utils.$('#animation');
const [$button] = utils.$('.star-button');
@@ -39,14 +39,14 @@ const increaseCount = (cursor) => {
.add($cursorClone, {
x: { to: [utils.random(-250, 250), utils.random(-70, 70)], ease: 'out(3)' },
y: { to: [utils.random(0, 1) ? -300 : 300, utils.random(0, 10)], ease: 'out(6)' },
- backgroundPosition: { to: '-40px 0px', ease: 'steps(1)', duration: 150 },
+ backgroundPosition: { to: '-40px 0px', ease: steps(1), duration: 150 },
opacity: [0, 1],
duration: 400,
})
.add($cursorClone, {
x: { to: utils.random(-250, 250), ease: 'inOut(3)' },
y: { to: utils.random(0, 1) ? -300 : 300, ease: 'inOut(6)' },
- backgroundPosition: { to: '0px 0px', ease: 'steps(1)', duration: 50 },
+ backgroundPosition: { to: '0px 0px', ease: steps(1), duration: 50 },
opacity: 0,
duration: 750,
})
@@ -75,7 +75,7 @@ createTimeline()
.add($cursor, {
x: { to: 0, ease: 'out(3)' },
y: { to: 10, ease: 'out(6)' },
- backgroundPosition: { to: '-40px 0px', ease: 'steps(1)', duration: 250 },
+ backgroundPosition: { to: '-40px 0px', ease: steps(1), duration: 250 },
duration: 750,
})
.add('.star-button', {
@@ -94,35 +94,35 @@ createTimeline()
.add($cursor, {
x: { to: -150, ease: 'inOut(3)' },
y: { to: 250, ease: 'inOut(6)' },
- backgroundPosition: { to: '0px 0px', ease: 'steps(1)', duration: 50 },
+ backgroundPosition: { to: '0px 0px', ease: steps(1), duration: 50 },
duration: 750,
}, 'CLICK START-=500')
.add(data, {
mult: [0, 0, 1.5, .25, 0, 0],
duration: 10000,
- ease: 'cubicBezier(1,0,0,1)',
+ ease: cubicBezier(1,0,0,1),
}, 'CLICK START')
.add(clickAnimation, {
progress: 1,
duration: 10000,
- ease: 'cubicBezier(.65,0,0,1)',
+ ease: cubicBezier(.65,0,0,1),
}, 'CLICK START')
.add($count, {
innerHTML: ['5', '40000'],
modifier: utils.round(0),
- ease: 'cubicBezier(1,0,1,1)',
+ ease: cubicBezier(1,0,1,1),
duration: 5000
}, 'CLICK START+=800')
.add($count, {
innerHTML: '49999',
modifier: utils.round(0),
- ease: 'cubicBezier(0,1,0,1)',
+ ease: cubicBezier(0,1,0,1),
duration: 4250
}, '<')
.add($cursor, {
x: { to: 0, ease: 'out(3)' },
y: { to: 10, ease: 'out(6)' },
- backgroundPosition: { to: '-40px 0px', ease: 'steps(1)', duration: 250 },
+ backgroundPosition: { to: '-40px 0px', ease: steps(1), duration: 250 },
duration: 750,
}, '<+=250')
.add('.star-button', {
@@ -135,7 +135,7 @@ createTimeline()
.add($cursor, {
x: { to: -150, ease: 'inOut(3)' },
y: { to: 250, ease: 'inOut(6)' },
- backgroundPosition: { to: '0px 0px', ease: 'steps(1)', duration: 250 },
+ backgroundPosition: { to: '0px 0px', ease: steps(1), duration: 250 },
duration: 750,
}, '<<+=1000')
.add($animation, {
diff --git a/package.json b/package.json
index e5756570..3bfd1247 100644
--- a/package.json
+++ b/package.json
@@ -1,16 +1,16 @@
{
- "name": "animejs",
- "version": "4.2.0-beta.0",
+ "name": "@juliangarnierorg/anime-beta",
+ "version": "4.2.0",
"description": "JavaScript animation engine",
"homepage": "https://animejs.com",
"author": "Julian Garnier <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
- "url": "git+https://github.com/juliangarnier/anime.git"
+ "url": "git+https://github.com/juliangarnierorg/anime-beta.git"
},
"bugs": {
- "url": "https://github.com/juliangarnier/anime/issues"
+ "url": "https://github.com/juliangarnierorg/anime-beta/issues"
},
"funding": {
"type": "github",
@@ -20,12 +20,17 @@
"anime",
"animejs",
"anime.js",
+ "timer",
"animation",
"timeline",
+ "animatable",
+ "draggable",
+ "scope",
+ "engine",
+ "scroll",
"easings",
+ "cubic-bezier",
"spring",
- "scroll",
- "drag",
"text",
"JavaScript",
"CSS",
@@ -100,18 +105,48 @@
"import": "./dist/modules/events/index.js",
"default": "./dist/modules/events/index.cjs"
},
- "./spring": {
- "types": "./dist/modules/spring/index.d.ts",
- "require": "./dist/modules/spring/index.cjs",
- "import": "./dist/modules/spring/index.js",
- "default": "./dist/modules/spring/index.cjs"
- },
"./easings": {
"types": "./dist/modules/easings/index.d.ts",
"require": "./dist/modules/easings/index.cjs",
"import": "./dist/modules/easings/index.js",
"default": "./dist/modules/easings/index.cjs"
},
+ "./easings/eases": {
+ "types": "./dist/modules/easings/eases/index.d.ts",
+ "require": "./dist/modules/easings/eases/index.cjs",
+ "import": "./dist/modules/easings/eases/index.js",
+ "default": "./dist/modules/easings/eases/index.cjs"
+ },
+ "./easings/linear": {
+ "types": "./dist/modules/easings/linear/index.d.ts",
+ "require": "./dist/modules/easings/linear/index.cjs",
+ "import": "./dist/modules/easings/linear/index.js",
+ "default": "./dist/modules/easings/linear/index.cjs"
+ },
+ "./easings/steps": {
+ "types": "./dist/modules/easings/steps/index.d.ts",
+ "require": "./dist/modules/easings/steps/index.cjs",
+ "import": "./dist/modules/easings/steps/index.js",
+ "default": "./dist/modules/easings/steps/index.cjs"
+ },
+ "./easings/irregular": {
+ "types": "./dist/modules/easings/irregular/index.d.ts",
+ "require": "./dist/modules/easings/irregular/index.cjs",
+ "import": "./dist/modules/easings/irregular/index.js",
+ "default": "./dist/modules/easings/irregular/index.cjs"
+ },
+ "./easings/cubic-bezier": {
+ "types": "./dist/modules/easings/cubic-bezier/index.d.ts",
+ "require": "./dist/modules/easings/cubic-bezier/index.cjs",
+ "import": "./dist/modules/easings/cubic-bezier/index.js",
+ "default": "./dist/modules/easings/cubic-bezier/index.cjs"
+ },
+ "./easings/spring": {
+ "types": "./dist/modules/easings/spring/index.d.ts",
+ "require": "./dist/modules/easings/spring/index.cjs",
+ "import": "./dist/modules/easings/spring/index.js",
+ "default": "./dist/modules/easings/spring/index.cjs"
+ },
"./utils": {
"types": "./dist/modules/utils/index.d.ts",
"require": "./dist/modules/utils/index.cjs",
@@ -139,6 +174,7 @@
},
"devDependencies": {
"@rollup/plugin-terser": "^0.4.4",
+ "@types/mocha": "^10.0.10",
"@types/node": "^24.3.0",
"browser-sync": "^2.29.3",
"chai": "^4.3.10",
diff --git a/rollup.config.js b/rollup.config.js
index fbc1028d..c249aa8a 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -34,6 +34,8 @@ const updatePackageVersion = replace(/__packageVersion__/g, pkg.version);
// Extracts module input paths from the package.json 'exports' field
const inputs = Object.keys(pkg.exports).filter(k => k !== './package.json').map(k => `src${k.replace('.', '')}/index.js`);
+console.log(inputs);
+
const tasks = [{
input: inputs,
output: [
diff --git a/src/animatable/animatable.js b/src/animatable/animatable.js
index 862f0c5a..b632b133 100644
--- a/src/animatable/animatable.js
+++ b/src/animatable/animatable.js
@@ -24,7 +24,7 @@ import {
import {
parseEase,
-} from '../easings/eases.js';
+} from '../easings/eases/parser.js';
/**
* @import {
diff --git a/src/animation/animation.js b/src/animation/animation.js
index a5ec23ff..fad08f56 100644
--- a/src/animation/animation.js
+++ b/src/animation/animation.js
@@ -19,6 +19,7 @@ import {
normalizeTime,
isNum,
round,
+ isNil,
} from '../core/helpers.js';
import {
@@ -52,7 +53,7 @@ import {
import {
parseEase,
-} from '../easings/eases.js';
+} from '../easings/eases/parser.js';
import {
Timer,
@@ -94,13 +95,14 @@ import {
*
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
// Defines decomposed values target objects only once and mutate their properties later to avoid GC
// TODO: Maybe move the objects creation to values.js and use the decompose function to create the base object
const fromTargetObject = createDecomposedValueTargetObject();
const toTargetObject = createDecomposedValueTargetObject();
+const inlineStylesStore = {};
const toFunctionStore = { func: null };
const keyframesTargetArray = [null];
const fastSetValuesArray = [null, null];
@@ -245,15 +247,15 @@ export class JSAnimation extends Timer {
const animEase = animaPlaybackEase ? parseEase(animaPlaybackEase) : null;
const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */(ease).ease);
const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */(ease).duration : setValue(duration, animDefaults.duration);
+ const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : setValue(duration, animDefaults.duration);
const tDelay = setValue(delay, animDefaults.delay);
const tModifier = modifier || animDefaults.modifier;
// If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
const tComposition = isUnd(composition) && targetsLength >= K ? compositionTypes.none : !isUnd(composition) ? composition : animDefaults.composition;
- // TODO: Do not create an empty object until we know the animation will generate inline styles
- const animInlineStyles = {};
// const absoluteOffsetTime = this._offset;
const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
+ // This allows targeting the current animation in the spring onComplete callback
+ if (hasSpring) /** @type {Spring} */(ease).parent = this;
let iterationDuration = NaN;
let iterationDelay = NaN;
@@ -355,7 +357,7 @@ export class JSAnimation extends Timer {
// Easing are treated differently and don't accept function based value to prevent having to pass a function wrapper that returns an other function all the time
const tweenEasing = hasSpring ? /** @type {Spring} */(keyEasing).ease : keyEasing || tEasing;
// Calculate default individual keyframe duration by dividing the tl of keyframes
- const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).duration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
+ const tweenDuration = hasSpring ? /** @type {Spring} */(keyEasing).settlingDuration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
// Default delay value should only be applied to the first tween
const tweenDelay = getFunctionValue(setValue(key.delay, (!tweenIndex ? tDelay : 0)), target, ti, tl);
const computedComposition = getFunctionValue(setValue(key.composition, tComposition), target, ti, tl);
@@ -405,7 +407,7 @@ export class JSAnimation extends Timer {
}
} else {
decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
decomposedOriginalValue
);
if (decomposedOriginalValue.t === valueTypes.UNIT) {
@@ -423,7 +425,7 @@ export class JSAnimation extends Timer {
} else {
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), toTargetObject);
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), toTargetObject);
}
}
if (hasFromvalue) {
@@ -434,7 +436,7 @@ export class JSAnimation extends Timer {
} else {
decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
// No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), fromTargetObject);
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore), fromTargetObject);
}
}
}
@@ -443,7 +445,7 @@ export class JSAnimation extends Timer {
if (fromTargetObject.o) {
fromTargetObject.n = getRelativeValue(
!prevSibling ? decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles),
+ getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
decomposedOriginalValue
).n : prevSibling._toNumber,
fromTargetObject.n,
@@ -499,6 +501,10 @@ export class JSAnimation extends Timer {
// Rounding is necessary here to minimize floating point errors when working in seconds
const tweenUpdateDuration = round(+tweenDuration || minValue, 12);
+ // Copy the value of the iniline style if it exist and imediatly nullify it to prevents false positive on other targets
+ let inlineValue = inlineStylesStore[propName];
+ if (!isNil(inlineValue)) inlineStylesStore[propName] = null;
+
/** @type {Tween} */
const tween = {
parent: this,
@@ -530,6 +536,7 @@ export class JSAnimation extends Timer {
_isOverlapped: 0,
_isOverridden: 0,
_renderTransforms: 0,
+ _inlineValue: inlineValue,
_prevRep: null, // For replaced tween
_nextRep: null, // For replaced tween
_prevAdd: null, // For additive tween
@@ -632,8 +639,6 @@ export class JSAnimation extends Timer {
// this._offset += parent ? iterationDelay : 0;
/** @type {Number} */
this.iterationDuration = iterationDuration;
- /** @type {{}} */
- this._inlineStyles = animInlineStyles;
if (!this._autoplay && shouldTriggerRender) this.onRender(this);
}
@@ -667,6 +672,7 @@ export class JSAnimation extends Timer {
if (tweenFunc) {
const ogValue = getOriginalAnimatableValue(tween.target, tween.property, tween._tweenType);
decomposeRawValue(ogValue, decomposedOriginalValue);
+ // TODO: Check for from / to Array based values here,
decomposeRawValue(tweenFunc(), toTargetObject);
tween._fromNumbers = cloneArray(decomposedOriginalValue.d);
tween._fromNumber = decomposedOriginalValue.n;
@@ -676,6 +682,8 @@ export class JSAnimation extends Timer {
tween._toNumber = toTargetObject.o ? getRelativeValue(decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
}
});
+ // This forces setter animations to render once
+ if (this.duration === minValue) this.restart();
return this;
}
diff --git a/src/core/consts.js b/src/core/consts.js
index 8e3dd68c..5fed2fd7 100644
--- a/src/core/consts.js
+++ b/src/core/consts.js
@@ -61,6 +61,8 @@ export const maxFps = 120;
// Strings
export const emptyString = '';
+export const cssVarPrefix = 'var(';
+
export const shortTransforms = /*#__PURE__*/ (() => {
const map = new Map();
map.set('x', 'translateX');
@@ -84,9 +86,9 @@ export const validTransforms = [
'skew',
'skewX',
'skewY',
- 'perspective',
'matrix',
'matrix3d',
+ 'perspective',
];
export const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) => ({...a, [v]: v + '('}), {});
@@ -110,3 +112,4 @@ export const unitsExecRgx = /^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i
export const lowerCaseRgx = /([a-z])([A-Z])/g;
export const transformsExecRgx = /(\w+)(\([^)]+\)+)/g; // Match inline transforms with cacl() values, returns the value wrapped in ()
export const relativeValuesExecRgx = /(\*=|\+=|-=)/;
+export const cssVariableMatchRgx = /var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/;
diff --git a/src/core/globals.js b/src/core/globals.js
index a026d030..c9199eb3 100644
--- a/src/core/globals.js
+++ b/src/core/globals.js
@@ -30,6 +30,7 @@ export const defaults = {
reversed: false,
alternate: false,
autoplay: true,
+ persist: false,
duration: K,
delay: 0,
loopDelay: 0,
diff --git a/src/core/render.js b/src/core/render.js
index 01fa67d2..27a8fb14 100644
--- a/src/core/render.js
+++ b/src/core/render.js
@@ -293,7 +293,9 @@ export const render = (tickable, time, muteCallbacks, internalRender, tickMode)
// Handle setters on timeline differently and allow re-trigering the onComplete callback when seeking backwards
if (parent && isSetter) {
if (!muteCallbacks && (
- (parent.began && !isRunningBackwards && tickableAbsoluteTime >= duration && !completed) ||
+ // (tickableAbsoluteTime > 0 instead) of (tickableAbsoluteTime >= duration) to prevent floating point precision issues
+ // see: https://github.com/juliangarnier/anime/issues/1088
+ (parent.began && !isRunningBackwards && tickableAbsoluteTime > 0 && !completed) ||
(isRunningBackwards && tickableAbsoluteTime <= minValue && completed)
)) {
tickable.onComplete(/** @type {CallbackArgument} */(tickable));
diff --git a/src/core/styles.js b/src/core/styles.js
index 24892406..9c94ce7d 100644
--- a/src/core/styles.js
+++ b/src/core/styles.js
@@ -9,14 +9,12 @@ import {
import {
forEachChildren,
+ isNil,
isSvg,
isUnd,
toLowerCase,
} from './helpers.js';
-const propertyNamesCache = {};
-
-
/**
* @import {
* JSAnimation,
@@ -32,6 +30,8 @@ const propertyNamesCache = {};
* } from '../types/index.js'
*/
+const propertyNamesCache = {};
+
/**
* @param {String} propertyName
* @param {Target} target
@@ -78,10 +78,11 @@ export const cleanInlineStyles = renderable => {
const tweenTarget = tween.target;
if (tweenTarget[isDomSymbol]) {
const targetStyle = /** @type {DOMTarget} */(tweenTarget).style;
- const originalInlinedValue = animation._inlineStyles[tweenProperty];
+ const originalInlinedValue = tween._inlineValue;
+ const tweenHadNoInlineValue = isNil(originalInlinedValue) || originalInlinedValue === emptyString;
if (tween._tweenType === tweenTypes.TRANSFORM) {
const cachedTransforms = tweenTarget[transformsSymbol];
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ if (tweenHadNoInlineValue) {
delete cachedTransforms[tweenProperty];
} else {
cachedTransforms[tweenProperty] = originalInlinedValue;
@@ -98,8 +99,8 @@ export const cleanInlineStyles = renderable => {
}
}
} else {
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
- targetStyle.removeProperty(tweenProperty);
+ if (tweenHadNoInlineValue) {
+ targetStyle.removeProperty(toLowerCase(tweenProperty));
} else {
targetStyle[tweenProperty] = originalInlinedValue;
}
diff --git a/src/core/values.js b/src/core/values.js
index 1357f59a..aa3f0174 100644
--- a/src/core/values.js
+++ b/src/core/values.js
@@ -8,6 +8,9 @@ import {
isDomSymbol,
isSvgSymbol,
proxyTargetSymbol,
+ cssVarPrefix,
+ cssVariableMatchRgx,
+ emptyString,
} from './consts.js';
import {
@@ -17,6 +20,7 @@ import {
isUnd,
isCol,
isValidSVGAttribute,
+ isStr,
} from './helpers.js';
import {
@@ -56,19 +60,30 @@ export const setValue = (targetValue, defaultValue) => {
* @return {any}
*/
export const getFunctionValue = (value, target, index, total, store) => {
+ let func;
if (isFnc(value)) {
- const func = () => {
+ func = () => {
const computed = /** @type {Function} */(value)(target, index, total);
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed || 0;
}
- if (store) {
- store.func = func;
+ } else if (isStr(value) && stringStartsWith(value, cssVarPrefix)) {
+ func = () => {
+ const match = value.match(cssVariableMatchRgx);
+ const cssVarName = match[1];
+ const fallbackValue = match[2];
+ let computed = getComputedStyle(/** @type {HTMLElement} */(target))?.getPropertyValue(cssVarName);
+ // Use fallback if CSS variable is not set or empty
+ if ((!computed || computed.trim() === emptyString) && fallbackValue) {
+ computed = fallbackValue.trim();
+ }
+ return computed || 0;
}
- return func();
} else {
return value;
}
+ if (store) store.func = func;
+ return func();
}
/**
diff --git a/src/draggable/draggable.js b/src/draggable/draggable.js
index b462f547..6be233b5 100644
--- a/src/draggable/draggable.js
+++ b/src/draggable/draggable.js
@@ -59,11 +59,11 @@ import {
import {
eases,
parseEase,
-} from '../easings/eases.js';
+} from '../easings/eases/parser.js';
import {
- createSpring,
-} from '../spring/spring.js'
+ spring,
+} from '../easings/spring/index.js';
import {
get,
@@ -89,7 +89,7 @@ import {
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
@@ -267,13 +267,13 @@ export class Draggable {
/** @type {Boolean|DraggableCursorParams} */
this.cursor = false;
/** @type {Spring} */
- this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : createSpring({
+ this.releaseXSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
mass: setValue(parameters.releaseMass, 1),
stiffness: setValue(parameters.releaseStiffness, 80),
damping: setValue(parameters.releaseDamping, 20),
});
/** @type {Spring} */
- this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : createSpring({
+ this.releaseYSpring = hasSpring ? /** @type {Spring} */(ease) : spring({
mass: setValue(parameters.releaseMass, 1),
stiffness: setValue(parameters.releaseStiffness, 80),
damping: setValue(parameters.releaseDamping, 20),
@@ -990,8 +990,8 @@ export class Draggable {
this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
this.$trigger.addEventListener('touchend', preventDefault);
-
- if ((!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
+ // Don't check for a miminim distance move if already dragging
+ if (this.dragged || (!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
this.updateTicker.resume();
this.pointer[2] = this.pointer[0];
@@ -1057,8 +1057,8 @@ export class Draggable {
const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
const distanceX = round(cx - dx, 0);
springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / abs(distanceX) : 0 : pv;
- const { ease, duration, restDuration } = springX;
- durationX = cx === dx ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springX;
+ durationX = cx === dx ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
if (hasReleaseSpring) easeX = ease;
if (durationX > longestReleaseDuration) longestReleaseDuration = durationX;
}
@@ -1067,8 +1067,8 @@ export class Draggable {
const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
const distanceY = round(cy - dy, 0);
springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / abs(distanceY) : 0 : pv;
- const { ease, duration, restDuration } = springY;
- durationY = cy === dy ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
+ const { ease, settlingDuration, restDuration } = springY;
+ durationY = cy === dy ? 0 : hasReleaseSpring ? settlingDuration : settlingDuration - (restDuration * globals.timeScale);
if (hasReleaseSpring) easeY = ease;
if (durationY > longestReleaseDuration) longestReleaseDuration = durationY;
}
diff --git a/src/easings/cubic-bezier.js b/src/easings/cubic-bezier/index.js
similarity index 93%
rename from src/easings/cubic-bezier.js
rename to src/easings/cubic-bezier/index.js
index d2442478..5dc56d0d 100644
--- a/src/easings/cubic-bezier.js
+++ b/src/easings/cubic-bezier/index.js
@@ -1,16 +1,15 @@
import {
abs,
-} from '../core/helpers.js';
+} from '../../core/helpers.js';
import {
none,
-} from './none.js';
-
+} from '../none.js';
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/src/easings/eases/index.js b/src/easings/eases/index.js
new file mode 100644
index 00000000..d73dfa6d
--- /dev/null
+++ b/src/easings/eases/index.js
@@ -0,0 +1 @@
+export { eases } from './parser.js';
diff --git a/src/easings/eases.js b/src/easings/eases/parser.js
similarity index 63%
rename from src/easings/eases.js
rename to src/easings/eases/parser.js
index aca3767a..823d9d36 100644
--- a/src/easings/eases.js
+++ b/src/easings/eases/parser.js
@@ -1,7 +1,7 @@
import {
minValue,
emptyString,
-} from '../core/consts.js';
+} from '../../core/consts.js';
import {
isStr,
@@ -13,19 +13,10 @@ import {
asin,
PI,
pow,
-} from '../core/helpers.js';
+ stringStartsWith,
+} from '../../core/helpers.js';
-import {
- easeInPower,
- easeTypes,
- parseEaseString,
-} from './parser.js';
-
-import { none } from './none.js';
-import { cubicBezier } from './cubic-bezier.js';
-import { steps } from './steps.js';
-import { linear } from './linear.js';
-import { irregular } from './irregular.js';
+import { none } from '../none.js';
/**
* @import {
@@ -35,9 +26,27 @@ import { irregular } from './irregular.js';
* BackEasing,
* ElasticEasing,
* PowerEasing,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
+
+/** @type {PowerEasing} */
+export const easeInPower = (p = 1.68) => t => pow(t, +p);
+
+/**
+ * @callback EaseType
+ * @param {EasingFunction} Ease
+ * @return {EasingFunction}
+ */
+
+/** @type {Record<String, EaseType>} */
+export const easeTypes = {
+ in: easeIn => t => easeIn(t),
+ out: easeIn => t => 1 - easeIn(1 - t),
+ inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
+ outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
+}
+
/**
* Easing functions adapted and simplified from https://robertpenner.com/easing/
* (c) 2001 Robert Penner
@@ -66,7 +75,7 @@ const easeInFunctions = {
return 1 / pow(4, 3 - b) - 7.5625 * pow((pow2 * 3 - 2) / 22 - t, 2);
},
/** @type {BackEasing} */
- Back: (overshoot = 1.70158) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
+ Back: (overshoot = 1.7) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
/** @type {ElasticEasing} */
Elastic: (amplitude = 1, period = .3) => {
const a = clamp(+amplitude, 1, 10);
@@ -79,10 +88,8 @@ const easeInFunctions = {
/**
* @typedef {Object} EasesFunctions
- * @property {typeof linear} linear
- * @property {typeof irregular} irregular
- * @property {typeof steps} steps
- * @property {typeof cubicBezier} cubicBezier
+ * @property {typeof none} linear
+ * @property {typeof none} none
* @property {PowerEasing} in
* @property {PowerEasing} out
* @property {PowerEasing} inOut
@@ -130,7 +137,7 @@ const easeInFunctions = {
*/
export const eases = (/*#__PURE__ */ (() => {
- const list = { linear, irregular, steps, cubicBezier };
+ const list = { linear: none, none: none };
for (let type in easeTypes) {
for (let name in easeInFunctions) {
const easeIn = easeInFunctions[name];
@@ -146,12 +153,40 @@ export const eases = (/*#__PURE__ */ (() => {
})());
/** @type {Record<String, EasingFunction>} */
-const JSEasesLookups = { linear: none };
+const easesLookups = { linear: none, none: none };
+
+/**
+ * @param {String} string
+ * @return {EasingFunction}
+ */
+export const parseEaseString = (string) => {
+ if (easesLookups[string]) return easesLookups[string];
+ if (string.indexOf('(') <= -1) {
+ const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
+ const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(eases[string])() : eases[string]);
+ return parsedFn ? easesLookups[string] = parsedFn : none;
+ } else {
+ const split = string.slice(0, -1).split('(');
+ const parsedFn = /** @type {EasingFunctionWithParams} */(eases[split[0]]);
+ return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
+ }
+}
+
+const deprecated = ['steps(', 'irregular(', 'linear(', 'cubicBezier('];
/**
* @param {EasingParam} ease
* @return {EasingFunction}
*/
-export const parseEase = ease => isFnc(ease) ? ease :
- isStr(ease) ? parseEaseString(/** @type {String} */(ease), eases, JSEasesLookups) :
- none;
+export const parseEase = ease => {
+ if (isStr(ease)) {
+ for (let i = 0, l = deprecated.length; i < l; i++) {
+ if (stringStartsWith(ease, deprecated[i])) {
+ console.warn(`String syntax for \`ease: "${ease}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${ease}\``);
+ return none;
+ }
+ }
+ }
+ const easeFunc = isFnc(ease) ? ease : isStr(ease) ? parseEaseString(/** @type {String} */(ease)) : none;
+ return easeFunc;
+}
diff --git a/src/easings/index.js b/src/easings/index.js
index 22ce441c..f66c14a6 100644
--- a/src/easings/index.js
+++ b/src/easings/index.js
@@ -1,6 +1,6 @@
-export { none } from './none.js';
-export { cubicBezier } from './cubic-bezier.js';
-export { steps } from './steps.js';
-export { linear } from './linear.js';
-export { irregular } from './irregular.js';
-export { eases } from './eases.js';
\ No newline at end of file
+export * from './cubic-bezier/index.js';
+export * from './steps/index.js';
+export * from './linear/index.js';
+export * from './irregular/index.js';
+export * from './spring/index.js';
+export * from './eases/index.js';
diff --git a/src/easings/irregular.js b/src/easings/irregular/index.js
similarity index 90%
rename from src/easings/irregular.js
rename to src/easings/irregular/index.js
index 43451a53..775eb8a3 100644
--- a/src/easings/irregular.js
+++ b/src/easings/irregular/index.js
@@ -1,16 +1,16 @@
import {
clamp,
-} from "../core/helpers.js";
+} from "../../core/helpers.js";
import {
linear,
-} from "./linear.js";
+} from "../linear/index.js";
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/src/easings/linear.js b/src/easings/linear/index.js
similarity index 94%
rename from src/easings/linear.js
rename to src/easings/linear/index.js
index 05a2f227..66dc008f 100644
--- a/src/easings/linear.js
+++ b/src/easings/linear/index.js
@@ -2,16 +2,16 @@ import {
isStr,
isUnd,
parseNumber,
-} from '../core/helpers.js';
+} from '../../core/helpers.js';
import {
none,
-} from './none.js';
+} from '../none.js';
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/src/easings/parser.js b/src/easings/parser.js
deleted file mode 100644
index 938aa4c3..00000000
--- a/src/easings/parser.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import { pow } from "../core/helpers.js";
-import { none } from "./none.js";
-
-/**
- * @import {
- * EasingFunction,
- * PowerEasing,
- * EasingFunctionWithParams,
- * } from '../types/index.js'
-*/
-
-/** @type {PowerEasing} */
-export const easeInPower = (p = 1.68) => t => pow(t, +p);
-
-/**
- * @callback EaseType
- * @param {EasingFunction} Ease
- * @return {EasingFunction}
- */
-
-/** @type {Record<String, EaseType>} */
-export const easeTypes = {
- in: easeIn => t => easeIn(t),
- out: easeIn => t => 1 - easeIn(1 - t),
- inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
- outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
-}
-
-/**
- * @param {String} string
- * @param {Record<String, EasingFunctionWithParams|EasingFunction>} easesFunctions
- * @param {Object} easesLookups
- * @return {EasingFunction}
- */
-export const parseEaseString = (string, easesFunctions, easesLookups) => {
- if (easesLookups[string]) return easesLookups[string];
- if (string.indexOf('(') <= -1) {
- const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
- const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @type {EasingFunctionWithParams} */(easesFunctions[string])() : easesFunctions[string]);
- return parsedFn ? easesLookups[string] = parsedFn : none;
- } else {
- const split = string.slice(0, -1).split('(');
- const parsedFn = /** @type {EasingFunctionWithParams} */(easesFunctions[split[0]]);
- return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
- }
-}
\ No newline at end of file
diff --git a/src/easings/spring/index.js b/src/easings/spring/index.js
new file mode 100644
index 00000000..4c9ab78c
--- /dev/null
+++ b/src/easings/spring/index.js
@@ -0,0 +1,264 @@
+import {
+ K,
+ minValue,
+ noop,
+} from '../../core/consts.js';
+
+import {
+ globals,
+} from '../../core/globals.js';
+
+import {
+ isUnd,
+ round,
+ clamp,
+ sqrt,
+ exp,
+ cos,
+ sin,
+ abs,
+ pow,
+ PI,
+} from '../../core/helpers.js';
+
+import {
+ setValue,
+} from '../../core/values.js';
+
+/**
+ * @import {
+ * JSAnimation,
+ * } from '../../animation/animation.js'
+ */
+
+/**
+ * @import {
+ * EasingFunction,
+ * SpringParams,
+ * Callback,
+ * } from '../../types/index.js'
+*/
+
+/*
+ * Spring easing solver adapted from https://webkit.org/demos/spring/spring.js
+ * (c) 2016 Webkit - Apple Inc
+ */
+
+const maxSpringParamValue = K * 10;
+
+export class Spring {
+ /**
+ * @param {SpringParams} [parameters]
+ */
+ constructor(parameters = {}) {
+ const hasBounceOrDuration = !isUnd(parameters.bounce) || !isUnd(parameters.duration);
+ this.timeStep = .02; // Interval fed to the solver to calculate duration
+ this.restThreshold = .0005; // Values below this threshold are considered resting position
+ this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
+ this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
+ this.maxRestSteps = this.restDuration / this.timeStep / K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
+ this.maxIterations = this.maxDuration / this.timeStep / K; // Calculate the maximum iterations allowed based on maxDuration
+ this.bn = clamp(setValue(parameters.bounce, .5), -1, 1); // The bounce percentage between -1 and 1.
+ this.pd = clamp(setValue(parameters.duration, 628), 10 * globals.timeScale, maxSpringParamValue * globals.timeScale); // The perceived duration
+ this.m = clamp(setValue(parameters.mass, 1), 1, maxSpringParamValue);
+ this.s = clamp(setValue(parameters.stiffness, 100), minValue, maxSpringParamValue);
+ this.d = clamp(setValue(parameters.damping, 10), minValue, maxSpringParamValue);
+ this.v = clamp(setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
+ this.w0 = 0;
+ this.zeta = 0;
+ this.wd = 0;
+ this.b = 0;
+ this.completed = false;
+ this.solverDuration = 0;
+ this.settlingDuration = 0;
+ /** @type {JSAnimation} */
+ this.parent = null;
+ /** @type {Callback<JSAnimation>} */
+ this.onComplete = parameters.onComplete || noop;
+ if (hasBounceOrDuration) this.calculateSDFromBD();
+ this.compute();
+ /** @type {EasingFunction} */
+ this.ease = t => {
+ const currentTime = t * this.settlingDuration;
+ const completed = this.completed;
+ const perceivedTime = this.pd;
+ if (currentTime >= perceivedTime && !completed) {
+ this.completed = true;
+ this.onComplete(this.parent);
+ }
+ if (currentTime < perceivedTime && completed) {
+ this.completed = false;
+ }
+ return t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
+ }
+ }
+
+ /** @type {EasingFunction} */
+ solve(time) {
+ const { zeta, w0, wd, b } = this;
+ let t = time;
+ if (zeta < 1) {
+ // Underdamped
+ t = exp(-t * zeta * w0) * (1 * cos(wd * t) + b * sin(wd * t));
+ } else if (zeta === 1) {
+ // Critically damped
+ t = (1 + b * t) * exp(-t * w0);
+ } else {
+ // Overdamped
+ // Using exponential instead of cosh and sinh functions to prevent Infinity
+ // Original exp(-zeta * w0 * t) * (cosh(wd * t) + b * sinh(wd * t))
+ t = ((1 + b) * exp((-zeta * w0 + wd) * t) + (1 - b) * exp((-zeta * w0 - wd) * t)) / 2;
+ }
+ return 1 - t;
+ }
+
+ calculateSDFromBD() {
+ // Apple's SwiftUI perceived spring duration implementation https://developer.apple.com/videos/play/wwdc2023/10158/?time=1010
+ // Equations taken from Kevin Grajeda's article https://www.kvin.me/posts/effortless-ui-spring-animations
+ const pds = globals.timeScale === 1 ? this.pd / K : this.pd;
+ // Mass and velocity should be set to their default values
+ this.m = 1;
+ this.v = 0;
+ // Stiffness = (2π ÷ perceptualDuration)²
+ this.s = pow((2 * PI) / pds, 2);
+ if (this.bn >= 0) {
+ // For bounce ≥ 0 (critically damped to underdamped)
+ // damping = ((1 - bounce) × 4π) ÷ perceptualDuration
+ this.d = ((1 - this.bn) * 4 * PI) / pds;
+ } else {
+ // For bounce < 0 (overdamped)
+ // damping = 4π ÷ (perceptualDuration × (1 + bounce))
+ // Note: (1 + bounce) is positive since bounce is negative
+ this.d = (4 * PI) / (pds * (1 + this.bn));
+ }
+ this.s = round(clamp(this.s, minValue, maxSpringParamValue), 3);
+ this.d = round(clamp(this.d, minValue, 300), 3); // Clamping to 300 is needed to prevent insane values in the solver
+ }
+
+ calculateBDFromSD() {
+ // Calculate perceived duration and bounce from stiffness and damping
+ // Note: We assumes m = 1 and v = 0 for these calculations
+ const pds = (2 * PI) / sqrt(this.s);
+ this.pd = pds * (globals.timeScale === 1 ? K : 1);
+ const zeta = this.d / (2 * sqrt(this.s));
+ if (zeta <= 1) {
+ // Critically damped to underdamped
+ this.bn = 1 - (this.d * pds) / (4 * PI);
+ } else {
+ // Overdamped
+ this.bn = (4 * PI) / (this.d * pds) - 1;
+ }
+ this.bn = round(clamp(this.bn, -1, 1), 3);
+ this.pd = round(clamp(this.pd, 10 * globals.timeScale, maxSpringParamValue * globals.timeScale), 3);
+ }
+
+ compute() {
+ const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
+ const w0 = this.w0 = clamp(sqrt(s / m), minValue, K);
+ const bouncedZeta = this.zeta = d / (2 * sqrt(s * m));
+ // Calculate wd based on damping type
+ if (bouncedZeta < 1) {
+ // Underdamped
+ this.wd = w0 * sqrt(1 - bouncedZeta * bouncedZeta);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ } else if (bouncedZeta === 1) {
+ // Critically damped
+ this.wd = 0;
+ this.b = -v + w0;
+ } else {
+ // Overdamped
+ this.wd = w0 * sqrt(bouncedZeta * bouncedZeta - 1);
+ this.b = (bouncedZeta * w0 + -v) / this.wd;
+ }
+
+ let solverTime = 0;
+ let restSteps = 0;
+ let iterations = 0;
+ while (restSteps <= maxRestSteps && iterations <= maxIterations) {
+ if (abs(1 - this.solve(solverTime)) < restThreshold) {
+ restSteps++;
+ } else {
+ restSteps = 0;
+ }
+ this.solverDuration = solverTime;
+ solverTime += timeStep;
+ iterations++;
+ }
+ this.settlingDuration = round(this.solverDuration * K, 0) * globals.timeScale;
+ }
+
+ get bounce() {
+ return this.bn;
+ }
+
+ set bounce(v) {
+ this.bn = clamp(setValue(v, 1), -1, 1);
+ this.calculateSDFromBD();
+ this.compute();
+ }
+
+ get duration() {
+ return this.pd;
+ }
+
+ set duration(v) {
+ this.pd = clamp(setValue(v, 1), 10 * globals.timeScale, maxSpringParamValue * globals.timeScale);
+ this.calculateSDFromBD();
+ this.compute();
+ }
+
+ get stiffness() {
+ return this.s;
+ }
+
+ set stiffness(v) {
+ this.s = clamp(setValue(v, 100), minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
+ this.compute();
+ }
+
+ get damping() {
+ return this.d;
+ }
+
+ set damping(v) {
+ this.d = clamp(setValue(v, 10), minValue, maxSpringParamValue);
+ this.calculateBDFromSD();
+ this.compute();
+ }
+
+ get mass() {
+ return this.m;
+ }
+
+ set mass(v) {
+ this.m = clamp(setValue(v, 1), 1, maxSpringParamValue);
+ this.compute();
+ }
+
+ get velocity() {
+ return this.v;
+ }
+
+ set velocity(v) {
+ this.v = clamp(setValue(v, 0), -maxSpringParamValue, maxSpringParamValue);
+ this.compute();
+ }
+}
+
+/**
+ * @param {SpringParams} [parameters]
+ * @returns {Spring}
+ */
+export const spring = (parameters) => new Spring(parameters);
+
+/**
+ * @deprecated createSpring() is deprecated use spring() instead
+ *
+ * @param {SpringParams} [parameters]
+ * @returns {Spring}
+ */
+export const createSpring = (parameters) => {
+ console.warn('createSpring() is deprecated use spring() instead');
+ return new Spring(parameters);
+}
diff --git a/src/easings/steps.js b/src/easings/steps/index.js
similarity index 88%
rename from src/easings/steps.js
rename to src/easings/steps/index.js
index cf1f1879..e8a0ba98 100644
--- a/src/easings/steps.js
+++ b/src/easings/steps/index.js
@@ -2,12 +2,12 @@ import {
ceil,
clamp,
floor,
-} from "../core/helpers.js";
+} from "../../core/helpers.js";
/**
* @import {
* EasingFunction,
- * } from '../types/index.js'
+ * } from '../../types/index.js'
*/
/**
diff --git a/src/events/scroll.js b/src/events/scroll.js
index 163d7218..a65c4610 100644
--- a/src/events/scroll.js
+++ b/src/events/scroll.js
@@ -59,7 +59,7 @@ import {
import {
parseEase,
-} from '../easings/eases.js';
+} from '../easings/eases/parser.js';
/**
* @import {
@@ -477,6 +477,8 @@ export class ScrollObserver {
/** @type {Boolean} */
this.reverted = false;
/** @type {Boolean} */
+ this.ready = false;
+ /** @type {Boolean} */
this.completed = false;
/** @type {Boolean} */
this.began = false;
@@ -486,8 +488,6 @@ export class ScrollObserver {
this.forceEnter = false;
/** @type {Boolean} */
this.hasEntered = false;
- // /** @type {Array.<Number>} */
- // this.offsets = [];
/** @type {Number} */
this.offset = 0;
/** @type {Number} */
@@ -535,6 +535,8 @@ export class ScrollObserver {
// Make sure to pause the linked object in case it's added later
linked.pause();
this.linked = linked;
+ // Forces WAAPI Animation to persist; otherwise, they will stop syncing on finish.
+ if (!isUnd(/** @type {WAAPIAnimation} */(linked))) /** @type {WAAPIAnimation} */(linked).persist = true;
// Try to use a target of the linked object if no target parameters specified
if (!this._params.target) {
/** @type {HTMLElement} */
@@ -574,6 +576,8 @@ export class ScrollObserver {
}
refresh() {
+ // This flag is used to prevent running handleScroll() outside of this.refresh() with values not yet calculated
+ this.ready = true;
this.reverted = false;
const params = this._params;
this.repeat = setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
@@ -819,8 +823,6 @@ export class ScrollObserver {
const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
const scrollDelta = offsetEnd - offsetStart;
- // this.offsets[0] = offsetX;
- // this.offsets[1] = offsetY;
this.offset = offset;
this.offsetStart = offsetStart;
this.offsetEnd = offsetEnd;
@@ -839,6 +841,7 @@ export class ScrollObserver {
}
handleScroll() {
+ if (!this.ready) return;
const linked = this.linked;
const sync = this.sync;
const syncEase = this.syncEase;
@@ -962,6 +965,7 @@ export class ScrollObserver {
this.removeDebug();
}
this.reverted = true;
+ this.ready = false;
return this;
}
diff --git a/src/index.js b/src/index.js
index cfb5666b..f331d709 100644
--- a/src/index.js
+++ b/src/index.js
@@ -5,7 +5,6 @@ export * from './animatable/index.js';
export * from './draggable/index.js';
export * from './scope/index.js';
export * from './events/index.js';
-export * from './spring/index.js';
export * from './engine/index.js';
export * from './easings/index.js';
export * as easings from './easings/index.js';
@@ -16,4 +15,4 @@ export * as svg from './svg/index.js';
export * from './text/index.js';
export * as text from './text/index.js';
export * from './waapi/index.js';
-export * from './types/index.js';
+export * from './types/index.js';
\ No newline at end of file
diff --git a/src/spring/index.js b/src/spring/index.js
deleted file mode 100644
index 5e16fd58..00000000
--- a/src/spring/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export * from './spring.js';
\ No newline at end of file
diff --git a/src/spring/spring.js b/src/spring/spring.js
deleted file mode 100644
index 04650316..00000000
--- a/src/spring/spring.js
+++ /dev/null
@@ -1,139 +0,0 @@
-import {
- K,
- minValue,
-} from '../core/consts.js';
-
-import {
- globals,
-} from '../core/globals.js';
-
-import {
- round,
- clamp,
- sqrt,
- exp,
- cos,
- sin,
- abs,
-} from '../core/helpers.js';
-
-import {
- setValue,
-} from '../core/values.js';
-
-/**
- * @import {
- * EasingFunction,
- * SpringParams,
- * } from '../types/index.js'
-*/
-
-/*
- * Spring ease solver adapted from https://webkit.org/demos/spring/spring.js
- * (c) 2016 Webkit - Apple Inc
- */
-
-const maxSpringParamValue = K * 10;
-
-export class Spring {
- /**
- * @param {SpringParams} [parameters]
- */
- constructor(parameters = {}) {
- this.timeStep = .02; // Interval fed to the solver to calculate duration
- this.restThreshold = .0005; // Values below this threshold are considered resting position
- this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
- this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
- this.maxRestSteps = this.restDuration / this.timeStep / K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
- this.maxIterations = this.maxDuration / this.timeStep / K; // Calculate the maximum iterations allowed based on maxDuration
- this.m = clamp(setValue(parameters.mass, 1), 0, maxSpringParamValue);
- this.s = clamp(setValue(parameters.stiffness, 100), 1, maxSpringParamValue);
- this.d = clamp(setValue(parameters.damping, 10), .1, maxSpringParamValue);
- this.v = clamp(setValue(parameters.velocity, 0), -maxSpringParamValue, maxSpringParamValue);
- this.w0 = 0;
- this.zeta = 0;
- this.wd = 0;
- this.b = 0;
- this.solverDuration = 0;
- this.duration = 0;
- this.compute();
- /** @type {EasingFunction} */
- this.ease = t => t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
- }
-
- /** @type {EasingFunction} */
- solve(time) {
- const { zeta, w0, wd, b } = this;
- let t = time;
- if (zeta < 1) {
- t = exp(-t * zeta * w0) * (1 * cos(wd * t) + b * sin(wd * t));
- } else {
- t = (1 + b * t) * exp(-t * w0);
- }
- return 1 - t;
- }
-
- compute() {
- const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
- const w0 = this.w0 = clamp(sqrt(s / m), minValue, K);
- const zeta = this.zeta = d / (2 * sqrt(s * m));
- const wd = this.wd = zeta < 1 ? w0 * sqrt(1 - zeta * zeta) : 0;
- this.b = zeta < 1 ? (zeta * w0 + -v) / wd : -v + w0;
- let solverTime = 0;
- let restSteps = 0;
- let iterations = 0;
- while (restSteps < maxRestSteps && iterations < maxIterations) {
- if (abs(1 - this.solve(solverTime)) < restThreshold) {
- restSteps++;
- } else {
- restSteps = 0;
- }
- this.solverDuration = solverTime;
- solverTime += timeStep;
- iterations++;
- }
- this.duration = round(this.solverDuration * K, 0) * globals.timeScale;
- }
-
- get mass() {
- return this.m;
- }
-
- set mass(v) {
- this.m = clamp(setValue(v, 1), 0, maxSpringParamValue);
- this.compute();
- }
-
- get stiffness() {
- return this.s;
- }
-
- set stiffness(v) {
- this.s = clamp(setValue(v, 100), 1, maxSpringParamValue);
- this.compute();
- }
-
- get damping() {
- return this.d;
- }
-
- set damping(v) {
- this.d = clamp(setValue(v, 10), .1, maxSpringParamValue);
- this.compute();
- }
-
- get velocity() {
- return this.v;
- }
-
- set velocity(v) {
- this.v = clamp(setValue(v, 0), -maxSpringParamValue, maxSpringParamValue);
- this.compute();
- }
-}
-
-/**
- * @param {SpringParams} [parameters]
- * @returns {Spring}
- */
-export const createSpring = (parameters) => new Spring(parameters);
diff --git a/src/timeline/timeline.js b/src/timeline/timeline.js
index 82152b1e..4bd1fc34 100644
--- a/src/timeline/timeline.js
+++ b/src/timeline/timeline.js
@@ -51,7 +51,7 @@ import {
import {
parseEase,
-} from '../easings/eases.js';
+} from '../easings/eases/parser.js';
import {
parseTimelinePosition,
diff --git a/src/types/index.js b/src/types/index.js
index 5e3704a5..61fca480 100644
--- a/src/types/index.js
+++ b/src/types/index.js
@@ -1,4 +1,4 @@
-// Needed to transform this file as an valid ESM module
+// Needed to transform this file into a valid ESM module
export {}
@@ -14,7 +14,7 @@ export {}
* @import { Draggable } from '../draggable/draggable.js';
* @import { TextSplitter } from '../text/split.js';
* @import { Scope } from '../scope/scope.js';
- * @import { Spring } from '../spring/spring.js';
+ * @import { Spring } from '../easings/spring/index.js';
* @import { compositionTypes, tweenTypes, valueTypes } from '../core/consts.js';
*/
@@ -32,6 +32,7 @@ export {}
* @property {Number|Boolean} [loop]
* @property {Boolean} [reversed]
* @property {Boolean} [alternate]
+ * @property {Boolean} [persist]
* @property {Boolean|ScrollObserver} [autoplay]
* @property {Number|FunctionValue} [duration]
* @property {Number|FunctionValue} [delay]
@@ -39,13 +40,13 @@ export {}
* @property {EasingParam} [ease]
* @property {'none'|'replace'|'blend'|compositionTypes} [composition]
* @property {(v: any) => any} [modifier]
- * @property {(tickable: Tickable) => void} [onBegin]
- * @property {(tickable: Tickable) => void} [onBeforeUpdate]
- * @property {(tickable: Tickable) => void} [onUpdate]
- * @property {(tickable: Tickable) => void} [onLoop]
- * @property {(tickable: Tickable) => void} [onPause]
- * @property {(tickable: Tickable) => void} [onComplete]
- * @property {(renderable: Renderable) => void} [onRender]
+ * @property {Callback<Tickable>} [onBegin]
+ * @property {Callback<Tickable>} [onBeforeUpdate]
+ * @property {Callback<Tickable>} [onUpdate]
+ * @property {Callback<Tickable>} [onLoop]
+ * @property {Callback<Tickable>} [onPause]
+ * @property {Callback<Tickable>} [onComplete]
+ * @property {Callback<Renderable>} [onRender]
*/
/** @typedef {JSAnimation|Timeline} Renderable */
@@ -101,7 +102,11 @@ export {}
*/
/**
- * @typedef {('linear'|'linear(x1, x2 25%, x3)'|'in'|'out'|'inOut'|'inQuad'|'outQuad'|'inOutQuad'|'inCubic'|'outCubic'|'inOutCubic'|'inQuart'|'outQuart'|'inOutQuart'|'inQuint'|'outQuint'|'inOutQuint'|'inSine'|'outSine'|'inOutSine'|'inCirc'|'outCirc'|'inOutCirc'|'inExpo'|'outExpo'|'inOutExpo'|'inBounce'|'outBounce'|'inOutBounce'|'inBack'|'outBack'|'inOutBack'|'inElastic'|'outElastic'|'inOutElastic'|'irregular'|'cubicBezier'|'steps'|'in(p = 1.675)'|'out(p = 1.675)'|'inOut(p = 1.675)'|'inBack(overshoot = 1.70158)'|'outBack(overshoot = 1.70158)'|'inOutBack(overshoot = 1.70158)'|'inElastic(amplitude = 1, period = .3)'|'outElastic(amplitude = 1, period = .3)'|'inOutElastic(amplitude = 1, period = .3)'|'irregular(length = 10, randomness = 1)'|'cubicBezier(x1, y1, x2, y2)'|'steps(steps = 10)')} EaseStringParamNames
+ * @typedef {('linear'|'none'|'in'|'out'|'inOut'|'inQuad'|'outQuad'|'inOutQuad'|'inCubic'|'outCubic'|'inOutCubic'|'inQuart'|'outQuart'|'inOutQuart'|'inQuint'|'outQuint'|'inOutQuint'|'inSine'|'outSine'|'inOutSine'|'inCirc'|'outCirc'|'inOutCirc'|'inExpo'|'outExpo'|'inOutExpo'|'inBounce'|'outBounce'|'inOutBounce'|'inBack'|'outBack'|'inOutBack'|'inElastic'|'outElastic'|'inOutElastic'|'out(p = 1.675)'|'inOut(p = 1.675)'|'inBack(overshoot = 1.7)'|'outBack(overshoot = 1.7)'|'inOutBack(overshoot = 1.7)'|'inElastic(amplitude = 1, period = .3)'|'outElastic(amplitude = 1, period = .3)'|'inOutElastic(amplitude = 1, period = .3)')} EaseStringParamNames
+ */
+
+/**
+ * @typedef {('ease'|'ease-in'|'ease-out'|'ease-in-out'|'linear(0, 0.25, 1)'|'steps'|'steps(6, start)'|'step-start'|'step-end'|'cubic-bezier(0.42, 0, 1, 1)') } WAAPIEaseStringParamNames
*/
/**
@@ -112,7 +117,7 @@ export {}
/**
* @callback BackEasing
- * @param {Number|String} [overshoot=1.70158]
+ * @param {Number|String} [overshoot=1.7]
* @return {EasingFunction}
*/
@@ -128,6 +133,7 @@ export {}
// A hack to get both ease names suggestions AND allow any strings
// https://github.com/microsoft/TypeScript/issues/29729#issuecomment-460346421
/** @typedef {(String & {})|EaseStringParamNames|EasingFunction|Spring} EasingParam */
+/** @typedef {(String & {})|EaseStringParamNames|WAAPIEaseStringParamNames|EasingFunction|Spring} WAAPIEasingParam */
// Spring types
@@ -137,6 +143,9 @@ export {}
* @property {Number} [stiffness=100] - Stiffness, default 100
* @property {Number} [damping=10] - Damping, default 10
* @property {Number} [velocity=0] - Initial velocity, default 0
+ * @property {Number} [bounce=0] - Initial bounce, default 0
+ * @property {Number} [duration=0] - The perceived duration, default 0
+ * @property {Callback<JSAnimation>} [onComplete] - Callback function called when the spring currentTime hits the perceived duration
*/
// Callback types
@@ -234,6 +243,7 @@ export {}
* @property {Number} _isOverlapped
* @property {Number} _isOverridden
* @property {Number} _renderTransforms
+ * @property {String} _inlineValue
* @property {Tween} _prevRep
* @property {Tween} _nextRep
* @property {Tween} _prevAdd
@@ -391,7 +401,7 @@ export {}
*/
/**
- * @typedef {(animation: WAAPIAnimation) => void} WAAPICallback
+ * @typedef {Callback<WAAPIAnimation>} WAAPICallback
*/
/**
@@ -400,7 +410,7 @@ export {}
* @property {WAAPIKeyframeValue} [from]
* @property {Number|WAAPIFunctionValue} [duration]
* @property {Number|WAAPIFunctionValue} [delay]
- * @property {EasingParam} [ease]
+ * @property {WAAPIEasingParam} [ease]
* @property {CompositeOperation} [composition]
*/
@@ -413,13 +423,14 @@ export {}
* @property {Number} [playbackRate]
* @property {Number|WAAPIFunctionValue} [duration]
* @property {Number|WAAPIFunctionValue} [delay]
- * @property {EasingParam} [ease]
+ * @property {WAAPIEasingParam} [ease]
* @property {CompositeOperation} [composition]
+ * @property {Boolean} [persist]
* @property {WAAPICallback} [onComplete]
*/
/**
- * @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | WAAPICallback | EasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams
+ * @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | WAAPICallback | WAAPIEasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams
*/
// Animatable types
diff --git a/src/utils/stagger.js b/src/utils/stagger.js
index b761dac8..301e69b9 100644
--- a/src/utils/stagger.js
+++ b/src/utils/stagger.js
@@ -19,7 +19,7 @@ import {
import {
parseEase,
-} from '../easings/eases.js';
+} from '../easings/eases/parser.js';
import {
parseTimelinePosition,
@@ -47,7 +47,7 @@ import {
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
diff --git a/src/waapi/composition.js b/src/waapi/composition.js
index 1178e2bf..8193f0b0 100644
--- a/src/waapi/composition.js
+++ b/src/waapi/composition.js
@@ -21,16 +21,18 @@ const WAAPIAnimationsLookups = {
* @param {DOMTarget} $el
* @param {String} [property]
* @param {WAAPIAnimation} [parent]
+ * @return {globalThis.Animation}
*/
export const removeWAAPIAnimation = ($el, property, parent) => {
let nextLookup = WAAPIAnimationsLookups._head;
+ let anim;
while (nextLookup) {
const next = nextLookup._next;
const matchTarget = nextLookup.$el === $el;
const matchProperty = !property || nextLookup.property === property;
const matchParent = !parent || nextLookup.parent === parent;
if (matchTarget && matchProperty && matchParent) {
- const anim = nextLookup.animation;
+ anim = nextLookup.animation;
try { anim.commitStyles(); } catch {};
anim.cancel();
removeChild(WAAPIAnimationsLookups, nextLookup);
@@ -39,8 +41,8 @@ export const removeWAAPIAnimation = ($el, property, parent) => {
lookupParent._completed++;
if (lookupParent.animations.length === lookupParent._completed) {
lookupParent.completed = true;
+ lookupParent.paused = true;
if (!lookupParent.muteCallbacks) {
- lookupParent.paused = true;
lookupParent.onComplete(lookupParent);
lookupParent._resolve(lookupParent);
}
@@ -49,6 +51,7 @@ export const removeWAAPIAnimation = ($el, property, parent) => {
}
nextLookup = next;
}
+ return anim;
}
/**
@@ -57,7 +60,7 @@ export const removeWAAPIAnimation = ($el, property, parent) => {
* @param {String} property
* @param {PropertyIndexedKeyframes} keyframes
* @param {KeyframeAnimationOptions} params
- * @retun {Animation}
+ * @retun {globalThis.Animation}
*/
export const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
const animation = $el.animate(keyframes, params);
@@ -72,7 +75,10 @@ export const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
removeWAAPIAnimation($el, property);
addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
+ animation.oncancel = handleRemove;
animation.onremove = handleRemove;
- animation.onfinish = handleRemove;
+ if (!parent.persist) {
+ animation.onfinish = handleRemove;
+ }
return animation;
}
diff --git a/src/waapi/waapi.js b/src/waapi/waapi.js
index 9d864e1a..a1c7a5a5 100644
--- a/src/waapi/waapi.js
+++ b/src/waapi/waapi.js
@@ -9,6 +9,7 @@ import {
stringStartsWith,
toLowerCase,
isNil,
+ round,
} from '../core/helpers.js';
import {
@@ -34,6 +35,7 @@ import {
transformsFragmentStrings,
transformsSymbol,
validTransforms,
+ cssVarPrefix,
} from '../core/consts.js';
import {
@@ -41,10 +43,8 @@ import {
} from '../easings/none.js';
import {
- easeTypes,
- easeInPower,
parseEaseString,
-} from '../easings/parser.js';
+} from '../easings/eases/parser.js';
import {
addWAAPIAnimation,
@@ -69,7 +69,7 @@ import {
/**
* @import {
* Spring,
- * } from '../spring/spring.js'
+ * } from '../easings/spring/index.js'
*/
/**
@@ -86,21 +86,11 @@ import {
*/
const easingToLinear = (fn, samples = 100) => {
const points = [];
- for (let i = 0; i <= samples; i++) points.push(fn(i / samples));
+ for (let i = 0; i <= samples; i++) points.push(round(fn(i / samples), 4));
return `linear(${points.join(', ')})`;
}
-const WAAPIEasesLookups = {
- in: 'ease-in',
- out: 'ease-out',
- inOut: 'ease-in-out',
-}
-
-const WAAPIeases = /*#__PURE__*/(() => {
- const list = {};
- for (let type in easeTypes) list[type] = (/** @type {String|Number} */p) => easeTypes[type](easeInPower(p));
- return /** @type {Record<String, EasingFunction>} */(list);
-})();
+const WAAPIEasesLookups = {}
/**
* @param {EasingParam} ease
@@ -121,9 +111,10 @@ const parseWAAPIEasing = (ease) => {
} else if (stringStartsWith(ease, 'cubicB')) {
parsedEase = toLowerCase(ease);
} else {
- const parsed = parseEaseString(ease, WAAPIeases, WAAPIEasesLookups);
+ const parsed = parseEaseString(ease);
if (isFnc(parsed)) parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
}
+ // Only cache string based easing name, otherwise function arguments get lost
WAAPIEasesLookups[ease] = parsedEase;
} else if (isFnc(ease)) {
const easing = easingToLinear(ease);
@@ -164,7 +155,8 @@ let transformsPropertiesRegistered = null;
* @return {String}
*/
const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
- let v = getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
+ // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
+ let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
if (!isNum(v)) return v;
if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
@@ -245,7 +237,7 @@ export class WAAPIAnimation {
/** @type {PlaybackDirection} */
const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
/** @type {FillMode} */
- const fill = 'forwards';
+ const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
/** @type {String} */
const easing = parseWAAPIEasing(ease);
const timeScale = (globals.timeScale === 1 ? 1 : K);
@@ -257,7 +249,7 @@ export class WAAPIAnimation {
/** @type {globalThis.Animation}] */
this.controlAnimation = null;
/** @type {Callback<this>} */
- this.onComplete = params.onComplete || noop;
+ this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.defaults.onComplete));
/** @type {Number} */
this.duration = 0;
/** @type {Boolean} */
@@ -268,6 +260,8 @@ export class WAAPIAnimation {
this.paused = !autoplay || scroll !== false;
/** @type {Boolean} */
this.reversed = reversed;
+ /** @type {Boolean} */
+ this.persist = setValue(params.persist, globals.defaults.persist);
/** @type {Boolean|ScrollObserver} */
this.autoplay = autoplay;
/** @type {Number} */
@@ -276,17 +270,18 @@ export class WAAPIAnimation {
this._resolve = noop; // Used by .then()
/** @type {Number} */
this._completed = 0;
- /** @type {Array<Object>}] */
- this._inlineStyles = parsedTargets.map($el => $el.getAttribute('style'));
+ /** @type {Array.<Object>} */
+ this._inlineStyles = [];
parsedTargets.forEach(($el, i) => {
const cachedTransforms = $el[transformsSymbol];
-
const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
+ const elStyle = $el.style;
+ const inlineStyles = this._inlineStyles[i] = {};
/** @type {Number} */
- const duration = (spring ? /** @type {Spring} */(spring).duration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
+ const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -300,6 +295,12 @@ export class WAAPIAnimation {
const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
const propertyValue = params[name];
const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
+
+ const styleName = individualTransformProperty ? 'transform' : name;
+ if (!inlineStyles[styleName]) {
+ inlineStyles[styleName] = elStyle[styleName];
+ }
+
let parsedPropertyValue;
if (isObj(propertyValue)) {
const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
@@ -308,7 +309,7 @@ export class WAAPIAnimation {
const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
/** @type {Number} */
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).duration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
+ tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
/** @type {Number} */
tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
/** @type {CompositeOperation} */
@@ -325,10 +326,10 @@ export class WAAPIAnimation {
addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
if (!isUnd(from)) {
if (!individualTransformProperty) {
- $el.style[name] = keyframes[name][0];
+ elStyle[name] = keyframes[name][0];
} else {
const key = `--${individualTransformProperty}`;
- $el.style.setProperty(key, keyframes[key][0]);
+ elStyle.setProperty(key, keyframes[key][0]);
}
}
} else {
@@ -349,7 +350,7 @@ export class WAAPIAnimation {
for (let t in cachedTransforms) {
transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
}
- $el.style.transform = transforms;
+ elStyle.transform = transforms;
}
});
@@ -394,7 +395,8 @@ export class WAAPIAnimation {
// Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
// The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
// https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
- if (t >= this.duration) anim.play();
+ // This is not needed for persisting animations since they never finish.
+ if (!this.persist && t >= this.duration) anim.play();
anim.currentTime = t;
});
}
@@ -464,13 +466,30 @@ export class WAAPIAnimation {
}
cancel() {
- this.forEach('cancel');
- return this.pause();
+ this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
+ return this.commitStyles().forEach('cancel');
}
revert() {
- this.cancel();
- this.targets.forEach(($el, i) => $el.setAttribute('style', this._inlineStyles[i]) );
+ // NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
+ // This means if you have multiple animations animating different transforms on the same target,
+ // reverting one of them will also override the transform property of the other animations.
+ // A better approach would be to store the original custom property values is they exist instead of the entire transform value,
+ // and update the CSS variables with the orignal value
+ this.cancel().targets.forEach(($el, i) => {
+ const targetStyle = $el.style;
+ const targetInlineStyles = this._inlineStyles[i];
+ for (let name in targetInlineStyles) {
+ const originalInlinedValue = targetInlineStyles[name];
+ if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ targetStyle.removeProperty(toLowerCase(name));
+ } else {
+ targetStyle[name] = originalInlinedValue;
+ }
+ }
+ // Remove style attribute if empty
+ if ($el.getAttribute('style') === emptyString) $el.removeAttribute('style');
+ });
return this;
}
diff --git a/tests/playground/sandbox/index.html b/tests/playground/sandbox/index.html
index 4e80804e..406f9b60 100644
--- a/tests/playground/sandbox/index.html
+++ b/tests/playground/sandbox/index.html
@@ -8,11 +8,14 @@
<style>
body {
display: flex;
- flex-direction: column;
+ flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: center;
height: 100vh;
+ --test-color: #00FF00;
+ --x: 5rem;
+ --y: 20rem;
}
.container {
@@ -20,14 +23,15 @@
flex-wrap: wrap;
justify-content: center;
align-items: center;
- gap: .5rem;
+ flex-direction: column;
+ gap: 1rem;
padding: 1rem;
}
.square {
width: 100px;
height: 100px;
- background: var(--red);
+ background: currentColor;
border-radius: 1rem;
padding: 1rem;
}
@@ -36,21 +40,32 @@
border-radius: 1rem;
padding: 1rem;
}
-
+ .demo .css-variables.square:after {
+ position: absolute;
+ opacity: .5;
+ top: 0;
+ left: 0;
+ content: "";
+ display: block;
+ width: 100%;
+ height: 100%;
+ background: currentColor;
+ border-radius: inherit;
+ transform: scale(var(--pseudo-el-after-scale));
+ }
</style>
</head>
<body>
- <div class="container">
- <button class="button">2000</button>
- <button class="button">4000</button>
- <button class="button">1000</button>
- </div>
- <div class="container">
- <div class="square"></div>
- <div class="square"></div>
- <div class="square"></div>
- <div class="square"></div>
- <div class="square"></div>
+ <div class="demo">
+ <div class="medium row">
+ <div class="css-variables square"></div>
+ </div>
+ <div class="medium row">
+ <div class="css-variables square"></div>
+ </div>
+ <div class="medium row">
+ <div class="css-variables square"></div>
+ </div>
</div>
<script type="module" src="./index.js"></script>
</body>
diff --git a/tests/playground/sandbox/index.js b/tests/playground/sandbox/index.js
index c3e0d32a..7f11eb24 100644
--- a/tests/playground/sandbox/index.js
+++ b/tests/playground/sandbox/index.js
@@ -1,16 +1,46 @@
-import { animate, clamp, createTimer, onScroll, random } from '../../../dist/modules/index.js';
-
-animate('square', {
- x: 100,
- duration: 200,
- autoplay: onScroll({
- target: '.container',
- sync: 1,
- })
-});
+import { waapi, animate, $, set, stagger, spring, random, utils } from '../../../dist/modules/index.js';
-animate('.square', {
- duration: () => random(1, 200)
+// const targets = $('.green');
+
+// const [$red] = $('.red');
+
+// set(targets, { y: () => random(-200, 200), x: () => random(-200, 200) });
+
+// set(targets, { backgroundColor: '#FF0000' });
+
+// let reverse = false;
+
+// const animation = animate(targets, {
+// x: 'var(--x)',
+// y: 'var(--y)',
+// backgroundColor: 'var(--test-color, #FF00FF)',
+// borderRadius: '40%',
+// rotate: 90,
+// scale: 1.25,
+// delay: stagger(100),
+// loop: true,
+// alternate: true,
+// onComplete: () => {
+// console.log('completed');
+// }
+// });
+
+// document.body.addEventListener('click', () => {
+// animation.revert();
+// });
+
+// Set the CSS variables as properties on the animated elements
+utils.set('.square', {
+ '--radius': '4px',
+ '--x': '0rem',
+ '--pseudo-el-after-scale': '1', // applied to the pseudo element "::after"
+ borderRadius: 'var(--radius)',
+ translateX: 'var(--x)',
});
-const value = clamp()
\ No newline at end of file
+// Animate the values of the CSS variables
+animate('.square', {
+ '--radius': '20px',
+ '--x': '16.5rem',
+ '--pseudo-el-after-scale': '1.55' // Animates the ":after" pseudo element of the element
+});
\ No newline at end of file
diff --git a/tests/playground/waapi/playback/index.js b/tests/playground/waapi/playback/index.js
index 1513a5f8..d375a5ed 100644
--- a/tests/playground/waapi/playback/index.js
+++ b/tests/playground/waapi/playback/index.js
@@ -33,17 +33,17 @@ const scope = createScope({
scale: 2,
backgroundColor: 'var(--bg)',
delay: stagger(70),
- loop: 4,
+ loop: 1,
alternate: true,
ease: 'inOut(4)',
duration: 750,
- onComplete: () => utils.set('.square', { backgroundColor: 'var(--yellow)' })
})
const scrollAnim = waapi.animate('.square', {
translate: ($el, i, t) => `0px ${stagger([-20, 20])($el, i, t)}rem`,
rotate: `90deg`,
delay: stagger(100),
+ reversed: true,
autoplay: onScroll({
target: document.body,
sync: 1,
diff --git a/tests/suites/animatables.test.js b/tests/suites/animatables.test.js
index b259cfb2..0f609fd0 100644
--- a/tests/suites/animatables.test.js
+++ b/tests/suites/animatables.test.js
@@ -6,7 +6,7 @@ import {
createAnimatable,
createTimer,
utils,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('Animatables', () => {
diff --git a/tests/suites/animations.test.js b/tests/suites/animations.test.js
index 1a97333a..86ef6768 100644
--- a/tests/suites/animations.test.js
+++ b/tests/suites/animations.test.js
@@ -12,7 +12,7 @@ import {
animate,
createTimer,
utils,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
import {
minValue,
diff --git a/tests/suites/callbacks.test.js b/tests/suites/callbacks.test.js
index 7161496b..1c835586 100644
--- a/tests/suites/callbacks.test.js
+++ b/tests/suites/callbacks.test.js
@@ -6,7 +6,7 @@ import {
animate,
createTimeline,
utils,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
function setupAnimationCallBack(callbackName, callbackFunc) {
const parameters = {
diff --git a/tests/suites/colors.test.js b/tests/suites/colors.test.js
index 27e18ff8..d7551833 100644
--- a/tests/suites/colors.test.js
+++ b/tests/suites/colors.test.js
@@ -6,7 +6,7 @@ import {
import {
animate,
utils,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
import {
valueTypes,
diff --git a/tests/suites/controls.test.js b/tests/suites/controls.test.js
index 51bd0e03..1351de45 100644
--- a/tests/suites/controls.test.js
+++ b/tests/suites/controls.test.js
@@ -9,8 +9,7 @@ import {
createTimeline,
createTimer,
utils,
- engine,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
import {
minValue,
@@ -290,9 +289,15 @@ suite('Controls', () => {
});
test('Revert an animation with CSS properties with existing inline styles and clean newly added inline styles', () => {
- const $target = /** @type {HTMLElement} */(document.querySelector('#target-id'));
- $target.style.height = '100px';
- const animation1 = animate($target, {
+ const targets = document.querySelectorAll('.target-class');
+ const cssText = [];
+ targets.forEach(($target, i) => {
+ const targetStyle = /** @type {HTMLElement} */($target).style;
+ targetStyle.borderRadius = `${i * 10}%`;
+ cssText[i] = targetStyle.cssText;
+ });
+ const animation1 = animate(targets, {
+ borderRadius: '50%',
width: 200,
height: 200,
});
@@ -300,13 +305,21 @@ suite('Controls', () => {
animation1.revert();
expect(animation1._cancelled).to.equal(1);
expect(animation1.paused).to.equal(true);
- expect($target.getAttribute('style')).to.equal('height: 100px;');
+ targets.forEach(($target, i) => {
+ const targetStyle = /** @type {HTMLElement} */($target).style;
+ expect(targetStyle.cssText).to.equal(cssText[i]);
+ });
});
- test('Revert an animation with Transforms properties with existing inline styles and clean newly added inline styles', () => {
- const $target = /** @type {HTMLElement} */(document.querySelector('#target-id'));
- $target.style.transform = 'translateY(100px)';
- const animation1 = animate($target, {
+ test('Revert an animation with transform properties with existing inline styles and clean newly added inline styles', () => {
+ const targets = document.querySelectorAll('.target-class');
+ const cssText = [];
+ targets.forEach(($target, i) => {
+ const targetStyle = /** @type {HTMLElement} */($target).style;
+ targetStyle.borderRadius = `${i * 10}%`;
+ cssText[i] = targetStyle.cssText;
+ });
+ const animation1 = animate(targets, {
translateX: 200,
translateY: 200,
});
@@ -314,7 +327,10 @@ suite('Controls', () => {
animation1.revert();
expect(animation1._cancelled).to.equal(1);
expect(animation1.paused).to.equal(true);
- expect($target.getAttribute('style')).to.equal('transform: translateY(100px);');
+ targets.forEach(($target, i) => {
+ const targetStyle = /** @type {HTMLElement} */($target).style;
+ expect(targetStyle.cssText).to.equal(cssText[i]);
+ });
});
test('Revert a timeline and and clean inline styles', () => {
diff --git a/tests/suites/directions.test.js b/tests/suites/directions.test.js
index 374fae99..3b2f12b9 100644
--- a/tests/suites/directions.test.js
+++ b/tests/suites/directions.test.js
@@ -5,7 +5,7 @@ import {
import {
animate,
utils,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('Directions', () => {
test('Direction normal should update from 0 to 1', resolve => {
diff --git a/tests/suites/draggables.test.js b/tests/suites/draggables.test.js
index 1060b915..cfbf3d6a 100644
--- a/tests/suites/draggables.test.js
+++ b/tests/suites/draggables.test.js
@@ -6,7 +6,7 @@ import {
createTimer,
createDraggable,
utils,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
const createMouseEvent = ($target, name, x, y) => $target.dispatchEvent(new MouseEvent('mouse' + name, {
clientX: x,
@@ -112,7 +112,7 @@ suite('Draggables', () => {
resolve();
draggable.revert();
},
- duration: 33,
+ duration: 50,
});
});
@@ -125,8 +125,8 @@ suite('Draggables', () => {
const draggable = createDraggable($target, {
container: $container,
- releaseDamping: 2000,
- releaseStiffness: 2000,
+ releaseStiffness: 10000,
+ releaseDamping: 300,
onUpdate: () => {
updates++;
},
@@ -148,7 +148,7 @@ suite('Draggables', () => {
createMouseEvent(document, 'move', ++x, 0);
createMouseEvent(document, 'up', ++x, 0);
},
- duration: 33,
+ duration: 50,
});
});
@@ -167,9 +167,11 @@ suite('Draggables', () => {
let y = 0;
const draggable = createDraggable($target, {
- releaseDamping: 2000,
- releaseStiffness: 2000,
- onUpdate: () => updates++,
+ releaseStiffness: 10000,
+ releaseDamping: 300,
+ onUpdate: () => {
+ updates++;
+ },
onSettle: () => {
expect(updates).to.be.above(0);
draggable.revert();
@@ -187,7 +189,7 @@ suite('Draggables', () => {
onComplete: () => {
createTouchEvent($target, 'end', ++x, 0);
},
- duration: 33,
+ duration: 100,
});
});
diff --git a/tests/suites/eases.test.js b/tests/suites/eases.test.js
index 1ee220d2..bc3bfd36 100644
--- a/tests/suites/eases.test.js
+++ b/tests/suites/eases.test.js
@@ -6,8 +6,11 @@ import {
animate,
utils,
eases,
- createSpring,
-} from '../../../dist/modules/index.js';
+ cubicBezier,
+ spring,
+ linear,
+ steps,
+} from '../../dist/modules/index.js';
function createEasingParam(ease) {
return {
@@ -24,7 +27,7 @@ function getOpacityValue() {
suite('Eases', () => {
- test("'linear' / eases.linear()", () => {
+ test("'linear' / eases.linear", () => {
const anim1 = animate('#target-id', createEasingParam('linear'));
anim1.seek(0);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(0);
@@ -33,7 +36,7 @@ suite('Eases', () => {
anim1.seek(100);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(1);
utils.set('#target-id', { opacity: 0 });
- const anim2 = animate('#target-id', createEasingParam(eases.linear()));
+ const anim2 = animate('#target-id', createEasingParam(eases.linear));
anim2.seek(0);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(0);
anim2.seek(50);
@@ -42,8 +45,8 @@ suite('Eases', () => {
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(1);
});
- test("'linear(0, 1)' / eases.linear(0, 1)", () => {
- const anim1 = animate('#target-id', createEasingParam('linear(0, 1)'));
+ test("'none' / eases.none", () => {
+ const anim1 = animate('#target-id', createEasingParam('none'));
anim1.seek(0);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(0);
anim1.seek(50);
@@ -51,7 +54,7 @@ suite('Eases', () => {
anim1.seek(100);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(1);
utils.set('#target-id', { opacity: 0 });
- const anim2 = animate('#target-id', createEasingParam(eases.linear(0, 1)));
+ const anim2 = animate('#target-id', createEasingParam(eases.none));
anim2.seek(0);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(0);
anim2.seek(50);
@@ -60,34 +63,28 @@ suite('Eases', () => {
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(1);
});
- test("Custom linear 'linear(0, 0.25, 1)' / eases.linear(0, 0.25, 1)", () => {
- const anim1 = animate('#target-id', createEasingParam('linear(0, 0.25, 1)'));
- anim1.seek(0);
- expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(0);
- anim1.seek(50);
- expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(.25);
- anim1.seek(100);
- expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(1);
- utils.set('#target-id', { opacity: 0 });
- const anim2 = animate('#target-id', createEasingParam(eases.linear(0, 0.25, 1)));
+ test("linear(0, 1)", () => {
+ const anim2 = animate('#target-id', createEasingParam(linear(0, 1)));
anim2.seek(0);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(0);
anim2.seek(50);
- expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(.25);
+ expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(.5);
anim2.seek(100);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(1);
});
- test("Custom uneven linear 'linear(0, 0.25 75%, 1)' / eases.linear(0, '0.25 75%', 1)", () => {
- const anim1 = animate('#target-id', createEasingParam('linear(0, 0.25 75%, 1)'));
- anim1.seek(0);
+ test("Custom linear linear(0, 0.25, 1)", () => {
+ const anim2 = animate('#target-id', createEasingParam(linear(0, 0.25, 1)));
+ anim2.seek(0);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(0);
- anim1.seek(75);
+ anim2.seek(50);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(.25);
- anim1.seek(100);
+ anim2.seek(100);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(1);
- utils.set('#target-id', { opacity: 0 });
- const anim2 = animate('#target-id', createEasingParam(eases.linear(0, '0.25 75%', 1)));
+ });
+
+ test("Custom uneven linear linear(0, '0.25 75%', 1)", () => {
+ const anim2 = animate('#target-id', createEasingParam(linear(0, '0.25 75%', 1)));
anim2.seek(0);
expect(parseFloat(utils.get('#target-id', 'opacity'))).to.equal(0);
anim2.seek(75);
@@ -162,7 +159,7 @@ suite('Eases', () => {
});
test('Spring ease overrides animation\'s duration parameter', () => {
- const animationParams = createEasingParam(createSpring());
+ const animationParams = createEasingParam(spring());
animationParams.duration = 500;
const animation = animate('#target-id', animationParams);
expect(animation.duration).to.be.above(1000);
@@ -173,7 +170,7 @@ suite('Eases', () => {
opacity: [0, 1],
translateX: {
to: 100,
- ease: createSpring(),
+ ease: spring(),
duration: 500
},
duration: 400,
@@ -184,101 +181,92 @@ suite('Eases', () => {
test('Spring ease parameters affect animation\'s duration', () => {
const target = '#target-id';
- expect(animate(target, createEasingParam(createSpring())).duration).to.equal(1740);
- expect(animate(target, createEasingParam(createSpring({ mass: 10 }))).duration).to.equal(13680);
- expect(animate(target, createEasingParam(createSpring({ stiffness: 50 }))).duration).to.equal(1740);
- expect(animate(target, createEasingParam(createSpring({ damping: 50 }))).duration).to.equal(1180);
- expect(animate(target, createEasingParam(createSpring({ velocity: 10 }))).duration).to.equal(1680);
+ expect(animate(target, createEasingParam(spring())).duration).to.equal(1760);
+ expect(animate(target, createEasingParam(spring({ mass: 10 }))).duration).to.equal(13700);
+ expect(animate(target, createEasingParam(spring({ stiffness: 50 }))).duration).to.equal(1760);
+ expect(animate(target, createEasingParam(spring({ damping: 50 }))).duration).to.equal(3880);
+ expect(animate(target, createEasingParam(spring({ velocity: 10 }))).duration).to.equal(1700);
});
test('Setting a Spring parameter after creation should update its duration', () => {
- const spring = createSpring();
- expect(spring.duration).to.equal(1740);
- spring.mass = 10;
- expect(spring.duration).to.equal(13680);
- expect(spring.mass).to.equal(10);
- spring.mass = 1;
- spring.stiffness = 50;
- expect(spring.mass).to.equal(1);
- expect(spring.stiffness).to.equal(50);
- expect(spring.duration).to.equal(1740);
- spring.stiffness = 100;
- spring.damping = 50;
- expect(spring.stiffness).to.equal(100);
- expect(spring.damping).to.equal(50);
- expect(spring.duration).to.equal(1180);
- spring.damping = 10;
- spring.velocity = 10;
- expect(spring.damping).to.equal(10);
- expect(spring.velocity).to.equal(10);
- expect(spring.duration).to.equal(1680);
+ const springEasing = spring();
+ expect(springEasing.settlingDuration).to.equal(1760);
+ springEasing.mass = 10;
+ expect(springEasing.settlingDuration).to.equal(13700);
+ expect(springEasing.mass).to.equal(10);
+ springEasing.mass = 1;
+ springEasing.stiffness = 50;
+ expect(springEasing.mass).to.equal(1);
+ expect(springEasing.stiffness).to.equal(50);
+ expect(springEasing.settlingDuration).to.equal(1760);
+ springEasing.stiffness = 100;
+ springEasing.damping = 50;
+ expect(springEasing.stiffness).to.equal(100);
+ expect(springEasing.damping).to.equal(50);
+ expect(springEasing.settlingDuration).to.equal(3880);
+ springEasing.damping = 10;
+ springEasing.velocity = 10;
+ expect(springEasing.damping).to.equal(10);
+ expect(springEasing.velocity).to.equal(10);
+ expect(springEasing.settlingDuration).to.equal(1700);
});
test('Spring parameters must be clamped at 10000', () => {
- const spring = createSpring({
+ const springEasing = spring({
mass: 15000,
stiffness: 15000,
damping: 15000,
velocity: 15000,
});
- expect(spring.mass).to.equal(10000);
- expect(spring.stiffness).to.equal(10000);
- expect(spring.damping).to.equal(10000);
- expect(spring.velocity).to.equal(10000);
- expect(spring.duration).to.be.above(0);
+ expect(springEasing.mass).to.equal(10000);
+ expect(springEasing.stiffness).to.equal(10000);
+ expect(springEasing.damping).to.equal(10000);
+ expect(springEasing.velocity).to.equal(10000);
+ expect(springEasing.settlingDuration).to.be.above(0);
- spring.mass = 20000;
- spring.stiffness = 20000;
- spring.damping = 20000;
- spring.velocity = 20000;
+ springEasing.mass = 20000;
+ springEasing.stiffness = 20000;
+ springEasing.damping = 20000;
+ springEasing.velocity = 20000;
- expect(spring.mass).to.equal(10000);
- expect(spring.stiffness).to.equal(10000);
- expect(spring.damping).to.equal(10000);
- expect(spring.velocity).to.equal(10000);
- expect(spring.duration).to.be.above(0);
+ expect(springEasing.mass).to.equal(10000);
+ expect(springEasing.stiffness).to.equal(10000);
+ expect(springEasing.damping).to.equal(10000);
+ expect(springEasing.velocity).to.equal(10000);
+ expect(springEasing.settlingDuration).to.be.above(0);
});
test('Spring velocity can be negative', () => {
- const spring = createSpring({
+ const springEasing = spring({
velocity: -15000,
});
- expect(spring.velocity).to.equal(-10000);
- expect(spring.duration).to.be.above(0);
- spring.velocity = -20000;
- expect(spring.velocity).to.equal(-10000);
- expect(spring.duration).to.be.above(0);
+ expect(springEasing.velocity).to.equal(-10000);
+ expect(springEasing.settlingDuration).to.be.above(0);
+ springEasing.velocity = -20000;
+ expect(springEasing.velocity).to.equal(-10000);
+ expect(springEasing.settlingDuration).to.be.above(0);
});
- test('Cubic bézier in: "cubicBezier(1,0,1,0)" / eases.cubicBezier(1,0,1,0)', () => {
- const cubicBezierIn = animate('#target-id', createEasingParam(eases.cubicBezier(1,0,1,0)));
+ test('Cubic bézier in: cubicBezier(1,0,1,0)', () => {
+ const cubicBezierIn = animate('#target-id', createEasingParam(cubicBezier(1,0,1,0)));
cubicBezierIn.seek(50);
expect(getOpacityValue()).to.be.below(.5);
- const cubicBezierInString = animate('#target-id', createEasingParam('cubicBezier(1,0,1,0)'));
- cubicBezierInString.seek(50);
- expect(getOpacityValue()).to.be.below(.5);
});
- test('Cubic bézier out: "cubicBezier(0,1,0,1)" / eases.cubicBezier(0,1,0,1)', () => {
- const cubicBezierOut = animate('#target-id', createEasingParam(eases.cubicBezier(0,1,0,1)));
+ test('Cubic bézier out: cubicBezier(0,1,0,1)', () => {
+ const cubicBezierOut = animate('#target-id', createEasingParam(cubicBezier(0,1,0,1)));
cubicBezierOut.seek(50);
expect(getOpacityValue()).to.be.above(.5);
- const cubicBezierOutString = animate('#target-id', createEasingParam('cubicBezier(0,1,0,1)'));
- cubicBezierOutString.seek(50);
- expect(getOpacityValue()).to.be.above(.5);
});
- test('Cubic bézier inOut: "cubicBezier(1,0,0,1)" / eases.cubicBezier(1,0,0,1)', () => {
- const cubicBezierInOut = animate('#target-id', createEasingParam(eases.cubicBezier(1,0,0,1)));
+ test('Cubic bézier inOut: cubicBezier(1,0,0,1)', () => {
+ const cubicBezierInOut = animate('#target-id', createEasingParam(cubicBezier(1,0,0,1)));
cubicBezierInOut.seek(50);
expect(getOpacityValue()).to.be.equal(.5);
- const cubicBezierInOutString = animate('#target-id', createEasingParam('cubicBezier(1,0,0,1)'));
- cubicBezierInOutString.seek(50);
- expect(getOpacityValue()).to.be.equal(.5);
});
test('Steps from end (default)', () => {
- const cubicBezierIn = animate('#target-id', createEasingParam('steps(4)'));
+ const cubicBezierIn = animate('#target-id', createEasingParam(steps(4)));
cubicBezierIn.seek(0);
expect(getOpacityValue()).to.equal(0);
cubicBezierIn.seek(24);
@@ -300,7 +288,7 @@ suite('Eases', () => {
});
test('Steps from start', () => {
- const cubicBezierIn = animate('#target-id', createEasingParam('steps(4, true)'));
+ const cubicBezierIn = animate('#target-id', createEasingParam(steps(4, true)));
cubicBezierIn.seek(0);
expect(getOpacityValue()).to.equal(0);
cubicBezierIn.seek(1);
diff --git a/tests/suites/engine.test.js b/tests/suites/engine.test.js
index 16349775..419a358a 100644
--- a/tests/suites/engine.test.js
+++ b/tests/suites/engine.test.js
@@ -6,7 +6,7 @@ import {
animate,
engine,
utils,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
const defaultEnginePauseState = engine.paused;
const defaultEngineReqId = engine.reqId;
diff --git a/tests/suites/function-based-values.test.js b/tests/suites/function-based-values.test.js
index ed01518b..ba31eca0 100644
--- a/tests/suites/function-based-values.test.js
+++ b/tests/suites/function-based-values.test.js
@@ -4,7 +4,7 @@ import {
getTweenDelay,
} from '../utils.js';
-import { animate, stagger, utils } from '../../../dist/modules/index.js';
+import { animate, stagger, utils } from '../../dist/modules/index.js';
import {
valueTypes,
diff --git a/tests/suites/keyframes.test.js b/tests/suites/keyframes.test.js
index 19fdd9a5..4edaa3c2 100644
--- a/tests/suites/keyframes.test.js
+++ b/tests/suites/keyframes.test.js
@@ -4,7 +4,7 @@ import {
getTweenDelay,
} from '../utils.js';
-import { animate, utils } from '../../../dist/modules/index.js';
+import { animate, utils } from '../../dist/modules/index.js';
import {
valueTypes,
diff --git a/tests/suites/leaks.test.js b/tests/suites/leaks.test.js
index 0aa8c2cc..4b0fa591 100644
--- a/tests/suites/leaks.test.js
+++ b/tests/suites/leaks.test.js
@@ -4,7 +4,7 @@ import {
import {
engine,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('Leaks', () => {
test('Engine should not contain any active tickable', resolve => {
diff --git a/tests/suites/parameters.test.js b/tests/suites/parameters.test.js
index 944f898d..44a1ace0 100644
--- a/tests/suites/parameters.test.js
+++ b/tests/suites/parameters.test.js
@@ -8,7 +8,7 @@ import {
testObject,
} from '../setup.js';
-import { animate, createTimeline, createTimer, utils } from '../../../dist/modules/index.js';
+import { animate, createTimeline, createTimer, utils } from '../../dist/modules/index.js';
import { minValue } from '../../dist/modules/core/consts.js';
suite('Parameters', () => {
diff --git a/tests/suites/promises.test.js b/tests/suites/promises.test.js
index c51bfcea..5132cc74 100644
--- a/tests/suites/promises.test.js
+++ b/tests/suites/promises.test.js
@@ -2,7 +2,7 @@ import {
expect,
} from '../utils.js';
-import { animate, createTimeline, createTimer, utils } from '../../../dist/modules/index.js';
+import { animate, createTimeline, createTimer, utils } from '../../dist/modules/index.js';
suite('Promises', () => {
diff --git a/tests/suites/scope.test.js b/tests/suites/scope.test.js
index aeab7e46..ec9d139d 100644
--- a/tests/suites/scope.test.js
+++ b/tests/suites/scope.test.js
@@ -4,7 +4,7 @@ import {
import {
createScope,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('Scope', () => {
diff --git a/tests/suites/scroll.test.js b/tests/suites/scroll.test.js
index d1a9abda..b56e15ee 100644
--- a/tests/suites/scroll.test.js
+++ b/tests/suites/scroll.test.js
@@ -7,7 +7,7 @@ import {
scrollContainers,
animate,
utils
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('Scroll', () => {
test('Reverting an animation with onScroll should also revert the ScrollObserver', () => {
diff --git a/tests/suites/seconds.test.js b/tests/suites/seconds.test.js
index 40178e81..8314ec63 100644
--- a/tests/suites/seconds.test.js
+++ b/tests/suites/seconds.test.js
@@ -12,7 +12,7 @@ import {
createTimeline,
createTimer,
engine,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('Seconds', () => {
diff --git a/tests/suites/stagger.test.js b/tests/suites/stagger.test.js
index e1bed7e9..b2d29e9c 100644
--- a/tests/suites/stagger.test.js
+++ b/tests/suites/stagger.test.js
@@ -4,7 +4,7 @@ import {
getTweenDelay,
} from '../utils.js';
-import { animate, stagger, createTimeline } from '../../../dist/modules/index.js';
+import { animate, stagger, createTimeline } from '../../dist/modules/index.js';
suite('Stagger', () => {
test('Increase each values by a specific value for each elements', () => {
diff --git a/tests/suites/svg.test.js b/tests/suites/svg.test.js
index 92f88fc5..a63db90f 100644
--- a/tests/suites/svg.test.js
+++ b/tests/suites/svg.test.js
@@ -7,7 +7,7 @@ import {
animate,
utils,
svg,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('SVG', () => {
test('svg.createDrawable', resolve => {
diff --git a/tests/suites/targets.test.js b/tests/suites/targets.test.js
index aa72cece..f2ee6083 100644
--- a/tests/suites/targets.test.js
+++ b/tests/suites/targets.test.js
@@ -10,7 +10,7 @@ import {
import {
animate,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('Targets', () => {
test('Single element from CSS selector', () => {
diff --git a/tests/suites/text.test.js b/tests/suites/text.test.js
index 6425ae77..46fcd3d0 100644
--- a/tests/suites/text.test.js
+++ b/tests/suites/text.test.js
@@ -7,7 +7,7 @@ import {
utils,
splitText,
animate,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
// Firefox detect Japanse words differently
const wordsLength = browserIs.firefox ? 44 : 45;
diff --git a/tests/suites/timelines.test.js b/tests/suites/timelines.test.js
index 5f2b1162..636aff17 100644
--- a/tests/suites/timelines.test.js
+++ b/tests/suites/timelines.test.js
@@ -6,10 +6,11 @@ import {
import {
createTimeline,
eases,
+ steps,
utils,
createTimer,
animate,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
import {
compositionTypes,
@@ -821,7 +822,7 @@ suite('Timelines', () => {
duration: 500,
opacity: [1, .5],
delay: (el, i) => i * 500,
- ease: 'steps(1)',
+ ease: steps(1),
}, 0)
.call(() => { timer1Log += 1; }, 0)
.call(() => { timer2Log += 1; }, 500)
@@ -848,6 +849,48 @@ suite('Timelines', () => {
expect($targets[2].style.opacity).to.equal('1');
});
+ test('.call with odd floating points values A', resolve => {
+ let timer1Log = 0;
+ let timer2Log = 0;
+ let timer3Log = 0;
+ let timer4Log = 0;
+ const tl = createTimeline({
+ onComplete: () => {
+ expect(timer1Log).to.equal(1);
+ expect(timer2Log).to.equal(1);
+ expect(timer3Log).to.equal(1);
+ expect(timer4Log).to.equal(1);
+ resolve();
+ }
+ })
+ .call(() => ++timer1Log, 0)
+ .call(() => ++timer2Log, 800)
+ .call(() => ++timer3Log, 8700)
+ .call(() => ++timer4Log, 8650)
+ .seek(8650);
+ });
+
+ test('.call with odd floating points values B', resolve => {
+ let timer1Log = 0;
+ let timer2Log = 0;
+ let timer3Log = 0;
+ let timer4Log = 0;
+ const tl = createTimeline({
+ onComplete: () => {
+ expect(timer1Log).to.equal(1);
+ expect(timer2Log).to.equal(1);
+ expect(timer3Log).to.equal(1);
+ expect(timer4Log).to.equal(1);
+ resolve();
+ }
+ })
+ .call(() => ++timer1Log, 0)
+ .call(() => ++timer2Log, 800)
+ .call(() => ++timer3Log, 8000)
+ .call(() => ++timer4Log, 8450)
+ .seek(8400);
+ });
+
test('Set values should properly update on loop', () => {
const $targets = utils.$(['.target-class:nth-child(1)', '.target-class:nth-child(2)', '.target-class:nth-child(3)']);
const tl = createTimeline({
@@ -862,7 +905,7 @@ suite('Timelines', () => {
duration: 500,
opacity: [1, .5],
delay: (el, i) => i * 500,
- ease: 'steps(1)',
+ ease: steps(1),
}, 0)
.init()
diff --git a/tests/suites/timings.test.js b/tests/suites/timings.test.js
index 5324c624..4a100efd 100644
--- a/tests/suites/timings.test.js
+++ b/tests/suites/timings.test.js
@@ -6,7 +6,7 @@ import {
import {
animate,
utils
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('Timings', () => {
test('Specified timings parameters', resolve => {
diff --git a/tests/suites/tweens.test.js b/tests/suites/tweens.test.js
index 8143627e..8a5f6994 100644
--- a/tests/suites/tweens.test.js
+++ b/tests/suites/tweens.test.js
@@ -11,7 +11,7 @@ import {
createTimer,
createTimeline,
engine,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
import {
compositionTypes,
diff --git a/tests/suites/types.test.js b/tests/suites/types.test.js
index d0e188b3..efb86d0b 100644
--- a/tests/suites/types.test.js
+++ b/tests/suites/types.test.js
@@ -1,4 +1,4 @@
-import { animate, createTimer, createTimeline, utils } from '../../../dist/modules/index.js';
+import { animate, createTimer, createTimeline, utils } from '../../dist/modules/index.js';
animate('.anime-css', {
keyframes: {
diff --git a/tests/suites/units.test.js b/tests/suites/units.test.js
index b5c7ff1f..c94d1cb0 100644
--- a/tests/suites/units.test.js
+++ b/tests/suites/units.test.js
@@ -6,7 +6,7 @@ import {
import {
animate,
utils,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
const validUnits = ['cm','mm','in','pc','pt','px','em','ex','ch','rem','vw','vh','vmin','vmax','q','lh','rlh','vb','vi','svw','svh','lvw','lvh','dvw','dvh'];
diff --git a/tests/suites/utils.test.js b/tests/suites/utils.test.js
index f0abd219..6223aa7b 100644
--- a/tests/suites/utils.test.js
+++ b/tests/suites/utils.test.js
@@ -2,7 +2,7 @@ import {
utils,
animate,
createTimeline,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
import {
expect,
diff --git a/tests/suites/values.test.js b/tests/suites/values.test.js
index c4b41f88..76a0d3e4 100644
--- a/tests/suites/values.test.js
+++ b/tests/suites/values.test.js
@@ -7,7 +7,7 @@ import {
import {
animate,
utils,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
import {
unitsExecRgx,
@@ -491,32 +491,40 @@ suite('Values', () => {
test('CSS Variables in Transforms', () => {
/** @type {HTMLElement} */
const $target = document.querySelector('#target-id');
- utils.set($target, {
- '--x': '12rem',
- '--rx': '45deg',
- '--s': 2,
+ const x = '12rem';
+ const rx = '45deg';
+ const s = '2';
+ // defined and set the variables in two different set() callS otherwise the values won't be properly computed
+ utils.set($target, { '--x': x, '--rx': rx, '--s': s });
+ const setter = utils.set($target, {
translateX: 'var(--x)',
rotateX: 'var(--rx)',
scale: 'var(--s)'
});
- expect(getComputedStyle($target).getPropertyValue('--x')).to.equal('12rem');
- expect(getComputedStyle($target).getPropertyValue('--rx')).to.equal('45deg');
- expect(getComputedStyle($target).getPropertyValue('--s')).to.equal('2');
+ expect(getComputedStyle($target).getPropertyValue('--x')).to.equal(x);
+ expect(getComputedStyle($target).getPropertyValue('--rx')).to.equal(rx);
+ expect(getComputedStyle($target).getPropertyValue('--s')).to.equal(s);
let transforms = $target.style.transform;
- expect(transforms).to.equal('translateX(var(--x)) rotateX(var(--rx)) scale(var(--s))');
+ expect(transforms).to.equal(`translateX(${x}) rotateX(${rx}) scale(${s})`);
+ const x2 = '19rem';
+ const rx2 = '64deg';
+ const s2 = '1.25';
const animation = animate($target, {
- '--x': '19rem',
- '--rx': '64deg',
- '--s': 1.25,
+ '--x': x2,
+ '--rx': rx2,
+ '--s': s2,
duration: 10
});
animation.pause().seek(animation.duration);
- expect(getComputedStyle($target).getPropertyValue('--x')).to.equal('19rem');
- expect(getComputedStyle($target).getPropertyValue('--rx')).to.equal('64deg');
- expect(getComputedStyle($target).getPropertyValue('--s')).to.equal('1.25');
+ expect(getComputedStyle($target).getPropertyValue('--x')).to.equal(x2);
+ expect(getComputedStyle($target).getPropertyValue('--rx')).to.equal(rx2);
+ expect(getComputedStyle($target).getPropertyValue('--s')).to.equal(s2);
+ // Setting css variables with utils.set() will convert the variable to a static computed value
+ // So we need to refresh the setter in order to get the updated values from the animation
+ setter.refresh();
transforms = $target.style.transform;
- expect(transforms).to.equal('translateX(var(--x)) rotateX(var(--rx)) scale(var(--s))');
+ expect(transforms).to.equal(`translateX(${x2}) rotateX(${rx2}) scale(${s2})`);
});
test('From values', () => {
diff --git a/tests/suites/waapi.test.js b/tests/suites/waapi.test.js
index 4a9aafeb..e0504f39 100644
--- a/tests/suites/waapi.test.js
+++ b/tests/suites/waapi.test.js
@@ -7,7 +7,7 @@ import {
utils,
stagger,
eases,
-} from '../../../dist/modules/index.js';
+} from '../../dist/modules/index.js';
suite('WAAPI', () => {
@@ -188,10 +188,11 @@ suite('WAAPI', () => {
targets.forEach($el => {
expect(utils.get($el, 'opacity')).to.equal('0.5');
expect(utils.get($el, 'backgroundColor')).to.equal('rgb(255, 0, 0)');
- expect(utils.get($el, '--translateX')).to.equal('0px');
- expect(utils.get($el, '--translateY')).to.equal('0px');
- expect(utils.get($el, '--rotate')).to.equal('0deg');
- expect(utils.get($el, '--scale')).to.equal('1');
+ expect(utils.get($el, 'transform')).to.equal('none');
+ // expect(utils.get($el, '--translateX')).to.equal('0px');
+ // expect(utils.get($el, '--translateY')).to.equal('0px');
+ // expect(utils.get($el, '--rotate')).to.equal('0deg');
+ // expect(utils.get($el, '--scale')).to.equal('1');
});
resolve();
},
diff --git a/tests/tsconfig.json b/tests/tsconfig.json
new file mode 100644
index 00000000..6137d41e
--- /dev/null
+++ b/tests/tsconfig.json
@@ -0,0 +1,10 @@
+{
+ "extends": "../tsconfig.json",
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "animejs": ["dist/modules/index.js"],
+ }
+ },
+ "include": ["**/*.js"]
+}
\ No newline at end of file
diff --git a/tsconfig.types.json b/tsconfig.types.json
index 8031b1cf..cba03c48 100644
--- a/tsconfig.types.json
+++ b/tsconfig.types.json
@@ -8,26 +8,7 @@
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
- "skipLibCheck": true,
"outDir": "./dist/modules/"
},
- "include": [
- "./src/index.js",
- "./src/timer/index.js",
- "./src/animation/index.js",
- "./src/timeline/index.js",
- "./src/animatable/index.js",
- "./src/draggable/index.js",
- "./src/scope/index.js",
- "./src/events/index.js",
- "./src/spring/index.js",
- "./src/engine/index.js",
- "./src/easings/index.js",
- "./src/utils/index.js",
- "./src/svg/index.js",
- "./src/text/index.js",
- "./src/waapi/index.js",
- "./src/types/index.js",
- ],
- "exclude": [] // Needed to allow include and outDir to be the same
+ "include": ["./src/**/*.js"],
}
\ No newline at end of file
diff --git a/types/index.d.ts b/types/index.d.ts
deleted file mode 100644
index 95069076..00000000
--- a/types/index.d.ts
+++ /dev/null
@@ -1,1126 +0,0 @@
-/// <reference types="node" />
-declare class Engine extends Clock {
- useDefaultMainLoop: boolean;
- pauseOnDocumentHidden: boolean;
- defaults: DefaultsParams;
- paused: boolean;
- reqId: number | NodeJS.Immediate;
- update(): void;
- wake(): this;
- pause(): Engine;
- resume(): this;
- set timeUnit(arg: "ms" | "s");
- get timeUnit(): "ms" | "s";
- set precision(arg: number);
- get precision(): number;
-}
-declare const engine: Engine;
-declare class Clock {
- constructor(initTime?: number);
- deltaTime: number;
- _currentTime: number;
- _elapsedTime: number;
- _startTime: number;
- _lastTime: number;
- _scheduledTime: number;
- _frameDuration: number;
- _fps: number;
- _speed: number;
- _hasChildren: boolean;
- _head: Tickable | Tween;
- _tail: Tickable | Tween;
- set fps(arg: number);
- get fps(): number;
- set speed(arg: number);
- get speed(): number;
- requestTick(time: number): tickModes;
- computeDeltaTime(time: number): number;
-}
-type tweenTypes = number;
-declare namespace tweenTypes {
- let OBJECT: number;
- let ATTRIBUTE: number;
- let CSS: number;
- let TRANSFORM: number;
- let CSS_VAR: number;
-}
-type valueTypes = number;
-declare namespace valueTypes {
- let NUMBER: number;
- let UNIT: number;
- let COLOR: number;
- let COMPLEX: number;
-}
-type tickModes = number;
-declare namespace tickModes {
- let NONE: number;
- let AUTO: number;
- let FORCE: number;
-}
-type compositionTypes = number;
-declare namespace compositionTypes {
- let replace: number;
- let none: number;
- let blend: number;
-}
-declare function getTargetValue(targetSelector: DOMTargetSelector, propName: string): string;
-declare function getTargetValue(targetSelector: JSTargetsParam, propName: string): number | string;
-declare function getTargetValue(targetSelector: DOMTargetsParam, propName: string, unit: string): string;
-declare function getTargetValue(targetSelector: TargetsParam, propName: string, unit: boolean): number;
-declare function sync(callback?: Callback<Timer>): Timer;
-declare function setTargetValues(targets: TargetsParam, parameters: AnimationParams): JSAnimation;
-declare function remove(targets: TargetsParam, renderable?: Renderable | WAAPIAnimation, propertyName?: string): TargetsArray;
-declare const keepTime: (constructor: (...args: any[]) => Tickable | ((...args: any[]) => void)) => (...args: any[]) => Tickable | ((...args: any[]) => void);
-declare function lerp(start: number, end: number, amount: number, renderable?: Renderable | boolean): number;
-declare namespace utils {
- export { registerTargets as $ };
- export { getTargetValue as get };
- export { setTargetValues as set };
- export { remove };
- export { cleanInlineStyles };
- export { random };
- export { randomPick };
- export { shuffle };
- export { lerp };
- export { sync };
- export { keepTime };
- export let clamp: ((v: number, min: number, max: number) => number) & ChainedClamp;
- export let round: ((v: number, decimalLength: number) => number) & ChainedRound;
- export let snap: ((v: number, increment: number | number[]) => number) & ChainedSnap;
- export let wrap: ((v: number, min: number, max: number) => number) & ChainedWrap;
- export let interpolate: ((start: number, end: number, progress: number) => number) & ChainedInterpolate;
- export let mapRange: ((value: number, inLow: number, inHigh: number, outLow: number, outHigh: number) => number) & ChainedMapRange;
- export let roundPad: ((v: string | number, decimalLength: number) => string) & ChainedRoundPad;
- export let padStart: ((v: number, totalLength: number, padString: string) => string) & ChainedPadStart;
- export let padEnd: ((v: number, totalLength: number, padString: string) => string) & ChainedPadEnd;
- export let degToRad: ((degrees: number) => number) & ChainedDegToRad;
- export let radToDeg: ((radians: number) => number) & ChainedRadToDeg;
-}
-type ChainedUtilsResult = (value: number) => number;
-type ChainableUtils = {
- clamp: ChainedClamp;
- round: ChainedRound;
- snap: ChainedSnap;
- wrap: ChainedWrap;
- interpolate: ChainedInterpolate;
- mapRange: ChainedMapRange;
- roundPad: ChainedRoundPad;
- padStart: ChainedPadStart;
- padEnd: ChainedPadEnd;
- degToRad: ChainedDegToRad;
- radToDeg: ChainedRadToDeg;
-};
-type ChainableUtil = ChainableUtils & ChainedUtilsResult;
-type ChainedClamp = (min: number, max: number) => ChainableUtil;
-type ChainedRound = (decimalLength: number) => ChainableUtil;
-type ChainedSnap = (increment: number) => ChainableUtil;
-type ChainedWrap = (min: number, max: number) => ChainableUtil;
-type ChainedInterpolate = (start: number, end: number) => ChainableUtil;
-type ChainedMapRange = (inLow: number, inHigh: number, outLow: number, outHigh: number) => ChainableUtil;
-type ChainedRoundPad = (decimalLength: number) => ChainableUtil;
-type ChainedPadStart = (totalLength: number, padString: string) => ChainableUtil;
-type ChainedPadEnd = (totalLength: number, padString: string) => ChainableUtil;
-type ChainedDegToRad = () => ChainableUtil;
-type ChainedRadToDeg = () => ChainableUtil;
-declare class Timer extends Clock {
- constructor(parameters?: TimerParams, parent?: Timeline, parentPosition?: number);
- id: string | number;
- parent: Timeline;
- duration: number;
- backwards: boolean;
- paused: boolean;
- began: boolean;
- completed: boolean;
- onBegin: Callback<this>;
- onBeforeUpdate: Callback<this>;
- onUpdate: Callback<this>;
- onLoop: Callback<this>;
- onPause: Callback<this>;
- onComplete: Callback<this>;
- iterationDuration: number;
- iterationCount: number;
- _autoplay: boolean | ScrollObserver;
- _offset: number;
- _delay: number;
- _loopDelay: number;
- _iterationTime: number;
- _currentIteration: number;
- _resolve: Function;
- _running: boolean;
- _reversed: number;
- _reverse: number;
- _cancelled: number;
- _alternate: boolean;
- _prev: Renderable;
- _next: Renderable;
- set cancelled(arg: boolean);
- get cancelled(): boolean;
- set currentTime(arg: number);
- get currentTime(): number;
- set iterationCurrentTime(arg: number);
- get iterationCurrentTime(): number;
- set progress(arg: number);
- get progress(): number;
- set iterationProgress(arg: number);
- get iterationProgress(): number;
- set currentIteration(arg: number);
- get currentIteration(): number;
- set reversed(arg: boolean);
- get reversed(): boolean;
- reset(internalRender?: number): this;
- init(internalRender?: number): this;
- resetTime(): this;
- pause(): this;
- resume(): this;
- restart(): this;
- seek(time: number, muteCallbacks?: boolean | number, internalRender?: boolean | number): this;
- alternate(): this;
- play(): this;
- reverse(): this;
- cancel(): this;
- stretch(newDuration: number): this;
- revert(): this;
- complete(): this;
- then(callback?: Callback<this>): Promise<any>;
-}
-declare function createTimer(parameters?: TimerParams): Timer;
-declare function cleanInlineStyles<T extends Renderable>(renderable: T): T;
-declare class JSAnimation extends Timer {
- constructor(targets: TargetsParam, parameters: AnimationParams, parent?: Timeline, parentPosition?: number, fastSet?: boolean, index?: number, length?: number);
- targets: TargetsArray;
- onRender: Callback<this>;
- _ease: EasingFunction;
- _inlineStyles: {};
- stretch(newDuration: number): this;
- refresh(): this;
- revert(): this;
- then(callback?: Callback<this>): Promise<any>;
-}
-declare function animate(targets: TargetsParam, parameters: AnimationParams): JSAnimation;
-declare function registerTargets(targets: DOMTargetsParam): DOMTargetsArray;
-declare function registerTargets(targets: JSTargetsParam): JSTargetsArray;
-declare function registerTargets(targets: TargetsParam): TargetsArray;
-declare function random(min: number, max: number, decimalLength?: number): number;
-declare function shuffle(items: any[]): any[];
-declare function randomPick(items: string | any[]): any;
-declare namespace svg {
- export { morphTo };
- export { createMotionPath };
- export { createDrawable };
-}
-declare function morphTo(path2: TargetsParam, precision?: number): FunctionValue;
-declare function createMotionPath(path: TargetsParam): {
- translateX: FunctionValue;
- translateY: FunctionValue;
- rotate: FunctionValue;
-};
-declare function createDrawable(selector: TargetsParam, start?: number, end?: number): Array<DrawableSVGGeometry>;
-declare function stagger(val: number | string | [
- number,
- number
-] | [
- string,
- string
-], params?: StaggerParams): StaggerFunction<number | string>;
-declare namespace eases {
- export let linear: (...args: (string | number)[]) => EasingFunction;
- export let irregular: (length?: number, randomness?: number) => EasingFunction;
- export let steps: (steps?: number, fromStart?: boolean) => EasingFunction;
- export let cubicBezier: (mX1?: number, mY1?: number, mX2?: number, mY2?: number) => EasingFunction;
- let _in: PowerEasing;
- export { _in as in };
- export let out: PowerEasing;
- export let inOut: PowerEasing;
- export let outIn: PowerEasing;
- export let inQuad: EasingFunction;
- export let outQuad: EasingFunction;
- export let inOutQuad: EasingFunction;
- export let outInQuad: EasingFunction;
- export let inCubic: EasingFunction;
- export let outCubic: EasingFunction;
- export let inOutCubic: EasingFunction;
- export let outInCubic: EasingFunction;
- export let inQuart: EasingFunction;
- export let outQuart: EasingFunction;
- export let inOutQuart: EasingFunction;
- export let outInQuart: EasingFunction;
- export let inQuint: EasingFunction;
- export let outQuint: EasingFunction;
- export let inOutQuint: EasingFunction;
- export let outInQuint: EasingFunction;
- export let inSine: EasingFunction;
- export let outSine: EasingFunction;
- export let inOutSine: EasingFunction;
- export let outInSine: EasingFunction;
- export let inCirc: EasingFunction;
- export let outCirc: EasingFunction;
- export let inOutCirc: EasingFunction;
- export let outInCirc: EasingFunction;
- export let inExpo: EasingFunction;
- export let outExpo: EasingFunction;
- export let inOutExpo: EasingFunction;
- export let outInExpo: EasingFunction;
- export let inBounce: EasingFunction;
- export let outBounce: EasingFunction;
- export let inOutBounce: EasingFunction;
- export let outInBounce: EasingFunction;
- export let inBack: BackEasing;
- export let outBack: BackEasing;
- export let inOutBack: BackEasing;
- export let outInBack: BackEasing;
- export let inElastic: ElasticEasing;
- export let outElastic: ElasticEasing;
- export let inOutElastic: ElasticEasing;
- export let outInElastic: ElasticEasing;
-}
-type PowerEasing = (power?: number | string) => EasingFunction;
-type BackEasing = (overshoot?: number | string) => EasingFunction;
-type ElasticEasing = (amplitude?: number | string, period?: number | string) => EasingFunction;
-type DefaultsParams = {
- id?: number | string;
- keyframes?: PercentageKeyframes | DurationKeyframes;
- playbackEase?: EasingParam;
- playbackRate?: number;
- frameRate?: number;
- loop?: number | boolean;
- reversed?: boolean;
- alternate?: boolean;
- autoplay?: boolean | ScrollObserver;
- duration?: number | FunctionValue;
- delay?: number | FunctionValue;
- loopDelay?: number;
- ease?: EasingParam;
- composition?: 'none' | 'replace' | 'blend' | compositionTypes;
- modifier?: (v: any) => any;
- onBegin?: (tickable: Tickable) => void;
- onBeforeUpdate?: (tickable: Tickable) => void;
- onUpdate?: (tickable: Tickable) => void;
- onLoop?: (tickable: Tickable) => void;
- onPause?: (tickable: Tickable) => void;
- onComplete?: (tickable: Tickable) => void;
- onRender?: (renderable: Renderable) => void;
-};
-type Renderable = JSAnimation | Timeline;
-type Tickable = Timer | Renderable;
-type CallbackArgument = Timer & JSAnimation & Timeline;
-declare class Animatable {
- constructor(targets: TargetsParam, parameters: AnimatableParams);
- targets: (HTMLElement | SVGElement | JSTarget)[];
- animations: {};
- callbacks: JSAnimation | null;
- revert(): this;
-}
-declare function createAnimatable(targets: TargetsParam, parameters: AnimatableParams): AnimatableObject;
-type Revertible = Animatable | Tickable | WAAPIAnimation | Draggable | ScrollObserver | TextSplitter | Scope;
-type StaggerFunction<T> = (target?: Target, index?: number, length?: number, tl?: Timeline) => T;
-type StaggerParams = {
- start?: number | string;
- from?: number | 'first' | 'center' | 'last' | 'random';
- reversed?: boolean;
- grid?: Array<number>;
- axis?: ('x' | 'y');
- use?: string | ((target: Target, i: number, length: number) => number);
- total?: number;
- ease?: EasingParam;
- modifier?: TweenModifier;
-};
-type EasingFunction = (time: number) => number;
-type EaseStringParamNames = ('linear' | 'linear(x1, x2 25%, x3)' | 'in' | 'out' | 'inOut' | 'inQuad' | 'outQuad' | 'inOutQuad' | 'inCubic' | 'outCubic' | 'inOutCubic' | 'inQuart' | 'outQuart' | 'inOutQuart' | 'inQuint' | 'outQuint' | 'inOutQuint' | 'inSine' | 'outSine' | 'inOutSine' | 'inCirc' | 'outCirc' | 'inOutCirc' | 'inExpo' | 'outExpo' | 'inOutExpo' | 'inBounce' | 'outBounce' | 'inOutBounce' | 'inBack' | 'outBack' | 'inOutBack' | 'inElastic' | 'outElastic' | 'inOutElastic' | 'irregular' | 'cubicBezier' | 'steps' | 'in(p = 1.675)' | 'out(p = 1.675)' | 'inOut(p = 1.675)' | 'inBack(overshoot = 1.70158)' | 'outBack(overshoot = 1.70158)' | 'inOutBack(overshoot = 1.70158)' | 'inElastic(amplitude = 1, period = .3)' | 'outElastic(amplitude = 1, period = .3)' | 'inOutElastic(amplitude = 1, period = .3)' | 'irregular(length = 10, randomness = 1)' | 'cubicBezier(x1, y1, x2, y2)' | 'steps(steps = 10)');
-type EasingParam = (string & {}) | EaseStringParamNames | EasingFunction | Spring;
-type DOMTarget = HTMLElement | SVGElement;
-type JSTarget = Record<string, any>;
-type Target = DOMTarget | JSTarget;
-type TargetSelector = Target | NodeList | string;
-type DOMTargetSelector = DOMTarget | NodeList | string;
-type DOMTargetsParam = Array<DOMTargetSelector> | DOMTargetSelector;
-type DOMTargetsArray = Array<DOMTarget>;
-type JSTargetsParam = Array<JSTarget> | JSTarget;
-type JSTargetsArray = Array<JSTarget>;
-type TargetsParam = Array<TargetSelector> | TargetSelector;
-type TargetsArray = Array<Target>;
-type SpringParams = {
- /**
- * - Mass, default 1
- */
- mass?: number;
- /**
- * - Stiffness, default 100
- */
- stiffness?: number;
- /**
- * - Damping, default 10
- */
- damping?: number;
- /**
- * - Initial velocity, default 0
- */
- velocity?: number;
-};
-type Callback<T> = (self: T, e?: PointerEvent) => any;
-type TickableCallbacks<T extends unknown> = {
- onBegin?: Callback<T>;
- onBeforeUpdate?: Callback<T>;
- onUpdate?: Callback<T>;
- onLoop?: Callback<T>;
- onPause?: Callback<T>;
- onComplete?: Callback<T>;
-};
-type RenderableCallbacks<T extends unknown> = {
- onRender?: Callback<T>;
-};
-type TimerOptions = {
- id?: number | string;
- duration?: TweenParamValue;
- delay?: TweenParamValue;
- loopDelay?: number;
- reversed?: boolean;
- alternate?: boolean;
- loop?: boolean | number;
- autoplay?: boolean | ScrollObserver;
- frameRate?: number;
- playbackRate?: number;
-};
-/**
- *
- * /**
- */
-type TimerParams = TimerOptions & TickableCallbacks<Timer>;
-type FunctionValue = (target: Target, index: number, length: number) => number | string | TweenObjectValue | Array<number | string | TweenObjectValue>;
-type TweenModifier = (value: number) => number | string;
-type ColorArray = [number, number, number, number];
-type Tween = {
- id: number;
- parent: JSAnimation;
- property: string;
- target: Target;
- _value: string | number;
- _func: Function | null;
- _ease: EasingFunction;
- _fromNumbers: Array<number>;
- _toNumbers: Array<number>;
- _strings: Array<string>;
- _fromNumber: number;
- _toNumber: number;
- _numbers: Array<number>;
- _number: number;
- _unit: string;
- _modifier: TweenModifier;
- _currentTime: number;
- _delay: number;
- _updateDuration: number;
- _startTime: number;
- _changeDuration: number;
- _absoluteStartTime: number;
- _tweenType: tweenTypes;
- _valueType: valueTypes;
- _composition: number;
- _isOverlapped: number;
- _isOverridden: number;
- _renderTransforms: number;
- _prevRep: Tween;
- _nextRep: Tween;
- _prevAdd: Tween;
- _nextAdd: Tween;
- _prev: Tween;
- _next: Tween;
-};
-type TweenDecomposedValue = {
- /**
- * - Type
- */
- t: number;
- /**
- * - Single number value
- */
- n: number;
- /**
- * - Value unit
- */
- u: string;
- /**
- * - Value operator
- */
- o: string;
- /**
- * - Array of Numbers (in case of complex value type)
- */
- d: Array<number>;
- /**
- * - Strings (in case of complex value type)
- */
- s: Array<string>;
-};
-type TweenPropertySiblings = {
- _head: null | Tween;
- _tail: null | Tween;
-};
-type TweenLookups = Record<string, TweenPropertySiblings>;
-type TweenReplaceLookups = WeakMap<Target, TweenLookups>;
-type TweenAdditiveLookups = Map<Target, TweenLookups>;
-type TweenParamValue = number | string | FunctionValue;
-type TweenPropValue = TweenParamValue | [TweenParamValue, TweenParamValue];
-type TweenComposition = (string & {}) | 'none' | 'replace' | 'blend' | compositionTypes;
-type TweenParamsOptions = {
- duration?: TweenParamValue;
- delay?: TweenParamValue;
- ease?: EasingParam;
- modifier?: TweenModifier;
- composition?: TweenComposition;
-};
-type TweenValues = {
- from?: TweenParamValue;
- to?: TweenPropValue;
- fromTo?: TweenPropValue;
-};
-type TweenKeyValue = TweenParamsOptions & TweenValues;
-type ArraySyntaxValue = Array<TweenKeyValue | TweenPropValue>;
-type TweenOptions = TweenParamValue | (TweenPropValue | TweenKeyValue)[] | TweenKeyValue;
-type TweenObjectValue = Partial<{
- to: TweenParamValue | Array<TweenParamValue>;
- from: TweenParamValue | Array<TweenParamValue>;
- fromTo: TweenParamValue | Array<TweenParamValue>;
-}>;
-type PercentageKeyframeOptions = {
- ease?: EasingParam;
-};
-type PercentageKeyframeParams = Record<string, TweenParamValue>;
-type PercentageKeyframes = Record<string, PercentageKeyframeParams & PercentageKeyframeOptions>;
-type DurationKeyframes = Array<Record<string, TweenOptions | TweenModifier | boolean> & TweenParamsOptions>;
-type AnimationOptions = {
- keyframes?: PercentageKeyframes | DurationKeyframes;
- playbackEase?: EasingParam;
-};
-type AnimationParams = Record<string, TweenOptions | Callback<JSAnimation> | TweenModifier | boolean | PercentageKeyframes | (Record<string, boolean | TweenModifier | TweenOptions> & TweenParamsOptions)[] | ScrollObserver> & TimerOptions & AnimationOptions & TweenParamsOptions & TickableCallbacks<JSAnimation> & RenderableCallbacks<JSAnimation>;
-/**
- * Accepts:<br>
- * - `Number` - Absolute position in milliseconds (e.g., `500` places element at exactly 500ms)<br>
- * - `'+=Number'` - Addition: Position element X ms after the last element (e.g., `'+=100'`)<br>
- * - `'-=Number'` - Subtraction: Position element X ms before the last element's end (e.g., `'-=100'`)<br>
- * - `'*=Number'` - Multiplier: Position element at a fraction of the total duration (e.g., `'*=.5'` for halfway)<br>
- * - `'<'` - Previous end: Position element at the end position of the previous element<br>
- * - `'<<'` - Previous start: Position element at the start position of the previous element<br>
- * - `'<<+=Number'` - Combined: Position element relative to previous element's start (e.g., `'<<+=250'`)<br>
- * - `'label'` - Label: Position element at a named label position (e.g., `'My Label'`)
- */
-type TimelinePosition = number | `+=${number}` | `-=${number}` | `*=${number}` | '<' | '<<' | `<<+=${number}` | `<<-=${number}` | string;
-/**
- * Accepts:<br>
- * - `Number` - Absolute position in milliseconds (e.g., `500` places animation at exactly 500ms)<br>
- * - `'+=Number'` - Addition: Position animation X ms after the last animation (e.g., `'+=100'`)<br>
- * - `'-=Number'` - Subtraction: Position animation X ms before the last animation's end (e.g., `'-=100'`)<br>
- * - `'*=Number'` - Multiplier: Position animation at a fraction of the total duration (e.g., `'*=.5'` for halfway)<br>
- * - `'<'` - Previous end: Position animation at the end position of the previous animation<br>
- * - `'<<'` - Previous start: Position animation at the start position of the previous animation<br>
- * - `'<<+=Number'` - Combined: Position animation relative to previous animation's start (e.g., `'<<+=250'`)<br>
- * - `'label'` - Label: Position animation at a named label position (e.g., `'My Label'`)<br>
- * - `stagger(String|Nummber)` - Stagger multi-elements animation positions (e.g., 10, 20, 30...)
- */
-type TimelineAnimationPosition = TimelinePosition | StaggerFunction<number | string>;
-type TimelineOptions = {
- defaults?: DefaultsParams;
- playbackEase?: EasingParam;
-};
-type TimelineParams = TimerOptions & TimelineOptions & TickableCallbacks<Timeline> & RenderableCallbacks<Timeline>;
-type WAAPITweenValue = string | number | Array<string> | Array<number>;
-type WAAPIFunctionValue = (target: DOMTarget, index: number, length: number) => WAAPITweenValue;
-type WAAPIKeyframeValue = WAAPITweenValue | WAAPIFunctionValue | Array<string | number | WAAPIFunctionValue>;
-type WAAPICallback = (animation: WAAPIAnimation) => void;
-type WAAPITweenOptions = {
- to?: WAAPIKeyframeValue;
- from?: WAAPIKeyframeValue;
- duration?: number | WAAPIFunctionValue;
- delay?: number | WAAPIFunctionValue;
- ease?: EasingParam;
- composition?: CompositeOperation;
-};
-type WAAPIAnimationOptions = {
- loop?: number | boolean;
- Reversed?: boolean;
- Alternate?: boolean;
- autoplay?: boolean | ScrollObserver;
- playbackRate?: number;
- duration?: number | WAAPIFunctionValue;
- delay?: number | WAAPIFunctionValue;
- ease?: EasingParam;
- composition?: CompositeOperation;
- onComplete?: WAAPICallback;
-};
-type WAAPIAnimationParams = Record<string, WAAPIKeyframeValue | WAAPIAnimationOptions | boolean | ScrollObserver | WAAPICallback | EasingParam | WAAPITweenOptions> & WAAPIAnimationOptions;
-type AnimatablePropertySetter = (to: number | Array<number>, duration?: number, ease?: EasingParam) => AnimatableObject;
-type AnimatablePropertyGetter = () => number | Array<number>;
-type AnimatableProperty = AnimatablePropertySetter & AnimatablePropertyGetter;
-type AnimatableObject = Animatable & Record<string, AnimatableProperty>;
-type AnimatablePropertyParamsOptions = {
- unit?: string;
- duration?: TweenParamValue;
- ease?: EasingParam;
- modifier?: TweenModifier;
- composition?: TweenComposition;
-};
-type AnimatableParams = Record<string, TweenParamValue | EasingParam | TweenModifier | TweenComposition | AnimatablePropertyParamsOptions> & AnimatablePropertyParamsOptions;
-type ReactRef = {
- current?: HTMLElement | SVGElement | null;
-};
-type AngularRef = {
- nativeElement?: HTMLElement | SVGElement;
-};
-type ScopeParams = {
- root?: DOMTargetSelector | ReactRef | AngularRef;
- defaults?: DefaultsParams;
- mediaQueries?: Record<string, string>;
-};
-type ScopedCallback<T> = (scope: Scope) => T;
-type ScopeCleanupCallback = (scope?: Scope) => any;
-type ScopeConstructorCallback = (scope?: Scope) => ScopeCleanupCallback | void;
-type ScopeMethod = (...args: any[]) => ScopeCleanupCallback | void;
-type ScrollThresholdValue = string | number;
-type ScrollThresholdParam = {
- target?: ScrollThresholdValue;
- container?: ScrollThresholdValue;
-};
-type ScrollObserverAxisCallback = (self: ScrollObserver) => 'x' | 'y';
-type ScrollThresholdCallback = (self: ScrollObserver) => ScrollThresholdValue | ScrollThresholdParam;
-type ScrollObserverParams = {
- id?: number | string;
- sync?: boolean | number | string | EasingParam;
- container?: TargetsParam;
- target?: TargetsParam;
- axis?: "x" | "y" | ScrollObserverAxisCallback | ((observer: ScrollObserver) => 'x' | 'y' | ScrollObserverAxisCallback);
- enter?: ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback | ((observer: ScrollObserver) => ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback);
- leave?: ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback | ((observer: ScrollObserver) => ScrollThresholdValue | ScrollThresholdParam | ScrollThresholdCallback);
- repeat?: boolean | ((observer: ScrollObserver) => boolean);
- debug?: boolean;
- onEnter?: Callback<ScrollObserver>;
- onLeave?: Callback<ScrollObserver>;
- onEnterForward?: Callback<ScrollObserver>;
- onLeaveForward?: Callback<ScrollObserver>;
- onEnterBackward?: Callback<ScrollObserver>;
- onLeaveBackward?: Callback<ScrollObserver>;
- onUpdate?: Callback<ScrollObserver>;
- onSyncComplete?: Callback<ScrollObserver>;
-};
-type DraggableAxisParam = {
- mapTo?: string;
- modifier?: TweenModifier;
- composition?: TweenComposition;
- snap?: number | number[] | ((draggable: Draggable) => number | Array<number>);
-};
-type DraggableCursorParams = {
- onHover?: string;
- onGrab?: string;
-};
-type DraggableParams = {
- trigger?: DOMTargetSelector;
- container?: number[] | DOMTargetSelector | ((draggable: Draggable) => DOMTargetSelector | Array<number>);
- x?: boolean | DraggableAxisParam;
- y?: boolean | DraggableAxisParam;
- modifier?: TweenModifier;
- snap?: number | number[] | ((draggable: Draggable) => number | Array<number>);
- containerPadding?: number | number[] | ((draggable: Draggable) => number | Array<number>);
- containerFriction?: number | ((draggable: Draggable) => number);
- releaseContainerFriction?: number | ((draggable: Draggable) => number);
- dragSpeed?: number | ((draggable: Draggable) => number);
- scrollSpeed?: number | ((draggable: Draggable) => number);
- scrollThreshold?: number | ((draggable: Draggable) => number);
- minVelocity?: number | ((draggable: Draggable) => number);
- maxVelocity?: number | ((draggable: Draggable) => number);
- velocityMultiplier?: number | ((draggable: Draggable) => number);
- releaseMass?: number;
- releaseStiffness?: number;
- releaseDamping?: number;
- releaseEase?: EasingParam;
- cursor?: boolean | DraggableCursorParams | ((draggable: Draggable) => boolean | DraggableCursorParams);
- onGrab?: Callback<Draggable>;
- onDrag?: Callback<Draggable>;
- onRelease?: Callback<Draggable>;
- onUpdate?: Callback<Draggable>;
- onSettle?: Callback<Draggable>;
- onSnap?: Callback<Draggable>;
- onResize?: Callback<Draggable>;
- onAfterResize?: Callback<Draggable>;
-};
-type splitTemplateParams = {
- class?: false | string;
- wrap?: boolean | 'hidden' | 'clip' | 'visible' | 'scroll' | 'auto';
- clone?: boolean | 'top' | 'right' | 'bottom' | 'left' | 'center';
-};
-type SplitValue = boolean | string;
-type SplitFunctionValue = (value?: Node | HTMLElement) => any;
-type TextSplitterParams = {
- lines?: SplitValue | splitTemplateParams | SplitFunctionValue;
- words?: SplitValue | splitTemplateParams | SplitFunctionValue;
- chars?: SplitValue | splitTemplateParams | SplitFunctionValue;
- accessible?: boolean;
- includeSpaces?: boolean;
- debug?: boolean;
-};
-type DrawableSVGGeometry = SVGGeometryElement & {
- setAttribute(name: 'draw', value: `${number} ${number}`): void;
- draw: `${number} ${number}`;
-};
-declare class Timeline extends Timer {
- constructor(parameters?: TimelineParams);
- labels: Record<string, number>;
- defaults: DefaultsParams;
- onRender: Callback<this>;
- _ease: EasingFunction;
- add(a1: TargetsParam, a2: AnimationParams, a3?: TimelinePosition | StaggerFunction<number | string>): this;
- add(a1: TimerParams, a2?: TimelinePosition): this;
- sync(synced?: Tickable, position?: TimelinePosition): this;
- sync(synced?: globalThis.Animation, position?: TimelinePosition): this;
- sync(synced?: WAAPIAnimation, position?: TimelinePosition): this;
- set(targets: TargetsParam, parameters: AnimationParams, position?: TimelinePosition): this;
- call(callback: Callback<Timer>, position?: TimelinePosition): this;
- label(labelName: string, position?: TimelinePosition): this;
- remove(targets: TargetsParam, propertyName?: string): this;
- stretch(newDuration: number): this;
- refresh(): this;
- revert(): this;
- then(callback?: Callback<this>): Promise<any>;
-}
-declare function createTimeline(parameters?: TimelineParams): Timeline;
-declare class Draggable {
- constructor(target: TargetsParam, parameters?: DraggableParams);
- containerArray: number[];
- $container: HTMLElement;
- useWin: boolean;
- $scrollContainer: Window | HTMLElement;
- $target: HTMLElement;
- $trigger: HTMLElement;
- fixed: boolean;
- isFinePointer: boolean;
- containerPadding: [
- number,
- number,
- number,
- number
- ];
- containerFriction: number;
- releaseContainerFriction: number;
- snapX: number | Array<number>;
- snapY: number | Array<number>;
- scrollSpeed: number;
- scrollThreshold: number;
- dragSpeed: number;
- maxVelocity: number;
- minVelocity: number;
- velocityMultiplier: number;
- cursor: boolean | DraggableCursorParams;
- releaseXSpring: Spring;
- releaseYSpring: Spring;
- releaseEase: EasingFunction;
- hasReleaseSpring: boolean;
- onGrab: Callback<this>;
- onDrag: Callback<this>;
- onRelease: Callback<this>;
- onUpdate: Callback<this>;
- onSettle: Callback<this>;
- onSnap: Callback<this>;
- onResize: Callback<this>;
- onAfterResize: Callback<this>;
- disabled: [
- number,
- number
- ];
- animate: AnimatableObject;
- xProp: string;
- yProp: string;
- destX: number;
- destY: number;
- deltaX: number;
- deltaY: number;
- scroll: {
- x: number;
- y: number;
- };
- coords: [
- number,
- number,
- number,
- number
- ];
- snapped: [
- number,
- number
- ];
- pointer: [
- number,
- number,
- number,
- number,
- number,
- number,
- number,
- number
- ];
- scrollView: [
- number,
- number
- ];
- dragArea: [
- number,
- number,
- number,
- number
- ];
- containerBounds: [
- number,
- number,
- number,
- number
- ];
- scrollBounds: [
- number,
- number,
- number,
- number
- ];
- targetBounds: [
- number,
- number,
- number,
- number
- ];
- window: [
- number,
- number
- ];
- velocityStack: [
- number,
- number,
- number
- ];
- velocityStackIndex: number;
- velocityTime: number;
- velocity: number;
- angle: number;
- cursorStyles: JSAnimation;
- triggerStyles: JSAnimation;
- bodyStyles: JSAnimation;
- targetStyles: JSAnimation;
- touchActionStyles: JSAnimation;
- transforms: Transforms;
- overshootCoords: {
- x: number;
- y: number;
- };
- overshootTicker: Timer;
- updated: boolean;
- manual: boolean;
- updateTicker: Timer;
- contained: boolean;
- grabbed: boolean;
- dragged: boolean;
- released: boolean;
- canScroll: boolean;
- enabled: boolean;
- initialized: boolean;
- activeProp: string;
- resizeTicker: Timer;
- parameters: DraggableParams;
- resizeObserver: ResizeObserver;
- computeVelocity(dx: number, dy: number): number;
- setX(x: number, muteUpdateCallback?: boolean): this;
- setY(y: number, muteUpdateCallback?: boolean): this;
- set x(arg: number);
- get x(): number;
- set y(arg: number);
- get y(): number;
- set progressX(arg: number);
- get progressX(): number;
- set progressY(arg: number);
- get progressY(): number;
- updateScrollCoords(): void;
- updateBoundingValues(): void;
- isOutOfBounds(bounds: any[], x: number, y: number): number;
- refresh(): void;
- update(): void;
- stop(): this;
- scrollInView(duration?: number, gap?: number, ease?: EasingParam): this;
- handleHover(): void;
- animateInView(duration?: number, gap?: number, ease?: EasingParam): this;
- handleDown(e: MouseEvent | TouchEvent): void;
- handleMove(e: MouseEvent | TouchEvent): void;
- handleUp(): void;
- reset(): this;
- enable(): this;
- disable(): this;
- revert(): this;
- handleEvent(e: Event): void;
-}
-declare function createDraggable(target: TargetsParam, parameters?: DraggableParams): Draggable;
-declare class Transforms {
- constructor($el: DOMTarget | DOMProxy);
- $el: DOMTarget | DOMProxy;
- inlineTransforms: any[];
- point: DOMPoint;
- inversedMatrix: DOMMatrix;
- normalizePoint(x: number, y: number): DOMPoint;
- traverseUp(cb: ($el: DOMTarget, i: number) => any): void;
- getMatrix(): DOMMatrix;
- remove(): void;
- revert(): void;
-}
-declare class DOMProxy {
- constructor(el: any);
- el: any;
- zIndex: number;
- parentElement: any;
- classList: {
- add: () => void;
- remove: () => void;
- };
- set x(arg: any);
- get x(): any;
- set y(arg: any);
- get y(): any;
- set width(arg: any);
- get width(): any;
- set height(arg: any);
- get height(): any;
- getBoundingClientRect(): {
- top: any;
- right: any;
- bottom: any;
- left: any;
- };
-}
-declare class Scope {
- constructor(parameters?: ScopeParams);
- defaults: DefaultsParams;
- root: Document | DOMTarget;
- constructors: Array<ScopeConstructorCallback>;
- revertConstructors: Array<ScopeCleanupCallback>;
- revertibles: Array<Revertible>;
- constructorsOnce: (ScopeConstructorCallback | ((scope: this) => Tickable))[];
- revertConstructorsOnce: Array<ScopeCleanupCallback>;
- revertiblesOnce: Array<Revertible>;
- once: boolean;
- onceIndex: number;
- methods: Record<string, ScopeMethod>;
- matches: Record<string, boolean>;
- mediaQueryLists: Record<string, MediaQueryList>;
- data: Record<string, any>;
- register(revertible: Revertible): void;
- execute<T>(cb: ScopedCallback<T>): T;
- refresh(): this;
- add(a1: string, a2: ScopeMethod): this;
- add(a1: ScopeConstructorCallback): this;
- addOnce(scopeConstructorCallback: ScopeConstructorCallback): this;
- keepTime(cb: (scope: this) => Tickable): Tickable;
- handleEvent(e: Event): void;
- revert(): void;
-}
-declare function createScope(params?: ScopeParams): Scope;
-declare const scrollContainers: Map<any, any>;
-declare class ScrollObserver {
- constructor(parameters?: ScrollObserverParams);
- index: number;
- id: string | number;
- container: ScrollContainer;
- target: HTMLElement;
- linked: Tickable | WAAPIAnimation;
- repeat: boolean;
- horizontal: boolean;
- enter: ScrollThresholdParam | ScrollThresholdValue | ScrollThresholdCallback;
- leave: ScrollThresholdParam | ScrollThresholdValue | ScrollThresholdCallback;
- sync: boolean;
- syncEase: EasingFunction;
- syncSmooth: number;
- onSyncEnter: Callback<ScrollObserver>;
- onSyncLeave: Callback<ScrollObserver>;
- onSyncEnterForward: Callback<ScrollObserver>;
- onSyncLeaveForward: Callback<ScrollObserver>;
- onSyncEnterBackward: Callback<ScrollObserver>;
- onSyncLeaveBackward: Callback<ScrollObserver>;
- onEnter: Callback<ScrollObserver>;
- onLeave: Callback<ScrollObserver>;
- onEnterForward: Callback<ScrollObserver>;
- onLeaveForward: Callback<ScrollObserver>;
- onEnterBackward: Callback<ScrollObserver>;
- onLeaveBackward: Callback<ScrollObserver>;
- onUpdate: Callback<ScrollObserver>;
- onSyncComplete: Callback<ScrollObserver>;
- reverted: boolean;
- completed: boolean;
- began: boolean;
- isInView: boolean;
- forceEnter: boolean;
- hasEntered: boolean;
- offset: number;
- offsetStart: number;
- offsetEnd: number;
- distance: number;
- prevProgress: number;
- thresholds: any[];
- coords: [
- number,
- number,
- number,
- number
- ];
- debugStyles: JSAnimation;
- $debug: HTMLElement;
- _params: ScrollObserverParams;
- _debug: boolean;
- _next: ScrollObserver;
- _prev: ScrollObserver;
- link(linked: Tickable | WAAPIAnimation): this;
- get velocity(): number;
- get backward(): boolean;
- get scroll(): number;
- get progress(): number;
- refresh(): this;
- removeDebug(): this;
- debug(): void;
- updateBounds(): void;
- handleScroll(): void;
- revert(): this;
-}
-declare function onScroll(parameters?: ScrollObserverParams): ScrollObserver;
-declare class ScrollContainer {
- constructor($el: HTMLElement);
- element: HTMLElement;
- useWin: boolean;
- winWidth: number;
- winHeight: number;
- width: number;
- height: number;
- left: number;
- top: number;
- zIndex: number;
- scrollX: number;
- scrollY: number;
- prevScrollX: number;
- prevScrollY: number;
- scrollWidth: number;
- scrollHeight: number;
- velocity: number;
- backwardX: boolean;
- backwardY: boolean;
- scrollTicker: Timer;
- dataTimer: Timer;
- resizeTicker: Timer;
- wakeTicker: Timer;
- _head: ScrollObserver;
- _tail: ScrollObserver;
- resizeObserver: ResizeObserver;
- updateScrollCoords(): void;
- updateWindowBounds(): void;
- updateBounds(): void;
- refreshScrollObservers(): void;
- refresh(): void;
- handleScroll(): void;
- handleEvent(e: Event): void;
- revert(): void;
-}
-declare class Spring {
- constructor(parameters?: SpringParams);
- timeStep: number;
- restThreshold: number;
- restDuration: number;
- maxDuration: number;
- maxRestSteps: number;
- maxIterations: number;
- m: number;
- s: number;
- d: number;
- v: number;
- w0: number;
- zeta: number;
- wd: number;
- b: number;
- solverDuration: number;
- duration: number;
- ease: EasingFunction;
- solve(time: number): number;
- compute(): void;
- set mass(arg: number);
- get mass(): number;
- set stiffness(arg: number);
- get stiffness(): number;
- set damping(arg: number);
- get damping(): number;
- set velocity(arg: number);
- get velocity(): number;
-}
-declare function createSpring(parameters?: SpringParams): Spring;
-type SpringParams = {
- mass?: number;
- stiffness?: number;
- damping?: number;
- velocity?: number;
-};
-declare class WAAPIAnimation {
- constructor(targets: DOMTargetsParam, params: WAAPIAnimationParams);
- targets: DOMTargetsArray;
- animations: Array<globalThis.Animation>;
- controlAnimation: globalThis.Animation;
- onComplete: Callback<this>;
- duration: number;
- muteCallbacks: boolean;
- completed: boolean;
- paused: boolean;
- reversed: boolean;
- autoplay: boolean | ScrollObserver;
- _speed: number;
- _resolve: Function;
- _completed: number;
- _inlineStyles: Array<any>;
- forEach(callback: string | ((animation: globalThis.Animation) => any)): this;
- set speed(arg: number);
- get speed(): number;
- set currentTime(arg: number);
- get currentTime(): number;
- set progress(arg: number);
- get progress(): number;
- resume(): this;
- pause(): this;
- alternate(): this;
- play(): this;
- reverse(): this;
- seek(time: number, muteCallbacks?: boolean): this;
- restart(): this;
- commitStyles(): this;
- complete(): this;
- cancel(): this;
- revert(): this;
- then(callback?: WAAPICallback): Promise<any>;
-}
-declare namespace waapi {
- export function animate(targets: DOMTargetsParam, params: WAAPIAnimationParams): WAAPIAnimation;
- export { easingToLinear as convertEase };
-}
-declare function easingToLinear(fn: EasingFunction, samples?: number): string;
-declare class TextSplitter {
- constructor(target: HTMLElement | NodeList | string | Array<HTMLElement>, parameters?: TextSplitterParams);
- debug: boolean;
- includeSpaces: boolean;
- accessible: boolean;
- linesOnly: boolean;
- lineTemplate: string | false | SplitFunctionValue;
- wordTemplate: string | false | SplitFunctionValue;
- charTemplate: string | false | SplitFunctionValue;
- $target: HTMLElement;
- html: string;
- lines: any[];
- words: any[];
- chars: any[];
- effects: any[];
- effectsCleanups: any[];
- cache: string;
- ready: boolean;
- width: number;
- resizeTimeout: NodeJS.Timeout;
- resizeObserver: ResizeObserver;
- addEffect(effect: (...args: any[]) => Tickable | (() => void)): void | this;
- revert(): this;
- splitNode(node: Node): void;
- split(clearCache?: boolean): this;
- refresh(): void;
-}
-declare function split(target: HTMLElement | NodeList | string | Array<HTMLElement>, parameters?: TextSplitterParams): TextSplitter;
-declare namespace text {
- export { split };
-}
-export { engine, utils, svg, stagger, eases, DefaultsParams, Renderable, Tickable, CallbackArgument, Revertible, StaggerFunction, StaggerParams, EasingFunction, EaseStringParamNames, EasingParam, DOMTarget, JSTarget, Target, TargetSelector, DOMTargetSelector, DOMTargetsParam, DOMTargetsArray, JSTargetsParam, JSTargetsArray, TargetsParam, TargetsArray, SpringParams, Callback, TickableCallbacks, RenderableCallbacks, TimerOptions, TimerParams, FunctionValue, TweenModifier, ColorArray, Tween, TweenDecomposedValue, TweenPropertySiblings, TweenLookups, TweenReplaceLookups, TweenAdditiveLookups, TweenParamValue, TweenPropValue, TweenComposition, TweenParamsOptions, TweenValues, TweenKeyValue, ArraySyntaxValue, TweenOptions, TweenObjectValue, PercentageKeyframeOptions, PercentageKeyframeParams, PercentageKeyframes, DurationKeyframes, AnimationOptions, AnimationParams, TimelinePosition, TimelineAnimationPosition, TimelineOptions, TimelineParams, WAAPITweenValue, WAAPIFunctionValue, WAAPIKeyframeValue, WAAPICallback, WAAPITweenOptions, WAAPIAnimationOptions, WAAPIAnimationParams, AnimatablePropertySetter, AnimatablePropertyGetter, AnimatableProperty, AnimatableObject, AnimatablePropertyParamsOptions, AnimatableParams, ReactRef, AngularRef, ScopeParams, ScopedCallback, ScopeCleanupCallback, ScopeConstructorCallback, ScopeMethod, ScrollThresholdValue, ScrollThresholdParam, ScrollObserverAxisCallback, ScrollThresholdCallback, ScrollObserverParams, DraggableAxisParam, DraggableCursorParams, DraggableParams, splitTemplateParams, SplitValue, SplitFunctionValue, TextSplitterParams, DrawableSVGGeometry, createTimer, Timer, animate, JSAnimation, createTimeline, Timeline, createAnimatable, Animatable, createDraggable, Draggable, createScope, Scope, onScroll, ScrollObserver, scrollContainers, createSpring, Spring, waapi, WAAPIAnimation, text, TextSplitter };
diff --git a/types/index.js b/types/index.js
deleted file mode 100644
index c3b9dfba..00000000
--- a/types/index.js
+++ /dev/null
@@ -1,7388 +0,0 @@
-/**
- * anime.js - ESM
- * @version v4.1.3
- * @author Julian Garnier
- * @license MIT
- * @copyright (c) 2025 Julian Garnier
- * @see https://animejs.com
- */
-
-// Environments
-// TODO: Do we need to check if we're running inside a worker ?
-const isBrowser = typeof window !== 'undefined';
-/** @type {Window & {AnimeJS: Array}|null} */
-const win = isBrowser ? /** @type {Window & {AnimeJS: Array}} */ ( /** @type {unknown} */(window)) : null;
-/** @type {Document|null} */
-const doc = isBrowser ? document : null;
-// Enums
-/** @enum {Number} */
-const tweenTypes = {
- OBJECT: 0,
- ATTRIBUTE: 1,
- CSS: 2,
- TRANSFORM: 3,
- CSS_VAR: 4,
-};
-/** @enum {Number} */
-const valueTypes = {
- NUMBER: 0,
- UNIT: 1,
- COLOR: 2,
- COMPLEX: 3,
-};
-/** @enum {Number} */
-const tickModes = {
- NONE: 0,
- AUTO: 1,
- FORCE: 2,
-};
-/** @enum {Number} */
-const compositionTypes = {
- replace: 0,
- none: 1,
- blend: 2,
-};
-// Cache symbols
-const isRegisteredTargetSymbol = Symbol();
-const isDomSymbol = Symbol();
-const isSvgSymbol = Symbol();
-const transformsSymbol = Symbol();
-const morphPointsSymbol = Symbol();
-const proxyTargetSymbol = Symbol();
-// Numbers
-const minValue = 1e-11;
-const maxValue = 1e12;
-const K = 1e3;
-const maxFps = 120;
-// Strings
-const emptyString = '';
-const shortTransforms = /*#__PURE__*/ (() => {
- const map = new Map();
- map.set('x', 'translateX');
- map.set('y', 'translateY');
- map.set('z', 'translateZ');
- return map;
-})();
-const validTransforms = [
- 'translateX',
- 'translateY',
- 'translateZ',
- 'rotate',
- 'rotateX',
- 'rotateY',
- 'rotateZ',
- 'scale',
- 'scaleX',
- 'scaleY',
- 'scaleZ',
- 'skew',
- 'skewX',
- 'skewY',
- 'perspective',
- 'matrix',
- 'matrix3d',
-];
-const transformsFragmentStrings = /*#__PURE__*/ validTransforms.reduce((a, v) => ({ ...a, [v]: v + '(' }), {});
-// Functions
-/** @return {void} */
-const noop = () => { };
-// Regex
-const hexTestRgx = /(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i;
-const rgbExecRgx = /rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i;
-const rgbaExecRgx = /rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i;
-const hslExecRgx = /hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i;
-const hslaExecRgx = /hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i;
-// export const digitWithExponentRgx = /[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g;
-const digitWithExponentRgx = /[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi;
-// export const unitsExecRgx = /^([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)+([a-z]+|%)$/i;
-const unitsExecRgx = /^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i;
-const lowerCaseRgx = /([a-z])([A-Z])/g;
-const transformsExecRgx = /(\w+)(\([^)]+\)+)/g; // Match inline transforms with cacl() values, returns the value wrapped in ()
-const relativeValuesExecRgx = /(\*=|\+=|-=)/;
-
-
-/** @type {DefaultsParams} */
-const defaults = {
- id: null,
- keyframes: null,
- playbackEase: null,
- playbackRate: 1,
- frameRate: maxFps,
- loop: 0,
- reversed: false,
- alternate: false,
- autoplay: true,
- duration: K,
- delay: 0,
- loopDelay: 0,
- ease: 'out(2)',
- composition: compositionTypes.replace,
- modifier: v => v,
- onBegin: noop,
- onBeforeUpdate: noop,
- onUpdate: noop,
- onLoop: noop,
- onPause: noop,
- onComplete: noop,
- onRender: noop,
-};
-const scope = {
- /** @type {Scope} */
- current: null,
- /** @type {Document|DOMTarget} */
- root: doc,
-};
-const globals = {
- /** @type {DefaultsParams} */
- defaults,
- /** @type {Number} */
- precision: 4,
- /** @type {Number} equals 1 in ms mode, 0.001 in s mode */
- timeScale: 1,
- /** @type {Number} */
- tickThreshold: 200,
-};
-const globalVersions = { version: '4.1.3', engine: null };
-if (isBrowser) {
- if (!win.AnimeJS)
- win.AnimeJS = [];
- win.AnimeJS.push(globalVersions);
-}
-
-// Strings
-/**
- * @param {String} str
- * @return {String}
- */
-const toLowerCase = str => str.replace(lowerCaseRgx, '$1-$2').toLowerCase();
-/**
- * Prioritize this method instead of regex when possible
- * @param {String} str
- * @param {String} sub
- * @return {Boolean}
- */
-const stringStartsWith = (str, sub) => str.indexOf(sub) === 0;
-// Note: Date.now is used instead of performance.now since it is precise enough for timings calculations, performs slightly faster and works in Node.js environement.
-const now = Date.now;
-// Types checkers
-const isArr = Array.isArray;
-/**@param {any} a @return {a is Record<String, any>} */
-const isObj = a => a && a.constructor === Object;
-/**@param {any} a @return {a is Number} */
-const isNum = a => typeof a === 'number' && !isNaN(a);
-/**@param {any} a @return {a is String} */
-const isStr = a => typeof a === 'string';
-/**@param {any} a @return {a is Function} */
-const isFnc = a => typeof a === 'function';
-/**@param {any} a @return {a is undefined} */
-const isUnd = a => typeof a === 'undefined';
-/**@param {any} a @return {a is null | undefined} */
-const isNil = a => isUnd(a) || a === null;
-/**@param {any} a @return {a is SVGElement} */
-const isSvg = a => isBrowser && a instanceof SVGElement;
-/**@param {any} a @return {Boolean} */
-const isHex = a => hexTestRgx.test(a);
-/**@param {any} a @return {Boolean} */
-const isRgb = a => stringStartsWith(a, 'rgb');
-/**@param {any} a @return {Boolean} */
-const isHsl = a => stringStartsWith(a, 'hsl');
-/**@param {any} a @return {Boolean} */
-const isCol = a => isHex(a) || isRgb(a) || isHsl(a);
-/**@param {any} a @return {Boolean} */
-const isKey = a => !globals.defaults.hasOwnProperty(a);
-// Number
-/**
- * @param {Number|String} str
- * @return {Number}
- */
-const parseNumber = str => isStr(str) ?
- parseFloat(/** @type {String} */ (str)) :
- /** @type {Number} */ (str);
-// Math
-const pow = Math.pow;
-const sqrt = Math.sqrt;
-const sin = Math.sin;
-const cos = Math.cos;
-const abs = Math.abs;
-const exp = Math.exp;
-const ceil = Math.ceil;
-const floor = Math.floor;
-const asin = Math.asin;
-const max = Math.max;
-const atan2 = Math.atan2;
-const PI = Math.PI;
-const _round = Math.round;
-/**
- * @param {Number} v
- * @param {Number} min
- * @param {Number} max
- * @return {Number}
- */
-const clamp = (v, min, max) => v < min ? min : v > max ? max : v;
-const powCache = {};
-/**
- * @param {Number} v
- * @param {Number} decimalLength
- * @return {Number}
- */
-const round = (v, decimalLength) => {
- if (decimalLength < 0)
- return v;
- if (!decimalLength)
- return _round(v);
- let p = powCache[decimalLength];
- if (!p)
- p = powCache[decimalLength] = 10 ** decimalLength;
- return _round(v * p) / p;
-};
-/**
- * @param {Number} v
- * @param {Number|Array<Number>} increment
- * @return {Number}
- */
-const snap = (v, increment) => isArr(increment) ? increment.reduce((closest, cv) => (abs(cv - v) < abs(closest - v) ? cv : closest)) : increment ? _round(v / increment) * increment : v;
-/**
- * @param {Number} start
- * @param {Number} end
- * @param {Number} progress
- * @return {Number}
- */
-const interpolate = (start, end, progress) => start + (end - start) * progress;
-/**
- * @param {Number} min
- * @param {Number} max
- * @param {Number} [decimalLength]
- * @return {Number}
- */
-const random = (min, max, decimalLength) => { const m = 10 ** (decimalLength || 0); return floor((Math.random() * (max - min + (1 / m)) + min) * m) / m; };
-/**
- * Adapted from https://bost.ocks.org/mike/shuffle/
- * @param {Array} items
- * @return {Array}
- */
-const shuffle = items => {
- let m = items.length, t, i;
- while (m) {
- i = random(0, --m);
- t = items[m];
- items[m] = items[i];
- items[i] = t;
- }
- return items;
-};
-/**
- * @param {Number} v
- * @return {Number}
- */
-const clampInfinity = v => v === Infinity ? maxValue : v === -Infinity ? -1e12 : v;
-/**
- * @param {Number} v
- * @return {Number}
- */
-const normalizeTime = v => v <= minValue ? minValue : clampInfinity(round(v, 11));
-// Arrays
-/**
- * @template T
- * @param {T[]} a
- * @return {T[]}
- */
-const cloneArray = a => isArr(a) ? [...a] : a;
-// Objects
-/**
- * @template T
- * @template U
- * @param {T} o1
- * @param {U} o2
- * @return {T & U}
- */
-const mergeObjects = (o1, o2) => {
- const merged = /** @type {T & U} */ ({ ...o1 });
- for (let p in o2) {
- const o1p = /** @type {T & U} */ (o1)[p];
- merged[p] = isUnd(o1p) ? /** @type {T & U} */ (o2)[p] : o1p;
- }
- return merged;
-};
-// Linked lists
-/**
- * @param {Object} parent
- * @param {Function} callback
- * @param {Boolean} [reverse]
- * @param {String} [prevProp]
- * @param {String} [nextProp]
- * @return {void}
- */
-const forEachChildren = (parent, callback, reverse, prevProp = '_prev', nextProp = '_next') => {
- let next = parent._head;
- let adjustedNextProp = nextProp;
- if (reverse) {
- next = parent._tail;
- adjustedNextProp = prevProp;
- }
- while (next) {
- const currentNext = next[adjustedNextProp];
- callback(next);
- next = currentNext;
- }
-};
-/**
- * @param {Object} parent
- * @param {Object} child
- * @param {String} [prevProp]
- * @param {String} [nextProp]
- * @return {void}
- */
-const removeChild = (parent, child, prevProp = '_prev', nextProp = '_next') => {
- const prev = child[prevProp];
- const next = child[nextProp];
- prev ? prev[nextProp] = next : parent._head = next;
- next ? next[prevProp] = prev : parent._tail = prev;
- child[prevProp] = null;
- child[nextProp] = null;
-};
-/**
- * @param {Object} parent
- * @param {Object} child
- * @param {Function} [sortMethod]
- * @param {String} prevProp
- * @param {String} nextProp
- * @return {void}
- */
-const addChild = (parent, child, sortMethod, prevProp = '_prev', nextProp = '_next') => {
- let prev = parent._tail;
- while (prev && sortMethod && sortMethod(prev, child))
- prev = prev[prevProp];
- const next = prev ? prev[nextProp] : parent._head;
- prev ? prev[nextProp] = child : parent._head = child;
- next ? next[prevProp] = child : parent._tail = child;
- child[prevProp] = prev;
- child[nextProp] = next;
-};
-/**
- * @param {(...args: any[]) => Tickable | ((...args: any[]) => void)} constructor
- * @return {(...args: any[]) => Tickable | ((...args: any[]) => void)}
- */
-const createRefreshable = constructor => {
- /** @type {Tickable} */
- let tracked;
- return (...args) => {
- let currentIteration, currentIterationProgress, reversed, alternate;
- if (tracked) {
- currentIteration = tracked.currentIteration;
- currentIterationProgress = tracked.iterationProgress;
- reversed = tracked.reversed;
- alternate = tracked._alternate;
- tracked.revert();
- }
- const cleanup = constructor(...args);
- if (cleanup && !isFnc(cleanup) && cleanup.revert)
- tracked = cleanup;
- if (!isUnd(currentIterationProgress)) {
- /** @type {Tickable} */ (tracked).currentIteration = currentIteration;
- /** @type {Tickable} */ (tracked).iterationProgress = (alternate ? !(currentIteration % 2) ? reversed : !reversed : reversed) ? 1 - currentIterationProgress : currentIterationProgress;
- }
- return cleanup || noop;
- };
-};
-
-/*
- * Base class to control framerate and playback rate.
- * Inherited by Engine, Timer, Animation and Timeline.
- */
-class Clock {
- /** @param {Number} [initTime] */
- constructor(initTime = 0) {
- /** @type {Number} */
- this.deltaTime = 0;
- /** @type {Number} */
- this._currentTime = initTime;
- /** @type {Number} */
- this._elapsedTime = initTime;
- /** @type {Number} */
- this._startTime = initTime;
- /** @type {Number} */
- this._lastTime = initTime;
- /** @type {Number} */
- this._scheduledTime = 0;
- /** @type {Number} */
- this._frameDuration = round(K / maxFps, 0);
- /** @type {Number} */
- this._fps = maxFps;
- /** @type {Number} */
- this._speed = 1;
- /** @type {Boolean} */
- this._hasChildren = false;
- /** @type {Tickable|Tween} */
- this._head = null;
- /** @type {Tickable|Tween} */
- this._tail = null;
- }
- get fps() {
- return this._fps;
- }
- set fps(frameRate) {
- const previousFrameDuration = this._frameDuration;
- const fr = +frameRate;
- const fps = fr < minValue ? minValue : fr;
- const frameDuration = round(K / fps, 0);
- this._fps = fps;
- this._frameDuration = frameDuration;
- this._scheduledTime += frameDuration - previousFrameDuration;
- }
- get speed() {
- return this._speed;
- }
- set speed(playbackRate) {
- const pbr = +playbackRate;
- this._speed = pbr < minValue ? minValue : pbr;
- }
- /**
- * @param {Number} time
- * @return {tickModes}
- */
- requestTick(time) {
- const scheduledTime = this._scheduledTime;
- const elapsedTime = this._elapsedTime;
- this._elapsedTime += (time - elapsedTime);
- // If the elapsed time is lower than the scheduled time
- // this means not enough time has passed to hit one frameDuration
- // so skip that frame
- if (elapsedTime < scheduledTime)
- return tickModes.NONE;
- const frameDuration = this._frameDuration;
- const frameDelta = elapsedTime - scheduledTime;
- // Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
- // Skips ahead if the actual elapsed time is higher.
- this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
- return tickModes.AUTO;
- }
- /**
- * @param {Number} time
- * @return {Number}
- */
- computeDeltaTime(time) {
- const delta = time - this._lastTime;
- this.deltaTime = delta;
- this._lastTime = time;
- return delta;
- }
-}
-
-
-/**
- * @param {Tickable} tickable
- * @param {Number} time
- * @param {Number} muteCallbacks
- * @param {Number} internalRender
- * @param {tickModes} tickMode
- * @return {Number}
- */
-const render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
- const parent = tickable.parent;
- const duration = tickable.duration;
- const completed = tickable.completed;
- const iterationDuration = tickable.iterationDuration;
- const iterationCount = tickable.iterationCount;
- const _currentIteration = tickable._currentIteration;
- const _loopDelay = tickable._loopDelay;
- const _reversed = tickable._reversed;
- const _alternate = tickable._alternate;
- const _hasChildren = tickable._hasChildren;
- const tickableDelay = tickable._delay;
- const tickablePrevAbsoluteTime = tickable._currentTime; // TODO: rename ._currentTime to ._absoluteCurrentTime
- const tickableEndTime = tickableDelay + iterationDuration;
- const tickableAbsoluteTime = time - tickableDelay;
- const tickablePrevTime = clamp(tickablePrevAbsoluteTime, -tickableDelay, duration);
- const tickableCurrentTime = clamp(tickableAbsoluteTime, -tickableDelay, duration);
- const deltaTime = tickableAbsoluteTime - tickablePrevAbsoluteTime;
- const isCurrentTimeAboveZero = tickableCurrentTime > 0;
- const isCurrentTimeEqualOrAboveDuration = tickableCurrentTime >= duration;
- const isSetter = duration <= minValue;
- const forcedTick = tickMode === tickModes.FORCE;
- let isOdd = 0;
- let iterationElapsedTime = tickableAbsoluteTime;
- // Render checks
- // Used to also check if the children have rendered in order to trigger the onRender callback on the parent timer
- let hasRendered = 0;
- // Execute the "expensive" iterations calculations only when necessary
- if (iterationCount > 1) {
- // bitwise NOT operator seems to be generally faster than Math.floor() across browsers
- const currentIteration = ~~(tickableCurrentTime / (iterationDuration + (isCurrentTimeEqualOrAboveDuration ? 0 : _loopDelay)));
- tickable._currentIteration = clamp(currentIteration, 0, iterationCount);
- // Prevent the iteration count to go above the max iterations when reaching the end of the animation
- if (isCurrentTimeEqualOrAboveDuration)
- tickable._currentIteration--;
- isOdd = tickable._currentIteration % 2;
- iterationElapsedTime = tickableCurrentTime % (iterationDuration + _loopDelay) || 0;
- }
- // Checks if exactly one of _reversed and (_alternate && isOdd) is true
- const isReversed = _reversed ^ (_alternate && isOdd);
- const _ease = /** @type {Renderable} */ (tickable)._ease;
- let iterationTime = isCurrentTimeEqualOrAboveDuration ? isReversed ? 0 : duration : isReversed ? iterationDuration - iterationElapsedTime : iterationElapsedTime;
- if (_ease)
- iterationTime = iterationDuration * _ease(iterationTime / iterationDuration) || 0;
- const isRunningBackwards = (parent ? parent.backwards : tickableAbsoluteTime < tickablePrevAbsoluteTime) ? !isReversed : !!isReversed;
- tickable._currentTime = tickableAbsoluteTime;
- tickable._iterationTime = iterationTime;
- tickable.backwards = isRunningBackwards;
- if (isCurrentTimeAboveZero && !tickable.began) {
- tickable.began = true;
- if (!muteCallbacks && !(parent && (isRunningBackwards || !parent.began))) {
- tickable.onBegin(/** @type {CallbackArgument} */ (tickable));
- }
- }
- else if (tickableAbsoluteTime <= 0) {
- tickable.began = false;
- }
- // Only triggers onLoop for tickable without children, otherwise call the the onLoop callback in the tick function
- // Make sure to trigger the onLoop before rendering to allow .refresh() to pickup the current values
- if (!muteCallbacks && !_hasChildren && isCurrentTimeAboveZero && tickable._currentIteration !== _currentIteration) {
- tickable.onLoop(/** @type {CallbackArgument} */ (tickable));
- }
- if (forcedTick ||
- tickMode === tickModes.AUTO && (time >= tickableDelay && time <= tickableEndTime || // Normal render
- time <= tickableDelay && tickablePrevTime > tickableDelay || // Playhead is before the animation start time so make sure the animation is at its initial state
- time >= tickableEndTime && tickablePrevTime !== duration // Playhead is after the animation end time so make sure the animation is at its end state
- ) ||
- iterationTime >= tickableEndTime && tickablePrevTime !== duration ||
- iterationTime <= tickableDelay && tickablePrevTime > 0 ||
- time <= tickablePrevTime && tickablePrevTime === duration && completed || // Force a render if a seek occurs on an completed animation
- isCurrentTimeEqualOrAboveDuration && !completed && isSetter // This prevents 0 duration tickables to be skipped
- ) {
- if (isCurrentTimeAboveZero) {
- // Trigger onUpdate callback before rendering
- tickable.computeDeltaTime(tickablePrevTime);
- if (!muteCallbacks)
- tickable.onBeforeUpdate(/** @type {CallbackArgument} */ (tickable));
- }
- // Start tweens rendering
- if (!_hasChildren) {
- // Time has jumped more than globals.tickThreshold so consider this tick manual
- const forcedRender = forcedTick || (isRunningBackwards ? deltaTime * -1 : deltaTime) >= globals.tickThreshold;
- const absoluteTime = tickable._offset + (parent ? parent._offset : 0) + tickableDelay + iterationTime;
- // Only Animation can have tweens, Timer returns undefined
- let tween = /** @type {Tween} */ ( /** @type {JSAnimation} */(tickable)._head);
- let tweenTarget;
- let tweenStyle;
- let tweenTargetTransforms;
- let tweenTargetTransformsProperties;
- let tweenTransformsNeedUpdate = 0;
- while (tween) {
- const tweenComposition = tween._composition;
- const tweenCurrentTime = tween._currentTime;
- const tweenChangeDuration = tween._changeDuration;
- const tweenAbsEndTime = tween._absoluteStartTime + tween._changeDuration;
- const tweenNextRep = tween._nextRep;
- const tweenPrevRep = tween._prevRep;
- const tweenHasComposition = tweenComposition !== compositionTypes.none;
- if ((forcedRender || ((tweenCurrentTime !== tweenChangeDuration || absoluteTime <= tweenAbsEndTime + (tweenNextRep ? tweenNextRep._delay : 0)) &&
- (tweenCurrentTime !== 0 || absoluteTime >= tween._absoluteStartTime))) && (!tweenHasComposition || (!tween._isOverridden &&
- (!tween._isOverlapped || absoluteTime <= tweenAbsEndTime) &&
- (!tweenNextRep || (tweenNextRep._isOverridden || absoluteTime <= tweenNextRep._absoluteStartTime)) &&
- (!tweenPrevRep || (tweenPrevRep._isOverridden || (absoluteTime >= (tweenPrevRep._absoluteStartTime + tweenPrevRep._changeDuration) + tween._delay)))))) {
- const tweenNewTime = tween._currentTime = clamp(iterationTime - tween._startTime, 0, tweenChangeDuration);
- const tweenProgress = tween._ease(tweenNewTime / tween._updateDuration);
- const tweenModifier = tween._modifier;
- const tweenValueType = tween._valueType;
- const tweenType = tween._tweenType;
- const tweenIsObject = tweenType === tweenTypes.OBJECT;
- const tweenIsNumber = tweenValueType === valueTypes.NUMBER;
- // Only round the in-between frames values if the final value is a string
- const tweenPrecision = (tweenIsNumber && tweenIsObject) || tweenProgress === 0 || tweenProgress === 1 ? -1 : globals.precision;
- // Recompose tween value
- /** @type {String|Number} */
- let value;
- /** @type {Number} */
- let number;
- if (tweenIsNumber) {
- value = number = /** @type {Number} */ (tweenModifier(round(interpolate(tween._fromNumber, tween._toNumber, tweenProgress), tweenPrecision)));
- }
- else if (tweenValueType === valueTypes.UNIT) {
- // Rounding the values speed up string composition
- number = /** @type {Number} */ (tweenModifier(round(interpolate(tween._fromNumber, tween._toNumber, tweenProgress), tweenPrecision)));
- value = `${number}${tween._unit}`;
- }
- else if (tweenValueType === valueTypes.COLOR) {
- const fn = tween._fromNumbers;
- const tn = tween._toNumbers;
- const r = round(clamp(/** @type {Number} */ (tweenModifier(interpolate(fn[0], tn[0], tweenProgress))), 0, 255), 0);
- const g = round(clamp(/** @type {Number} */ (tweenModifier(interpolate(fn[1], tn[1], tweenProgress))), 0, 255), 0);
- const b = round(clamp(/** @type {Number} */ (tweenModifier(interpolate(fn[2], tn[2], tweenProgress))), 0, 255), 0);
- const a = clamp(/** @type {Number} */ (tweenModifier(round(interpolate(fn[3], tn[3], tweenProgress), tweenPrecision))), 0, 1);
- value = `rgba(${r},${g},${b},${a})`;
- if (tweenHasComposition) {
- const ns = tween._numbers;
- ns[0] = r;
- ns[1] = g;
- ns[2] = b;
- ns[3] = a;
- }
- }
- else if (tweenValueType === valueTypes.COMPLEX) {
- value = tween._strings[0];
- for (let j = 0, l = tween._toNumbers.length; j < l; j++) {
- const n = /** @type {Number} */ (tweenModifier(round(interpolate(tween._fromNumbers[j], tween._toNumbers[j], tweenProgress), tweenPrecision)));
- const s = tween._strings[j + 1];
- value += `${s ? n + s : n}`;
- if (tweenHasComposition) {
- tween._numbers[j] = n;
- }
- }
- }
- // For additive tweens and Animatables
- if (tweenHasComposition) {
- tween._number = number;
- }
- if (!internalRender && tweenComposition !== compositionTypes.blend) {
- const tweenProperty = tween.property;
- tweenTarget = tween.target;
- if (tweenIsObject) {
- tweenTarget[tweenProperty] = value;
- }
- else if (tweenType === tweenTypes.ATTRIBUTE) {
- /** @type {DOMTarget} */ (tweenTarget).setAttribute(tweenProperty, /** @type {String} */ (value));
- }
- else {
- tweenStyle = /** @type {DOMTarget} */ (tweenTarget).style;
- if (tweenType === tweenTypes.TRANSFORM) {
- if (tweenTarget !== tweenTargetTransforms) {
- tweenTargetTransforms = tweenTarget;
- // NOTE: Referencing the cachedTransforms in the tween property directly can be a little bit faster but appears to increase memory usage.
- tweenTargetTransformsProperties = tweenTarget[transformsSymbol];
- }
- tweenTargetTransformsProperties[tweenProperty] = value;
- tweenTransformsNeedUpdate = 1;
- }
- else if (tweenType === tweenTypes.CSS) {
- tweenStyle[tweenProperty] = value;
- }
- else if (tweenType === tweenTypes.CSS_VAR) {
- tweenStyle.setProperty(tweenProperty, /** @type {String} */ (value));
- }
- }
- if (isCurrentTimeAboveZero)
- hasRendered = 1;
- }
- else {
- // Used for composing timeline tweens without having to do a real render
- tween._value = value;
- }
- }
- // NOTE: Possible improvement: Use translate(x,y) / translate3d(x,y,z) syntax
- // to reduce memory usage on string composition
- if (tweenTransformsNeedUpdate && tween._renderTransforms) {
- let str = emptyString;
- for (let key in tweenTargetTransformsProperties) {
- str += `${transformsFragmentStrings[key]}${tweenTargetTransformsProperties[key]}) `;
- }
- tweenStyle.transform = str;
- tweenTransformsNeedUpdate = 0;
- }
- tween = tween._next;
- }
- if (!muteCallbacks && hasRendered) {
- /** @type {JSAnimation} */ (tickable).onRender(/** @type {JSAnimation} */ (tickable));
- }
- }
- if (!muteCallbacks && isCurrentTimeAboveZero) {
- tickable.onUpdate(/** @type {CallbackArgument} */ (tickable));
- }
- }
- // End tweens rendering
- // Handle setters on timeline differently and allow re-trigering the onComplete callback when seeking backwards
- if (parent && isSetter) {
- if (!muteCallbacks && ((parent.began && !isRunningBackwards && tickableAbsoluteTime >= duration && !completed) ||
- (isRunningBackwards && tickableAbsoluteTime <= minValue && completed))) {
- tickable.onComplete(/** @type {CallbackArgument} */ (tickable));
- tickable.completed = !isRunningBackwards;
- }
- // If currentTime is both above 0 and at least equals to duration, handles normal onComplete or infinite loops
- }
- else if (isCurrentTimeAboveZero && isCurrentTimeEqualOrAboveDuration) {
- if (iterationCount === Infinity) {
- // Offset the tickable _startTime with its duration to reset _currentTime to 0 and continue the infinite timer
- tickable._startTime += tickable.duration;
- }
- else if (tickable._currentIteration >= iterationCount - 1) {
- // By setting paused to true, we tell the engine loop to not render this tickable and removes it from the list on the next tick
- tickable.paused = true;
- if (!completed && !_hasChildren) {
- // If the tickable has children, triggers onComplete() only when all children have completed in the tick function
- tickable.completed = true;
- if (!muteCallbacks && !(parent && (isRunningBackwards || !parent.began))) {
- tickable.onComplete(/** @type {CallbackArgument} */ (tickable));
- tickable._resolve(/** @type {CallbackArgument} */ (tickable));
- }
- }
- }
- // Otherwise set the completed flag to false
- }
- else {
- tickable.completed = false;
- }
- // NOTE: hasRendered * direction (negative for backwards) this way we can remove the tickable.backwards property completly ?
- return hasRendered;
-};
-/**
- * @param {Tickable} tickable
- * @param {Number} time
- * @param {Number} muteCallbacks
- * @param {Number} internalRender
- * @param {Number} tickMode
- * @return {void}
- */
-const tick = (tickable, time, muteCallbacks, internalRender, tickMode) => {
- const _currentIteration = tickable._currentIteration;
- render(tickable, time, muteCallbacks, internalRender, tickMode);
- if (tickable._hasChildren) {
- const tl = /** @type {Timeline} */ (tickable);
- const tlIsRunningBackwards = tl.backwards;
- const tlChildrenTime = internalRender ? time : tl._iterationTime;
- const tlCildrenTickTime = now();
- let tlChildrenHasRendered = 0;
- let tlChildrenHaveCompleted = true;
- // If the timeline has looped forward, we need to manually triggers children skipped callbacks
- if (!internalRender && tl._currentIteration !== _currentIteration) {
- const tlIterationDuration = tl.iterationDuration;
- forEachChildren(tl, (/** @type {JSAnimation} */ child) => {
- if (!tlIsRunningBackwards) {
- // Force an internal render to trigger the callbacks if the child has not completed on loop
- if (!child.completed && !child.backwards && child._currentTime < child.iterationDuration) {
- render(child, tlIterationDuration, muteCallbacks, 1, tickModes.FORCE);
- }
- // Reset their began and completed flags to allow retrigering callbacks on the next iteration
- child.began = false;
- child.completed = false;
- }
- else {
- const childDuration = child.duration;
- const childStartTime = child._offset + child._delay;
- const childEndTime = childStartTime + childDuration;
- // Triggers the onComplete callback on reverse for children on the edges of the timeline
- if (!muteCallbacks && childDuration <= minValue && (!childStartTime || childEndTime === tlIterationDuration)) {
- child.onComplete(child);
- }
- }
- });
- if (!muteCallbacks)
- tl.onLoop(/** @type {CallbackArgument} */ (tl));
- }
- forEachChildren(tl, (/** @type {JSAnimation} */ child) => {
- const childTime = round((tlChildrenTime - child._offset) * child._speed, 12); // Rounding is needed when using seconds
- const childTickMode = child._fps < tl._fps ? child.requestTick(tlCildrenTickTime) : tickMode;
- tlChildrenHasRendered += render(child, childTime, muteCallbacks, internalRender, childTickMode);
- if (!child.completed && tlChildrenHaveCompleted)
- tlChildrenHaveCompleted = false;
- }, tlIsRunningBackwards);
- // Renders on timeline are triggered by its children so it needs to be set after rendering the children
- if (!muteCallbacks && tlChildrenHasRendered)
- tl.onRender(/** @type {CallbackArgument} */ (tl));
- // Triggers the timeline onComplete() once all chindren all completed and the current time has reached the end
- if ((tlChildrenHaveCompleted || tlIsRunningBackwards) && tl._currentTime >= tl.duration) {
- // Make sure the paused flag is false in case it has been skipped in the render function
- tl.paused = true;
- if (!tl.completed) {
- tl.completed = true;
- if (!muteCallbacks) {
- tl.onComplete(/** @type {CallbackArgument} */ (tl));
- tl._resolve(/** @type {CallbackArgument} */ (tl));
- }
- }
- }
- }
-};
-
-
-const additive = {
- animation: null,
- update: noop,
-};
-/**
- * @typedef AdditiveAnimation
- * @property {Number} duration
- * @property {Number} _offset
- * @property {Number} _delay
- * @property {Tween} _head
- * @property {Tween} _tail
- */
-/**
- * @param {TweenAdditiveLookups} lookups
- * @return {AdditiveAnimation}
- */
-const addAdditiveAnimation = lookups => {
- let animation = additive.animation;
- if (!animation) {
- animation = {
- duration: minValue,
- computeDeltaTime: noop,
- _offset: 0,
- _delay: 0,
- _head: null,
- _tail: null,
- };
- additive.animation = animation;
- additive.update = () => {
- lookups.forEach(propertyAnimation => {
- for (let propertyName in propertyAnimation) {
- const tweens = propertyAnimation[propertyName];
- const lookupTween = tweens._head;
- if (lookupTween) {
- const valueType = lookupTween._valueType;
- const additiveValues = valueType === valueTypes.COMPLEX || valueType === valueTypes.COLOR ? cloneArray(lookupTween._fromNumbers) : null;
- let additiveValue = lookupTween._fromNumber;
- let tween = tweens._tail;
- while (tween && tween !== lookupTween) {
- if (additiveValues) {
- for (let i = 0, l = tween._numbers.length; i < l; i++)
- additiveValues[i] += tween._numbers[i];
- }
- else {
- additiveValue += tween._number;
- }
- tween = tween._prevAdd;
- }
- lookupTween._toNumber = additiveValue;
- lookupTween._toNumbers = additiveValues;
- }
- }
- });
- // TODO: Avoid polymorphism here, idealy the additive animation should be a regular animation with a higher priority in the render loop
- render(animation, 1, 1, 0, tickModes.FORCE);
- };
- }
- return animation;
-};
-
-const engineTickMethod = /*#__PURE__*/ (() => isBrowser ? requestAnimationFrame : setImmediate)();
-const engineCancelMethod = /*#__PURE__*/ (() => isBrowser ? cancelAnimationFrame : clearImmediate)();
-class Engine extends Clock {
- /** @param {Number} [initTime] */
- constructor(initTime) {
- super(initTime);
- this.useDefaultMainLoop = true;
- this.pauseOnDocumentHidden = true;
- /** @type {DefaultsParams} */
- this.defaults = defaults;
- // this.paused = isBrowser && doc.hidden ? true : false;
- this.paused = true;
- /** @type {Number|NodeJS.Immediate} */
- this.reqId = 0;
- }
- update() {
- const time = this._currentTime = now();
- if (this.requestTick(time)) {
- this.computeDeltaTime(time);
- const engineSpeed = this._speed;
- const engineFps = this._fps;
- let activeTickable = /** @type {Tickable} */ (this._head);
- while (activeTickable) {
- const nextTickable = activeTickable._next;
- if (!activeTickable.paused) {
- tick(activeTickable, (time - activeTickable._startTime) * activeTickable._speed * engineSpeed, 0, // !muteCallbacks
- 0, // !internalRender
- activeTickable._fps < engineFps ? activeTickable.requestTick(time) : tickModes.AUTO);
- }
- else {
- removeChild(this, activeTickable);
- this._hasChildren = !!this._tail;
- activeTickable._running = false;
- if (activeTickable.completed && !activeTickable._cancelled) {
- activeTickable.cancel();
- }
- }
- activeTickable = nextTickable;
- }
- additive.update();
- }
- }
- wake() {
- if (this.useDefaultMainLoop && !this.reqId) {
- // Imediatly request a tick to update engine._elapsedTime and get accurate offsetPosition calculation in timer.js
- this.requestTick(now());
- this.reqId = engineTickMethod(tickEngine);
- }
- return this;
- }
- pause() {
- if (!this.reqId)
- return;
- this.paused = true;
- return killEngine();
- }
- resume() {
- if (!this.paused)
- return;
- this.paused = false;
- forEachChildren(this, (/** @type {Tickable} */ child) => child.resetTime());
- return this.wake();
- }
- // Getter and setter for speed
- get speed() {
- return this._speed * (globals.timeScale === 1 ? 1 : K);
- }
- set speed(playbackRate) {
- this._speed = playbackRate * globals.timeScale;
- forEachChildren(this, (/** @type {Tickable} */ child) => child.speed = child._speed);
- }
- // Getter and setter for timeUnit
- get timeUnit() {
- return globals.timeScale === 1 ? 'ms' : 's';
- }
- ;
- set timeUnit(unit) {
- const secondsScale = 0.001;
- const isSecond = unit === 's';
- const newScale = isSecond ? secondsScale : 1;
- if (globals.timeScale !== newScale) {
- globals.timeScale = newScale;
- globals.tickThreshold = 200 * newScale;
- const scaleFactor = isSecond ? secondsScale : K;
- /** @type {Number} */
- (this.defaults.duration) *= scaleFactor;
- this._speed *= scaleFactor;
- }
- }
- // Getter and setter for precision
- get precision() {
- return globals.precision;
- }
- set precision(precision) {
- globals.precision = precision;
- }
-}
-const engine = /*#__PURE__*/ (() => {
- const engine = new Engine(now());
- if (isBrowser) {
- globalVersions.engine = engine;
- doc.addEventListener('visibilitychange', () => {
- if (!engine.pauseOnDocumentHidden)
- return;
- doc.hidden ? engine.pause() : engine.resume();
- });
- }
- return engine;
-})();
-const tickEngine = () => {
- if (engine._head) {
- engine.reqId = engineTickMethod(tickEngine);
- engine.update();
- }
- else {
- engine.reqId = 0;
- }
-};
-const killEngine = () => {
- engineCancelMethod(/** @type {NodeJS.Immediate & Number} */ (engine.reqId));
- engine.reqId = 0;
- return engine;
-};
-
-
-/**
- * @param {DOMTarget} target
- * @param {String} propName
- * @param {Object} animationInlineStyles
- * @return {String}
- */
-const parseInlineTransforms = (target, propName, animationInlineStyles) => {
- const inlineTransforms = target.style.transform;
- let inlinedStylesPropertyValue;
- if (inlineTransforms) {
- const cachedTransforms = target[transformsSymbol];
- let t;
- while (t = transformsExecRgx.exec(inlineTransforms)) {
- const inlinePropertyName = t[1];
- // const inlinePropertyValue = t[2];
- const inlinePropertyValue = t[2].slice(1, -1);
- cachedTransforms[inlinePropertyName] = inlinePropertyValue;
- if (inlinePropertyName === propName) {
- inlinedStylesPropertyValue = inlinePropertyValue;
- // Store the new parsed inline styles if animationInlineStyles is provided
- if (animationInlineStyles) {
- animationInlineStyles[propName] = inlinePropertyValue;
- }
- }
- }
- }
- return inlineTransforms && !isUnd(inlinedStylesPropertyValue) ? inlinedStylesPropertyValue :
- stringStartsWith(propName, 'scale') ? '1' :
- stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew') ? '0deg' : '0px';
-};
-
-
-/**
- * @param {DOMTargetsParam|TargetsParam} v
- * @return {NodeList|HTMLCollection}
- */
-function getNodeList(v) {
- const n = isStr(v) ? scope.root.querySelectorAll(v) : v;
- if (n instanceof NodeList || n instanceof HTMLCollection)
- return n;
-}
-/**
- * @overload
- * @param {DOMTargetsParam} targets
- * @return {DOMTargetsArray}
- *
- * @overload
- * @param {JSTargetsParam} targets
- * @return {JSTargetsArray}
- *
- * @overload
- * @param {TargetsParam} targets
- * @return {TargetsArray}
- *
- * @param {DOMTargetsParam|JSTargetsParam|TargetsParam} targets
- */
-function parseTargets(targets) {
- if (isNil(targets))
- return /** @type {TargetsArray} */ ([]);
- if (!isBrowser)
- return /** @type {JSTargetsArray} */ (isArr(targets) && targets.flat(Infinity) || [targets]);
- if (isArr(targets)) {
- const flattened = targets.flat(Infinity);
- /** @type {TargetsArray} */
- const parsed = [];
- for (let i = 0, l = flattened.length; i < l; i++) {
- const item = flattened[i];
- if (!isNil(item)) {
- const nodeList = getNodeList(item);
- if (nodeList) {
- for (let j = 0, jl = nodeList.length; j < jl; j++) {
- const subItem = nodeList[j];
- if (!isNil(subItem)) {
- let isDuplicate = false;
- for (let k = 0, kl = parsed.length; k < kl; k++) {
- if (parsed[k] === subItem) {
- isDuplicate = true;
- break;
- }
- }
- if (!isDuplicate) {
- parsed.push(subItem);
- }
- }
- }
- }
- else {
- let isDuplicate = false;
- for (let j = 0, jl = parsed.length; j < jl; j++) {
- if (parsed[j] === item) {
- isDuplicate = true;
- break;
- }
- }
- if (!isDuplicate) {
- parsed.push(item);
- }
- }
- }
- }
- return parsed;
- }
- const nodeList = getNodeList(targets);
- if (nodeList)
- return /** @type {DOMTargetsArray} */ (Array.from(nodeList));
- return /** @type {TargetsArray} */ ([targets]);
-}
-/**
- * @overload
- * @param {DOMTargetsParam} targets
- * @return {DOMTargetsArray}
- *
- * @overload
- * @param {JSTargetsParam} targets
- * @return {JSTargetsArray}
- *
- * @overload
- * @param {TargetsParam} targets
- * @return {TargetsArray}
- *
- * @param {DOMTargetsParam|JSTargetsParam|TargetsParam} targets
- */
-function registerTargets(targets) {
- const parsedTargetsArray = parseTargets(targets);
- const parsedTargetsLength = parsedTargetsArray.length;
- if (parsedTargetsLength) {
- for (let i = 0; i < parsedTargetsLength; i++) {
- const target = parsedTargetsArray[i];
- if (!target[isRegisteredTargetSymbol]) {
- target[isRegisteredTargetSymbol] = true;
- const isSvgType = isSvg(target);
- const isDom = /** @type {DOMTarget} */ (target).nodeType || isSvgType;
- if (isDom) {
- target[isDomSymbol] = true;
- target[isSvgSymbol] = isSvgType;
- target[transformsSymbol] = {};
- }
- }
- }
- }
- return parsedTargetsArray;
-}
-
-
-/**
- * @param {TargetsParam} path
- * @return {SVGGeometryElement|undefined}
- */
-const getPath = path => {
- const parsedTargets = parseTargets(path);
- const $parsedSvg = /** @type {SVGGeometryElement} */ (parsedTargets[0]);
- if (!$parsedSvg || !isSvg($parsedSvg))
- return;
- return $parsedSvg;
-};
-/**
- * @param {TargetsParam} path2
- * @param {Number} [precision]
- * @return {FunctionValue}
- */
-const morphTo = (path2, precision = .33) => ($path1) => {
- const $path2 = /** @type {SVGGeometryElement} */ (getPath(path2));
- if (!$path2)
- return;
- const isPath = $path1.tagName === 'path';
- const separator = isPath ? ' ' : ',';
- const previousPoints = $path1[morphPointsSymbol];
- if (previousPoints)
- $path1.setAttribute(isPath ? 'd' : 'points', previousPoints);
- let v1 = '', v2 = '';
- if (!precision) {
- v1 = $path1.getAttribute(isPath ? 'd' : 'points');
- v2 = $path2.getAttribute(isPath ? 'd' : 'points');
- }
- else {
- const length1 = /** @type {SVGGeometryElement} */ ($path1).getTotalLength();
- const length2 = $path2.getTotalLength();
- const maxPoints = Math.max(Math.ceil(length1 * precision), Math.ceil(length2 * precision));
- for (let i = 0; i < maxPoints; i++) {
- const t = i / (maxPoints - 1);
- const pointOnPath1 = /** @type {SVGGeometryElement} */ ($path1).getPointAtLength(length1 * t);
- const pointOnPath2 = $path2.getPointAtLength(length2 * t);
- const prefix = isPath ? (i === 0 ? 'M' : 'L') : '';
- v1 += prefix + round(pointOnPath1.x, 3) + separator + pointOnPath1.y + ' ';
- v2 += prefix + round(pointOnPath2.x, 3) + separator + pointOnPath2.y + ' ';
- }
- }
- $path1[morphPointsSymbol] = v2;
- return [v1, v2];
-};
-/**
- * @param {SVGGeometryElement} [$el]
- * @return {Number}
- */
-const getScaleFactor = $el => {
- let scaleFactor = 1;
- if ($el && $el.getCTM) {
- const ctm = $el.getCTM();
- if (ctm) {
- const scaleX = sqrt(ctm.a * ctm.a + ctm.b * ctm.b);
- const scaleY = sqrt(ctm.c * ctm.c + ctm.d * ctm.d);
- scaleFactor = (scaleX + scaleY) / 2;
- }
- }
- return scaleFactor;
-};
-/**
- * Creates a proxy that wraps an SVGGeometryElement and adds drawing functionality.
- * @param {SVGGeometryElement} $el - The SVG element to transform into a drawable
- * @param {number} start - Starting position (0-1)
- * @param {number} end - Ending position (0-1)
- * @return {DrawableSVGGeometry} - Returns a proxy that preserves the original element's type with additional 'draw' attribute functionality
- */
-const createDrawableProxy = ($el, start, end) => {
- const pathLength = K;
- const computedStyles = getComputedStyle($el);
- const strokeLineCap = computedStyles.strokeLinecap;
- // @ts-ignore
- const $scalled = computedStyles.vectorEffect === 'non-scaling-stroke' ? $el : null;
- let currentCap = strokeLineCap;
- const proxy = new Proxy($el, {
- get(target, property) {
- const value = target[property];
- if (property === proxyTargetSymbol)
- return target;
- if (property === 'setAttribute') {
- return (...args) => {
- if (args[0] === 'draw') {
- const value = args[1];
- const values = value.split(' ');
- const v1 = +values[0];
- const v2 = +values[1];
- // TOTO: Benchmark if performing two slices is more performant than one split
- // const spaceIndex = value.indexOf(' ');
- // const v1 = round(+value.slice(0, spaceIndex), precision);
- // const v2 = round(+value.slice(spaceIndex + 1), precision);
- const scaleFactor = getScaleFactor($scalled);
- const os = v1 * -1e3 * scaleFactor;
- const d1 = (v2 * pathLength * scaleFactor) + os;
- const d2 = (pathLength * scaleFactor +
- ((v1 === 0 && v2 === 1) || (v1 === 1 && v2 === 0) ? 0 : 10 * scaleFactor) - d1);
- if (strokeLineCap !== 'butt') {
- const newCap = v1 === v2 ? 'butt' : strokeLineCap;
- if (currentCap !== newCap) {
- target.style.strokeLinecap = `${newCap}`;
- currentCap = newCap;
- }
- }
- target.setAttribute('stroke-dashoffset', `${os}`);
- target.setAttribute('stroke-dasharray', `${d1} ${d2}`);
- }
- return Reflect.apply(value, target, args);
- };
- }
- if (isFnc(value)) {
- return (...args) => Reflect.apply(value, target, args);
- }
- else {
- return value;
- }
- }
- });
- if ($el.getAttribute('pathLength') !== `${pathLength}`) {
- $el.setAttribute('pathLength', `${pathLength}`);
- proxy.setAttribute('draw', `${start} ${end}`);
- }
- return /** @type {DrawableSVGGeometry} */ (proxy);
-};
-/**
- * Creates drawable proxies for multiple SVG elements.
- * @param {TargetsParam} selector - CSS selector, SVG element, or array of elements and selectors
- * @param {number} [start=0] - Starting position (0-1)
- * @param {number} [end=0] - Ending position (0-1)
- * @return {Array<DrawableSVGGeometry>} - Array of proxied elements with drawing functionality
- */
-const createDrawable = (selector, start = 0, end = 0) => {
- const els = parseTargets(selector);
- return els.map($el => createDrawableProxy(
- /** @type {SVGGeometryElement} */ ($el), start, end));
-};
-// Motion path animation
-/**
- * @param {SVGGeometryElement} $path
- * @param {Number} progress
- * @param {Number}lookup
- * @return {DOMPoint}
- */
-const getPathPoint = ($path, progress, lookup = 0) => {
- return $path.getPointAtLength(progress + lookup >= 1 ? progress + lookup : 0);
-};
-/**
- * @param {SVGGeometryElement} $path
- * @param {String} pathProperty
- * @return {FunctionValue}
- */
-const getPathProgess = ($path, pathProperty) => {
- return $el => {
- const totalLength = +($path.getTotalLength());
- const inSvg = $el[isSvgSymbol];
- const ctm = $path.getCTM();
- /** @type {TweenObjectValue} */
- return {
- from: 0,
- to: totalLength,
- /** @type {TweenModifier} */
- modifier: progress => {
- if (pathProperty === 'a') {
- const p0 = getPathPoint($path, progress, -1);
- const p1 = getPathPoint($path, progress, 1);
- return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
- }
- else {
- const p = getPathPoint($path, progress, 0);
- return pathProperty === 'x' ?
- inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
- inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f;
- }
- }
- };
- };
-};
-/**
- * @param {TargetsParam} path
- */
-const createMotionPath = path => {
- const $path = getPath(path);
- if (!$path)
- return;
- return {
- translateX: getPathProgess($path, 'x'),
- translateY: getPathProgess($path, 'y'),
- rotate: getPathProgess($path, 'a'),
- };
-};
-// Check for valid SVG attribute
-const cssReservedProperties = ['opacity', 'rotate', 'overflow', 'color'];
-/**
- * @param {Target} el
- * @param {String} propertyName
- * @return {Boolean}
- */
-const isValidSVGAttribute = (el, propertyName) => {
- // Return early and use CSS opacity animation instead (already better default values (opacity: 1 instead of 0)) and rotate should be considered a transform
- if (cssReservedProperties.includes(propertyName))
- return false;
- if (el.getAttribute(propertyName) || propertyName in el) {
- if (propertyName === 'scale') { // Scale
- const elParentNode = /** @type {SVGGeometryElement} */ ( /** @type {DOMTarget} */(el).parentNode);
- // Only consider scale as a valid SVG attribute on filter element
- return elParentNode && elParentNode.tagName === 'filter';
- }
- return true;
- }
-};
-const svg = {
- morphTo,
- createMotionPath,
- createDrawable,
-};
-
-
-/**
- * RGB / RGBA Color value string -> RGBA values array
- * @param {String} rgbValue
- * @return {ColorArray}
- */
-const rgbToRgba = rgbValue => {
- const rgba = rgbExecRgx.exec(rgbValue) || rgbaExecRgx.exec(rgbValue);
- const a = !isUnd(rgba[4]) ? +rgba[4] : 1;
- return [
- +rgba[1],
- +rgba[2],
- +rgba[3],
- a
- ];
-};
-/**
- * HEX3 / HEX3A / HEX6 / HEX6A Color value string -> RGBA values array
- * @param {String} hexValue
- * @return {ColorArray}
- */
-const hexToRgba = hexValue => {
- const hexLength = hexValue.length;
- const isShort = hexLength === 4 || hexLength === 5;
- return [
- +('0x' + hexValue[1] + hexValue[isShort ? 1 : 2]),
- +('0x' + hexValue[isShort ? 2 : 3] + hexValue[isShort ? 2 : 4]),
- +('0x' + hexValue[isShort ? 3 : 5] + hexValue[isShort ? 3 : 6]),
- ((hexLength === 5 || hexLength === 9) ? +(+('0x' + hexValue[isShort ? 4 : 7] + hexValue[isShort ? 4 : 8]) / 255).toFixed(3) : 1)
- ];
-};
-/**
- * @param {Number} p
- * @param {Number} q
- * @param {Number} t
- * @return {Number}
- */
-const hue2rgb = (p, q, t) => {
- if (t < 0)
- t += 1;
- if (t > 1)
- t -= 1;
- return t < 1 / 6 ? p + (q - p) * 6 * t :
- t < 1 / 2 ? q :
- t < 2 / 3 ? p + (q - p) * (2 / 3 - t) * 6 :
- p;
-};
-/**
- * HSL / HSLA Color value string -> RGBA values array
- * @param {String} hslValue
- * @return {ColorArray}
- */
-const hslToRgba = hslValue => {
- const hsla = hslExecRgx.exec(hslValue) || hslaExecRgx.exec(hslValue);
- const h = +hsla[1] / 360;
- const s = +hsla[2] / 100;
- const l = +hsla[3] / 100;
- const a = !isUnd(hsla[4]) ? +hsla[4] : 1;
- let r, g, b;
- if (s === 0) {
- r = g = b = l;
- }
- else {
- const q = l < .5 ? l * (1 + s) : l + s - l * s;
- const p = 2 * l - q;
- r = round(hue2rgb(p, q, h + 1 / 3) * 255, 0);
- g = round(hue2rgb(p, q, h) * 255, 0);
- b = round(hue2rgb(p, q, h - 1 / 3) * 255, 0);
- }
- return [r, g, b, a];
-};
-/**
- * All in one color converter that converts a color string value into an array of RGBA values
- * @param {String} colorString
- * @return {ColorArray}
- */
-const convertColorStringValuesToRgbaArray = colorString => {
- return isRgb(colorString) ? rgbToRgba(colorString) :
- isHex(colorString) ? hexToRgba(colorString) :
- isHsl(colorString) ? hslToRgba(colorString) :
- [0, 0, 0, 1];
-};
-
-
-/**
- * @template T, D
- * @param {T|undefined} targetValue
- * @param {D} defaultValue
- * @return {T|D}
- */
-const setValue = (targetValue, defaultValue) => {
- return isUnd(targetValue) ? defaultValue : targetValue;
-};
-/**
- * @param {TweenPropValue} value
- * @param {Target} target
- * @param {Number} index
- * @param {Number} total
- * @param {Object} [store]
- * @return {any}
- */
-const getFunctionValue = (value, target, index, total, store) => {
- if (isFnc(value)) {
- const func = () => {
- const computed = /** @type {Function} */ (value)(target, index, total);
- // Fallback to 0 if the function returns undefined / NaN / null / false / 0
- return !isNaN(+computed) ? +computed : computed || 0;
- };
- if (store) {
- store.func = func;
- }
- return func();
- }
- else {
- return value;
- }
-};
-/**
- * @param {Target} target
- * @param {String} prop
- * @return {tweenTypes}
- */
-const getTweenType = (target, prop) => {
- return !target[isDomSymbol] ? tweenTypes.OBJECT :
- // Handle SVG attributes
- target[isSvgSymbol] && isValidSVGAttribute(target, prop) ? tweenTypes.ATTRIBUTE :
- // Handle CSS Transform properties differently than CSS to allow individual animations
- validTransforms.includes(prop) || shortTransforms.get(prop) ? tweenTypes.TRANSFORM :
- // CSS variables
- stringStartsWith(prop, '--') ? tweenTypes.CSS_VAR :
- // All other CSS properties
- prop in /** @type {DOMTarget} */ (target).style ? tweenTypes.CSS :
- // Handle other DOM Attributes
- prop in target ? tweenTypes.OBJECT :
- tweenTypes.ATTRIBUTE;
-};
-/**
- * @param {DOMTarget} target
- * @param {String} propName
- * @param {Object} animationInlineStyles
- * @return {String}
- */
-const getCSSValue = (target, propName, animationInlineStyles) => {
- const inlineStyles = target.style[propName];
- if (inlineStyles && animationInlineStyles) {
- animationInlineStyles[propName] = inlineStyles;
- }
- const value = inlineStyles || getComputedStyle(target[proxyTargetSymbol] || target).getPropertyValue(propName);
- return value === 'auto' ? '0' : value;
-};
-/**
- * @param {Target} target
- * @param {String} propName
- * @param {tweenTypes} [tweenType]
- * @param {Object|void} [animationInlineStyles]
- * @return {String|Number}
- */
-const getOriginalAnimatableValue = (target, propName, tweenType, animationInlineStyles) => {
- const type = !isUnd(tweenType) ? tweenType : getTweenType(target, propName);
- return type === tweenTypes.OBJECT ? target[propName] || 0 :
- type === tweenTypes.ATTRIBUTE ? /** @type {DOMTarget} */ (target).getAttribute(propName) :
- type === tweenTypes.TRANSFORM ? parseInlineTransforms(/** @type {DOMTarget} */ (target), propName, animationInlineStyles) :
- type === tweenTypes.CSS_VAR ? getCSSValue(/** @type {DOMTarget} */ (target), propName, animationInlineStyles).trimStart() :
- getCSSValue(/** @type {DOMTarget} */ (target), propName, animationInlineStyles);
-};
-/**
- * @param {Number} x
- * @param {Number} y
- * @param {String} operator
- * @return {Number}
- */
-const getRelativeValue = (x, y, operator) => {
- return operator === '-' ? x - y :
- operator === '+' ? x + y :
- x * y;
-};
-/** @return {TweenDecomposedValue} */
-const createDecomposedValueTargetObject = () => {
- return {
- /** @type {valueTypes} */
- t: valueTypes.NUMBER,
- n: 0,
- u: null,
- o: null,
- d: null,
- s: null,
- };
-};
-/**
- * @param {String|Number} rawValue
- * @param {TweenDecomposedValue} targetObject
- * @return {TweenDecomposedValue}
- */
-const decomposeRawValue = (rawValue, targetObject) => {
- /** @type {valueTypes} */
- targetObject.t = valueTypes.NUMBER;
- targetObject.n = 0;
- targetObject.u = null;
- targetObject.o = null;
- targetObject.d = null;
- targetObject.s = null;
- if (!rawValue)
- return targetObject;
- const num = +rawValue;
- if (!isNaN(num)) {
- // It's a number
- targetObject.n = num;
- return targetObject;
- }
- else {
- // let str = /** @type {String} */(rawValue).trim();
- let str = /** @type {String} */ (rawValue);
- // Parsing operators (+=, -=, *=) manually is much faster than using regex here
- if (str[1] === '=') {
- targetObject.o = str[0];
- str = str.slice(2);
- }
- // Skip exec regex if the value type is complex or color to avoid long regex backtracking
- const unitMatch = str.includes(' ') ? false : unitsExecRgx.exec(str);
- if (unitMatch) {
- // Has a number and a unit
- targetObject.t = valueTypes.UNIT;
- targetObject.n = +unitMatch[1];
- targetObject.u = unitMatch[2];
- return targetObject;
- }
- else if (targetObject.o) {
- // Has an operator (+=, -=, *=)
- targetObject.n = +str;
- return targetObject;
- }
- else if (isCol(str)) {
- // Is a color
- targetObject.t = valueTypes.COLOR;
- targetObject.d = convertColorStringValuesToRgbaArray(str);
- return targetObject;
- }
- else {
- // Is a more complex string (generally svg coords, calc() or filters CSS values)
- const matchedNumbers = str.match(digitWithExponentRgx);
- targetObject.t = valueTypes.COMPLEX;
- targetObject.d = matchedNumbers ? matchedNumbers.map(Number) : [];
- targetObject.s = str.split(digitWithExponentRgx) || [];
- return targetObject;
- }
- }
-};
-/**
- * @param {Tween} tween
- * @param {TweenDecomposedValue} targetObject
- * @return {TweenDecomposedValue}
- */
-const decomposeTweenValue = (tween, targetObject) => {
- targetObject.t = tween._valueType;
- targetObject.n = tween._toNumber;
- targetObject.u = tween._unit;
- targetObject.o = null;
- targetObject.d = cloneArray(tween._toNumbers);
- targetObject.s = cloneArray(tween._strings);
- return targetObject;
-};
-const decomposedOriginalValue = createDecomposedValueTargetObject();
-
-
-const lookups = {
- /** @type {TweenReplaceLookups} */
- _rep: new WeakMap(),
- /** @type {TweenAdditiveLookups} */
- _add: new Map(),
-};
-/**
- * @param {Target} target
- * @param {String} property
- * @param {String} lookup
- * @return {TweenPropertySiblings}
- */
-const getTweenSiblings = (target, property, lookup = '_rep') => {
- const lookupMap = lookups[lookup];
- let targetLookup = lookupMap.get(target);
- if (!targetLookup) {
- targetLookup = {};
- lookupMap.set(target, targetLookup);
- }
- return targetLookup[property] ? targetLookup[property] : targetLookup[property] = {
- _head: null,
- _tail: null,
- };
-};
-/**
- * @param {Tween} p
- * @param {Tween} c
- * @return {Number|Boolean}
- */
-const addTweenSortMethod = (p, c) => {
- return p._isOverridden || p._absoluteStartTime > c._absoluteStartTime;
-};
-/**
- * @param {Tween} tween
- */
-const overrideTween = tween => {
- tween._isOverlapped = 1;
- tween._isOverridden = 1;
- tween._changeDuration = minValue;
- tween._currentTime = minValue;
-};
-/**
- * @param {Tween} tween
- * @param {TweenPropertySiblings} siblings
- * @return {Tween}
- */
-const composeTween = (tween, siblings) => {
- const tweenCompositionType = tween._composition;
- // Handle replaced tweens
- if (tweenCompositionType === compositionTypes.replace) {
- const tweenAbsStartTime = tween._absoluteStartTime;
- addChild(siblings, tween, addTweenSortMethod, '_prevRep', '_nextRep');
- const prevSibling = tween._prevRep;
- // Update the previous siblings for composition replace tweens
- if (prevSibling) {
- const prevParent = prevSibling.parent;
- const prevAbsEndTime = prevSibling._absoluteStartTime + prevSibling._changeDuration;
- // Handle looped animations tween
- if (
- // Check if the previous tween is from a different animation
- tween.parent.id !== prevParent.id &&
- // Check if the animation has loops
- prevParent.iterationCount > 1 &&
- // Check if _absoluteChangeEndTime of last loop overlaps the current tween
- prevAbsEndTime + (prevParent.duration - prevParent.iterationDuration) > tweenAbsStartTime) {
- // TODO: Find a way to only override the iterations overlapping with the tween
- overrideTween(prevSibling);
- let prevPrevSibling = prevSibling._prevRep;
- // If the tween was part of a set of keyframes, override its siblings
- while (prevPrevSibling && prevPrevSibling.parent.id === prevParent.id) {
- overrideTween(prevPrevSibling);
- prevPrevSibling = prevPrevSibling._prevRep;
- }
- }
- const absoluteUpdateStartTime = tweenAbsStartTime - tween._delay;
- if (prevAbsEndTime > absoluteUpdateStartTime) {
- const prevChangeStartTime = prevSibling._startTime;
- const prevTLOffset = prevAbsEndTime - (prevChangeStartTime + prevSibling._updateDuration);
- // Rounding is necessary here to minimize floating point errors when working in seconds
- const updatedPrevChangeDuration = round(absoluteUpdateStartTime - prevTLOffset - prevChangeStartTime, 12);
- prevSibling._changeDuration = updatedPrevChangeDuration;
- prevSibling._currentTime = updatedPrevChangeDuration;
- prevSibling._isOverlapped = 1;
- // Override the previous tween if its new _changeDuration is lower than minValue
- // TODO: See if it's even neceseeary to test against minValue, checking for 0 might be enough
- if (updatedPrevChangeDuration < minValue) {
- overrideTween(prevSibling);
- }
- }
- // Pause (and cancel) the parent if it only contains overlapped tweens
- let pausePrevParentAnimation = true;
- forEachChildren(prevParent, (/** @type Tween */ t) => {
- if (!t._isOverlapped)
- pausePrevParentAnimation = false;
- });
- if (pausePrevParentAnimation) {
- const prevParentTL = prevParent.parent;
- if (prevParentTL) {
- let pausePrevParentTL = true;
- forEachChildren(prevParentTL, (/** @type JSAnimation */ a) => {
- if (a !== prevParent) {
- forEachChildren(a, (/** @type Tween */ t) => {
- if (!t._isOverlapped)
- pausePrevParentTL = false;
- });
- }
- });
- if (pausePrevParentTL) {
- prevParentTL.cancel();
- }
- }
- else {
- prevParent.cancel();
- // Previously, calling .cancel() on a timeline child would affect the render order of other children
- // Worked around this by marking it as .completed and using .pause() for safe removal in the engine loop
- // This is no longer needed since timeline tween composition is now handled separately
- // Keeping this here for reference
- // prevParent.completed = true;
- // prevParent.pause();
- }
- }
- }
- // let nextSibling = tween._nextRep;
- // // All the next siblings are automatically overridden
- // if (nextSibling && nextSibling._absoluteStartTime >= tweenAbsStartTime) {
- // while (nextSibling) {
- // overrideTween(nextSibling);
- // nextSibling = nextSibling._nextRep;
- // }
- // }
- // if (nextSibling && nextSibling._absoluteStartTime < tweenAbsStartTime) {
- // while (nextSibling) {
- // overrideTween(nextSibling);
- // console.log(tween.id, nextSibling.id);
- // nextSibling = nextSibling._nextRep;
- // }
- // }
- // Handle additive tweens composition
- }
- else if (tweenCompositionType === compositionTypes.blend) {
- const additiveTweenSiblings = getTweenSiblings(tween.target, tween.property, '_add');
- const additiveAnimation = addAdditiveAnimation(lookups._add);
- let lookupTween = additiveTweenSiblings._head;
- if (!lookupTween) {
- lookupTween = { ...tween };
- lookupTween._composition = compositionTypes.replace;
- lookupTween._updateDuration = minValue;
- lookupTween._startTime = 0;
- lookupTween._numbers = cloneArray(tween._fromNumbers);
- lookupTween._number = 0;
- lookupTween._next = null;
- lookupTween._prev = null;
- addChild(additiveTweenSiblings, lookupTween);
- addChild(additiveAnimation, lookupTween);
- }
- // Convert the values of TO to FROM and set TO to 0
- const toNumber = tween._toNumber;
- tween._fromNumber = lookupTween._fromNumber - toNumber;
- tween._toNumber = 0;
- tween._numbers = cloneArray(tween._fromNumbers);
- tween._number = 0;
- lookupTween._fromNumber = toNumber;
- if (tween._toNumbers) {
- const toNumbers = cloneArray(tween._toNumbers);
- if (toNumbers) {
- toNumbers.forEach((value, i) => {
- tween._fromNumbers[i] = lookupTween._fromNumbers[i] - value;
- tween._toNumbers[i] = 0;
- });
- }
- lookupTween._fromNumbers = toNumbers;
- }
- addChild(additiveTweenSiblings, tween, null, '_prevAdd', '_nextAdd');
- }
- return tween;
-};
-/**
- * @param {Tween} tween
- * @return {Tween}
- */
-const removeTweenSliblings = tween => {
- const tweenComposition = tween._composition;
- if (tweenComposition !== compositionTypes.none) {
- const tweenTarget = tween.target;
- const tweenProperty = tween.property;
- const replaceTweensLookup = lookups._rep;
- const replaceTargetProps = replaceTweensLookup.get(tweenTarget);
- const tweenReplaceSiblings = replaceTargetProps[tweenProperty];
- removeChild(tweenReplaceSiblings, tween, '_prevRep', '_nextRep');
- if (tweenComposition === compositionTypes.blend) {
- const addTweensLookup = lookups._add;
- const addTargetProps = addTweensLookup.get(tweenTarget);
- if (!addTargetProps)
- return;
- const additiveTweenSiblings = addTargetProps[tweenProperty];
- const additiveAnimation = additive.animation;
- removeChild(additiveTweenSiblings, tween, '_prevAdd', '_nextAdd');
- // If only one tween is left in the additive lookup, it's the tween lookup
- const lookupTween = additiveTweenSiblings._head;
- if (lookupTween && lookupTween === additiveTweenSiblings._tail) {
- removeChild(additiveTweenSiblings, lookupTween, '_prevAdd', '_nextAdd');
- removeChild(additiveAnimation, lookupTween);
- let shouldClean = true;
- for (let prop in addTargetProps) {
- if (addTargetProps[prop]._head) {
- shouldClean = false;
- break;
- }
- }
- if (shouldClean) {
- addTweensLookup.delete(tweenTarget);
- }
- }
- }
- }
- return tween;
-};
-
-
-/**
- * @param {Timer} timer
- * @return {Timer}
- */
-const resetTimerProperties = timer => {
- timer.paused = true;
- timer.began = false;
- timer.completed = false;
- return timer;
-};
-/**
- * @param {Timer} timer
- * @return {Timer}
- */
-const reviveTimer = timer => {
- if (!timer._cancelled)
- return timer;
- if (timer._hasChildren) {
- forEachChildren(timer, reviveTimer);
- }
- else {
- forEachChildren(timer, (/** @type {Tween} tween*/ tween) => {
- if (tween._composition !== compositionTypes.none) {
- composeTween(tween, getTweenSiblings(tween.target, tween.property));
- }
- });
- }
- timer._cancelled = 0;
- return timer;
-};
-let timerId = 0;
-/**
- * Base class used to create Timers, Animations and Timelines
- */
-class Timer extends Clock {
- /**
- * @param {TimerParams} [parameters]
- * @param {Timeline} [parent]
- * @param {Number} [parentPosition]
- */
- constructor(parameters = {}, parent = null, parentPosition = 0) {
- super(0);
- const { id, delay, duration, reversed, alternate, loop, loopDelay, autoplay, frameRate, playbackRate, onComplete, onLoop, onPause, onBegin, onBeforeUpdate, onUpdate, } = parameters;
- if (scope.current)
- scope.current.register(this);
- const timerInitTime = parent ? 0 : engine._elapsedTime;
- const timerDefaults = parent ? parent.defaults : globals.defaults;
- const timerDelay = /** @type {Number} */ (isFnc(delay) || isUnd(delay) ? timerDefaults.delay : +delay);
- const timerDuration = isFnc(duration) || isUnd(duration) ? Infinity : +duration;
- const timerLoop = setValue(loop, timerDefaults.loop);
- const timerLoopDelay = setValue(loopDelay, timerDefaults.loopDelay);
- const timerIterationCount = timerLoop === true ||
- timerLoop === Infinity ||
- /** @type {Number} */ (timerLoop) < 0 ? Infinity :
- /** @type {Number} */ (timerLoop) + 1;
- let offsetPosition = 0;
- if (parent) {
- offsetPosition = parentPosition;
- }
- else {
- // Make sure to tick the engine once if not currently running to get up to date engine._elapsedTime
- // to avoid big gaps with the following offsetPosition calculation
- if (!engine.reqId)
- engine.requestTick(now());
- // Make sure to scale the offset position with globals.timeScale to properly handle seconds unit
- offsetPosition = (engine._elapsedTime - engine._startTime) * globals.timeScale;
- }
- // Timer's parameters
- this.id = !isUnd(id) ? id : ++timerId;
- /** @type {Timeline} */
- this.parent = parent;
- // Total duration of the timer
- this.duration = clampInfinity(((timerDuration + timerLoopDelay) * timerIterationCount) - timerLoopDelay) || minValue;
- /** @type {Boolean} */
- this.backwards = false;
- /** @type {Boolean} */
- this.paused = true;
- /** @type {Boolean} */
- this.began = false;
- /** @type {Boolean} */
- this.completed = false;
- /** @type {Callback<this>} */
- this.onBegin = onBegin || timerDefaults.onBegin;
- /** @type {Callback<this>} */
- this.onBeforeUpdate = onBeforeUpdate || timerDefaults.onBeforeUpdate;
- /** @type {Callback<this>} */
- this.onUpdate = onUpdate || timerDefaults.onUpdate;
- /** @type {Callback<this>} */
- this.onLoop = onLoop || timerDefaults.onLoop;
- /** @type {Callback<this>} */
- this.onPause = onPause || timerDefaults.onPause;
- /** @type {Callback<this>} */
- this.onComplete = onComplete || timerDefaults.onComplete;
- /** @type {Number} */
- this.iterationDuration = timerDuration; // Duration of one loop
- /** @type {Number} */
- this.iterationCount = timerIterationCount; // Number of loops
- /** @type {Boolean|ScrollObserver} */
- this._autoplay = parent ? false : setValue(autoplay, timerDefaults.autoplay);
- /** @type {Number} */
- this._offset = offsetPosition;
- /** @type {Number} */
- this._delay = timerDelay;
- /** @type {Number} */
- this._loopDelay = timerLoopDelay;
- /** @type {Number} */
- this._iterationTime = 0;
- /** @type {Number} */
- this._currentIteration = 0; // Current loop index
- /** @type {Function} */
- this._resolve = noop; // Used by .then()
- /** @type {Boolean} */
- this._running = false;
- /** @type {Number} */
- this._reversed = +setValue(reversed, timerDefaults.reversed);
- /** @type {Number} */
- this._reverse = this._reversed;
- /** @type {Number} */
- this._cancelled = 0;
- /** @type {Boolean} */
- this._alternate = setValue(alternate, timerDefaults.alternate);
- /** @type {Renderable} */
- this._prev = null;
- /** @type {Renderable} */
- this._next = null;
- // Clock's parameters
- /** @type {Number} */
- this._elapsedTime = timerInitTime;
- /** @type {Number} */
- this._startTime = timerInitTime;
- /** @type {Number} */
- this._lastTime = timerInitTime;
- /** @type {Number} */
- this._fps = setValue(frameRate, timerDefaults.frameRate);
- /** @type {Number} */
- this._speed = setValue(playbackRate, timerDefaults.playbackRate);
- }
- get cancelled() {
- return !!this._cancelled;
- }
- /** @param {Boolean} cancelled */
- set cancelled(cancelled) {
- cancelled ? this.cancel() : this.reset(1).play();
- }
- get currentTime() {
- return clamp(round(this._currentTime, globals.precision), -this._delay, this.duration);
- }
- /** @param {Number} time */
- set currentTime(time) {
- const paused = this.paused;
- // Pausing the timer is necessary to avoid time jumps on a running instance
- this.pause().seek(+time);
- if (!paused)
- this.resume();
- }
- get iterationCurrentTime() {
- return round(this._iterationTime, globals.precision);
- }
- /** @param {Number} time */
- set iterationCurrentTime(time) {
- this.currentTime = (this.iterationDuration * this._currentIteration) + time;
- }
- get progress() {
- return clamp(round(this._currentTime / this.duration, 10), 0, 1);
- }
- /** @param {Number} progress */
- set progress(progress) {
- this.currentTime = this.duration * progress;
- }
- get iterationProgress() {
- return clamp(round(this._iterationTime / this.iterationDuration, 10), 0, 1);
- }
- /** @param {Number} progress */
- set iterationProgress(progress) {
- const iterationDuration = this.iterationDuration;
- this.currentTime = (iterationDuration * this._currentIteration) + (iterationDuration * progress);
- }
- get currentIteration() {
- return this._currentIteration;
- }
- /** @param {Number} iterationCount */
- set currentIteration(iterationCount) {
- this.currentTime = (this.iterationDuration * clamp(+iterationCount, 0, this.iterationCount - 1));
- }
- get reversed() {
- return !!this._reversed;
- }
- /** @param {Boolean} reverse */
- set reversed(reverse) {
- reverse ? this.reverse() : this.play();
- }
- get speed() {
- return super.speed;
- }
- /** @param {Number} playbackRate */
- set speed(playbackRate) {
- super.speed = playbackRate;
- this.resetTime();
- }
- /**
- * @param {Number} internalRender
- * @return {this}
- */
- reset(internalRender = 0) {
- // If cancelled, revive the timer before rendering in order to have propertly composed tweens siblings
- reviveTimer(this);
- if (this._reversed && !this._reverse)
- this.reversed = false;
- // Rendering before updating the completed flag to prevent skips and to make sure the properties are not overridden
- // Setting the iterationTime at the end to force the rendering to happend backwards, otherwise calling .reset() on Timelines might not render children in the right order
- // NOTE: This is only required for Timelines and might be better to move to the Timeline class?
- this._iterationTime = this.iterationDuration;
- // Set tickMode to tickModes.FORCE to force rendering
- tick(this, 0, 1, internalRender, tickModes.FORCE);
- // Reset timer properties after revive / render to make sure the props are not updated again
- resetTimerProperties(this);
- // Also reset children properties
- if (this._hasChildren) {
- forEachChildren(this, resetTimerProperties);
- }
- return this;
- }
- /**
- * @param {Number} internalRender
- * @return {this}
- */
- init(internalRender = 0) {
- this.fps = this._fps;
- this.speed = this._speed;
- // Manually calling .init() on timelines should render all children intial state
- // Forces all children to render once then render to 0 when reseted
- if (!internalRender && this._hasChildren) {
- tick(this, this.duration, 1, internalRender, tickModes.FORCE);
- }
- this.reset(internalRender);
- // Make sure to set autoplay to false to child timers so it doesn't attempt to autoplay / link
- const autoplay = this._autoplay;
- if (autoplay === true) {
- this.resume();
- }
- else if (autoplay && !isUnd(/** @type {ScrollObserver} */ (autoplay).linked)) {
- /** @type {ScrollObserver} */ (autoplay).link(this);
- }
- return this;
- }
- /** @return {this} */
- resetTime() {
- const timeScale = 1 / (this._speed * engine._speed);
- // TODO: See if we can safely use engine._elapsedTime here
- // if (!engine.reqId) engine.requestTick(now())
- // this._startTime = engine._elapsedTime - (this._currentTime + this._delay) * timeScale;
- this._startTime = now() - (this._currentTime + this._delay) * timeScale;
- return this;
- }
- /** @return {this} */
- pause() {
- if (this.paused)
- return this;
- this.paused = true;
- this.onPause(this);
- return this;
- }
- /** @return {this} */
- resume() {
- if (!this.paused)
- return this;
- this.paused = false;
- // We can safely imediatly render a timer that has no duration and no children
- if (this.duration <= minValue && !this._hasChildren) {
- tick(this, minValue, 0, 0, tickModes.FORCE);
- }
- else {
- if (!this._running) {
- addChild(engine, this);
- engine._hasChildren = true;
- this._running = true;
- }
- this.resetTime();
- // Forces the timer to advance by at least one frame when the next tick occurs
- this._startTime -= 12;
- engine.wake();
- }
- return this;
- }
- /** @return {this} */
- restart() {
- return this.reset(0).resume();
- }
- /**
- * @param {Number} time
- * @param {Boolean|Number} [muteCallbacks]
- * @param {Boolean|Number} [internalRender]
- * @return {this}
- */
- seek(time, muteCallbacks = 0, internalRender = 0) {
- // Recompose the tween siblings in case the timer has been cancelled
- reviveTimer(this);
- // If you seek a completed animation, otherwise the next play will starts at 0
- this.completed = false;
- const isPaused = this.paused;
- this.paused = true;
- // timer, time, muteCallbacks, internalRender, tickMode
- tick(this, time + this._delay, ~~muteCallbacks, ~~internalRender, tickModes.AUTO);
- return isPaused ? this : this.resume();
- }
- /** @return {this} */
- alternate() {
- const reversed = this._reversed;
- const count = this.iterationCount;
- const duration = this.iterationDuration;
- // Calculate the maximum iterations possible given the iteration duration
- const iterations = count === Infinity ? floor(maxValue / duration) : count;
- this._reversed = +(this._alternate && !(iterations % 2) ? reversed : !reversed);
- if (count === Infinity) {
- // Handle infinite loops to loop on themself
- this.iterationProgress = this._reversed ? 1 - this.iterationProgress : this.iterationProgress;
- }
- else {
- this.seek((duration * iterations) - this._currentTime);
- }
- this.resetTime();
- return this;
- }
- /** @return {this} */
- play() {
- if (this._reversed)
- this.alternate();
- return this.resume();
- }
- /** @return {this} */
- reverse() {
- if (!this._reversed)
- this.alternate();
- return this.resume();
- }
- // TODO: Move all the animation / tweens / children related code to Animation / Timeline
- /** @return {this} */
- cancel() {
- if (this._hasChildren) {
- forEachChildren(this, (/** @type {Renderable} */ child) => child.cancel(), true);
- }
- else {
- forEachChildren(this, removeTweenSliblings);
- }
- this._cancelled = 1;
- // Pausing the timer removes it from the engine
- return this.pause();
- }
- /**
- * @param {Number} newDuration
- * @return {this}
- */
- stretch(newDuration) {
- const currentDuration = this.duration;
- const normlizedDuration = normalizeTime(newDuration);
- if (currentDuration === normlizedDuration)
- return this;
- const timeScale = newDuration / currentDuration;
- const isSetter = newDuration <= minValue;
- this.duration = isSetter ? minValue : normlizedDuration;
- this.iterationDuration = isSetter ? minValue : normalizeTime(this.iterationDuration * timeScale);
- this._offset *= timeScale;
- this._delay *= timeScale;
- this._loopDelay *= timeScale;
- return this;
- }
- /**
- * Cancels the timer by seeking it back to 0 and reverting the attached scroller if necessary
- * @return {this}
- */
- revert() {
- tick(this, 0, 1, 0, tickModes.AUTO);
- const ap = /** @type {ScrollObserver} */ (this._autoplay);
- if (ap && ap.linked && ap.linked === this)
- ap.revert();
- return this.cancel();
- }
- /**
- * Imediatly completes the timer, cancels it and triggers the onComplete callback
- * @return {this}
- */
- complete() {
- return this.seek(this.duration).cancel();
- }
- /**
- * @param {Callback<this>} [callback]
- * @return {Promise}
- */
- then(callback = noop) {
- const then = this.then;
- const onResolve = () => {
- // this.then = null prevents infinite recursion if returned by an async function
- // https://github.com/juliangarnierorg/anime-beta/issues/26
- this.then = null;
- callback(this);
- this.then = then;
- this._resolve = noop;
- };
- return new Promise(r => {
- this._resolve = () => r(onResolve());
- // Make sure to resolve imediatly if the timer has already completed
- if (this.completed)
- this._resolve();
- return this;
- });
- }
-}
-/**
- * @param {TimerParams} [parameters]
- * @return {Timer}
- */
-const createTimer = parameters => new Timer(parameters, null, 0).init();
-
-
-/** @type {EasingFunction} */
-const none = t => t;
-// Cubic Bezier solver adapted from https://github.com/gre/bezier-ease © Gaëtan Renaudeau
-/**
- * @param {Number} aT
- * @param {Number} aA1
- * @param {Number} aA2
- * @return {Number}
- */
-const calcBezier = (aT, aA1, aA2) => (((1 - 3 * aA2 + 3 * aA1) * aT + (3 * aA2 - 6 * aA1)) * aT + (3 * aA1)) * aT;
-/**
- * @param {Number} aX
- * @param {Number} mX1
- * @param {Number} mX2
- * @return {Number}
- */
-const binarySubdivide = (aX, mX1, mX2) => {
- let aA = 0, aB = 1, currentX, currentT, i = 0;
- do {
- currentT = aA + (aB - aA) / 2;
- currentX = calcBezier(currentT, mX1, mX2) - aX;
- if (currentX > 0) {
- aB = currentT;
- }
- else {
- aA = currentT;
- }
- } while (abs(currentX) > .0000001 && ++i < 100);
- return currentT;
-};
-/**
- * @param {Number} [mX1] The x coordinate of the first point
- * @param {Number} [mY1] The y coordinate of the first point
- * @param {Number} [mX2] The x coordinate of the second point
- * @param {Number} [mY2] The y coordinate of the second point
- * @return {EasingFunction}
- */
-const cubicBezier = (mX1 = 0.5, mY1 = 0.0, mX2 = 0.5, mY2 = 1.0) => (mX1 === mY1 && mX2 === mY2) ? none :
- t => t === 0 || t === 1 ? t :
- calcBezier(binarySubdivide(t, mX1, mX2), mY1, mY2);
-/**
- * Steps ease implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
- * Only covers 'end' and 'start' jumpterms
- * @param {Number} steps
- * @param {Boolean} [fromStart]
- * @return {EasingFunction}
- */
-const steps = (steps = 10, fromStart) => {
- const roundMethod = fromStart ? ceil : floor;
- return t => roundMethod(clamp(t, 0, 1) * steps) * (1 / steps);
-};
-/**
- * Without parameters, the linear function creates a non-eased transition.
- * Parameters, if used, creates a piecewise linear easing by interpolating linearly between the specified points.
- * @param {...(String|Number)} args - Points
- * @return {EasingFunction}
- */
-const linear = (...args) => {
- const argsLength = args.length;
- if (!argsLength)
- return none;
- const totalPoints = argsLength - 1;
- const firstArg = args[0];
- const lastArg = args[totalPoints];
- const xPoints = [0];
- const yPoints = [parseNumber(firstArg)];
- for (let i = 1; i < totalPoints; i++) {
- const arg = args[i];
- const splitValue = isStr(arg) ?
- /** @type {String} */ (arg).trim().split(' ') :
- [arg];
- const value = splitValue[0];
- const percent = splitValue[1];
- xPoints.push(!isUnd(percent) ? parseNumber(percent) / 100 : i / totalPoints);
- yPoints.push(parseNumber(value));
- }
- yPoints.push(parseNumber(lastArg));
- xPoints.push(1);
- return function easeLinear(t) {
- for (let i = 1, l = xPoints.length; i < l; i++) {
- const currentX = xPoints[i];
- if (t <= currentX) {
- const prevX = xPoints[i - 1];
- const prevY = yPoints[i - 1];
- return prevY + (yPoints[i] - prevY) * (t - prevX) / (currentX - prevX);
- }
- }
- return yPoints[yPoints.length - 1];
- };
-};
-/**
- * Generate random steps
- * @param {Number} [length] - The number of steps
- * @param {Number} [randomness] - How strong the randomness is
- * @return {EasingFunction}
- */
-const irregular = (length = 10, randomness = 1) => {
- const values = [0];
- const total = length - 1;
- for (let i = 1; i < total; i++) {
- const previousValue = values[i - 1];
- const spacing = i / total;
- const segmentEnd = (i + 1) / total;
- const randomVariation = spacing + (segmentEnd - spacing) * Math.random();
- // Mix the even spacing and random variation based on the randomness parameter
- const randomValue = spacing * (1 - randomness) + randomVariation * randomness;
- values.push(clamp(randomValue, previousValue, 1));
- }
- values.push(1);
- return linear(...values);
-};
-// Easing functions adapted from http://www.robertpenner.com/ease © Robert Penner
-/**
- * @callback PowerEasing
- * @param {Number|String} [power=1.675]
- * @return {EasingFunction}
- */
-/**
- * @callback BackEasing
- * @param {Number|String} [overshoot=1.70158]
- * @return {EasingFunction}
- */
-/**
- * @callback ElasticEasing
- * @param {Number|String} [amplitude=1]
- * @param {Number|String} [period=.3]
- * @return {EasingFunction}
- */
-/**
- * @callback EaseFactory
- * @param {Number|String} [paramA]
- * @param {Number|String} [paramB]
- * @return {EasingFunction|Number}
- */
-/** @typedef {PowerEasing|BackEasing|ElasticEasing} EasesFactory */
-const halfPI = PI / 2;
-const doublePI = PI * 2;
-/** @type {PowerEasing} */
-const easeInPower = (p = 1.68) => t => pow(t, +p);
-/** @type {Record<String, EasesFactory|EasingFunction>} */
-const easeInFunctions = {
- [emptyString]: easeInPower,
- Quad: easeInPower(2),
- Cubic: easeInPower(3),
- Quart: easeInPower(4),
- Quint: easeInPower(5),
- /** @type {EasingFunction} */
- Sine: t => 1 - cos(t * halfPI),
- /** @type {EasingFunction} */
- Circ: t => 1 - sqrt(1 - t * t),
- /** @type {EasingFunction} */
- Expo: t => t ? pow(2, 10 * t - 10) : 0,
- /** @type {EasingFunction} */
- Bounce: t => {
- let pow2, b = 4;
- while (t < ((pow2 = pow(2, --b)) - 1) / 11)
- ;
- return 1 / pow(4, 3 - b) - 7.5625 * pow((pow2 * 3 - 2) / 22 - t, 2);
- },
- /** @type {BackEasing} */
- Back: (overshoot = 1.70158) => t => (+overshoot + 1) * t * t * t - +overshoot * t * t,
- /** @type {ElasticEasing} */
- Elastic: (amplitude = 1, period = .3) => {
- const a = clamp(+amplitude, 1, 10);
- const p = clamp(+period, minValue, 2);
- const s = (p / doublePI) * asin(1 / a);
- const e = doublePI / p;
- return t => t === 0 || t === 1 ? t : -a * pow(2, -10 * (1 - t)) * sin(((1 - t) - s) * e);
- }
-};
-/**
- * @callback EaseType
- * @param {EasingFunction} Ease
- * @return {EasingFunction}
- */
-/** @type {Record<String, EaseType>} */
-const easeTypes = {
- in: easeIn => t => easeIn(t),
- out: easeIn => t => 1 - easeIn(1 - t),
- inOut: easeIn => t => t < .5 ? easeIn(t * 2) / 2 : 1 - easeIn(t * -2 + 2) / 2,
- outIn: easeIn => t => t < .5 ? (1 - easeIn(1 - t * 2)) / 2 : (easeIn(t * 2 - 1) + 1) / 2,
-};
-/**
- * @param {String} string
- * @param {Record<String, EasesFactory|EasingFunction>} easesFunctions
- * @param {Object} easesLookups
- * @return {EasingFunction}
- */
-const parseEaseString = (string, easesFunctions, easesLookups) => {
- if (easesLookups[string])
- return easesLookups[string];
- if (string.indexOf('(') <= -1) {
- const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
- const parsedFn = /** @type {EasingFunction} */ (hasParams ? /** @type {EasesFactory} */ (easesFunctions[string])() : easesFunctions[string]);
- return parsedFn ? easesLookups[string] = parsedFn : none;
- }
- else {
- const split = string.slice(0, -1).split('(');
- const parsedFn = /** @type {EasesFactory} */ (easesFunctions[split[0]]);
- return parsedFn ? easesLookups[string] = parsedFn(...split[1].split(',')) : none;
- }
-};
-/**
- * @typedef {Object} EasesFunctions
- * @property {typeof linear} linear
- * @property {typeof irregular} irregular
- * @property {typeof steps} steps
- * @property {typeof cubicBezier} cubicBezier
- * @property {PowerEasing} in
- * @property {PowerEasing} out
- * @property {PowerEasing} inOut
- * @property {PowerEasing} outIn
- * @property {EasingFunction} inQuad
- * @property {EasingFunction} outQuad
- * @property {EasingFunction} inOutQuad
- * @property {EasingFunction} outInQuad
- * @property {EasingFunction} inCubic
- * @property {EasingFunction} outCubic
- * @property {EasingFunction} inOutCubic
- * @property {EasingFunction} outInCubic
- * @property {EasingFunction} inQuart
- * @property {EasingFunction} outQuart
- * @property {EasingFunction} inOutQuart
- * @property {EasingFunction} outInQuart
- * @property {EasingFunction} inQuint
- * @property {EasingFunction} outQuint
- * @property {EasingFunction} inOutQuint
- * @property {EasingFunction} outInQuint
- * @property {EasingFunction} inSine
- * @property {EasingFunction} outSine
- * @property {EasingFunction} inOutSine
- * @property {EasingFunction} outInSine
- * @property {EasingFunction} inCirc
- * @property {EasingFunction} outCirc
- * @property {EasingFunction} inOutCirc
- * @property {EasingFunction} outInCirc
- * @property {EasingFunction} inExpo
- * @property {EasingFunction} outExpo
- * @property {EasingFunction} inOutExpo
- * @property {EasingFunction} outInExpo
- * @property {EasingFunction} inBounce
- * @property {EasingFunction} outBounce
- * @property {EasingFunction} inOutBounce
- * @property {EasingFunction} outInBounce
- * @property {BackEasing} inBack
- * @property {BackEasing} outBack
- * @property {BackEasing} inOutBack
- * @property {BackEasing} outInBack
- * @property {ElasticEasing} inElastic
- * @property {ElasticEasing} outElastic
- * @property {ElasticEasing} inOutElastic
- * @property {ElasticEasing} outInElastic
- */
-const eases = ( /*#__PURE__*/(() => {
- const list = { linear, irregular, steps, cubicBezier };
- for (let type in easeTypes) {
- for (let name in easeInFunctions) {
- const easeIn = easeInFunctions[name];
- const easeType = easeTypes[type];
- list[type + name] = /** @type {EasesFactory|EasingFunction} */ (name === emptyString || name === 'Back' || name === 'Elastic' ?
- (a, b) => easeType(/** @type {EasesFactory} */ (easeIn)(a, b)) :
- easeType(/** @type {EasingFunction} */ (easeIn)));
- }
- }
- return /** @type {EasesFunctions} */ (list);
-})());
-/** @type {Record<String, EasingFunction>} */
-const JSEasesLookups = { linear: none };
-/**
- * @param {EasingParam} ease
- * @return {EasingFunction}
- */
-const parseEasings = ease => isFnc(ease) ? ease :
- isStr(ease) ? parseEaseString(/** @type {String} */ (ease), eases, JSEasesLookups) :
- none;
-
-
-const propertyNamesCache = {};
-/**
- * @param {String} propertyName
- * @param {Target} target
- * @param {tweenTypes} tweenType
- * @return {String}
- */
-const sanitizePropertyName = (propertyName, target, tweenType) => {
- if (tweenType === tweenTypes.TRANSFORM) {
- const t = shortTransforms.get(propertyName);
- return t ? t : propertyName;
- }
- else if (tweenType === tweenTypes.CSS ||
- // Handle special cases where properties like "strokeDashoffset" needs to be set as "stroke-dashoffset"
- // but properties like "baseFrequency" should stay in lowerCamelCase
- (tweenType === tweenTypes.ATTRIBUTE && (isSvg(target) && propertyName in /** @type {DOMTarget} */ (target).style))) {
- const cachedPropertyName = propertyNamesCache[propertyName];
- if (cachedPropertyName) {
- return cachedPropertyName;
- }
- else {
- const lowerCaseName = propertyName ? toLowerCase(propertyName) : propertyName;
- propertyNamesCache[propertyName] = lowerCaseName;
- return lowerCaseName;
- }
- }
- else {
- return propertyName;
- }
-};
-
-
-const angleUnitsMap = { 'deg': 1, 'rad': 180 / PI, 'turn': 360 };
-const convertedValuesCache = {};
-/**
- * @param {DOMTarget} el
- * @param {TweenDecomposedValue} decomposedValue
- * @param {String} unit
- * @param {Boolean} [force]
- * @return {TweenDecomposedValue}
- */
-const convertValueUnit = (el, decomposedValue, unit, force = false) => {
- const currentUnit = decomposedValue.u;
- const currentNumber = decomposedValue.n;
- if (decomposedValue.t === valueTypes.UNIT && currentUnit === unit) { // TODO: Check if checking against the same unit string is necessary
- return decomposedValue;
- }
- const cachedKey = currentNumber + currentUnit + unit;
- const cached = convertedValuesCache[cachedKey];
- if (!isUnd(cached) && !force) {
- decomposedValue.n = cached;
- }
- else {
- let convertedValue;
- if (currentUnit in angleUnitsMap) {
- convertedValue = currentNumber * angleUnitsMap[currentUnit] / angleUnitsMap[unit];
- }
- else {
- const baseline = 100;
- const tempEl = /** @type {DOMTarget} */ (el.cloneNode());
- const parentNode = el.parentNode;
- const parentEl = (parentNode && (parentNode !== doc)) ? parentNode : doc.body;
- parentEl.appendChild(tempEl);
- const elStyle = tempEl.style;
- elStyle.width = baseline + currentUnit;
- const currentUnitWidth = /** @type {HTMLElement} */ (tempEl).offsetWidth || baseline;
- elStyle.width = baseline + unit;
- const newUnitWidth = /** @type {HTMLElement} */ (tempEl).offsetWidth || baseline;
- const factor = currentUnitWidth / newUnitWidth;
- parentEl.removeChild(tempEl);
- convertedValue = factor * currentNumber;
- }
- decomposedValue.n = convertedValue;
- convertedValuesCache[cachedKey] = convertedValue;
- }
- decomposedValue.t === valueTypes.UNIT;
- decomposedValue.u = unit;
- return decomposedValue;
-};
-
-
-/**
- * @template {Renderable} T
- * @param {T} renderable
- * @return {T}
- */
-const cleanInlineStyles = renderable => {
- // Allow cleanInlineStyles() to be called on timelines
- if (renderable._hasChildren) {
- forEachChildren(renderable, cleanInlineStyles, true);
- }
- else {
- const animation = /** @type {JSAnimation} */ (renderable);
- animation.pause();
- forEachChildren(animation, (/** @type {Tween} */ tween) => {
- const tweenProperty = tween.property;
- const tweenTarget = tween.target;
- if (tweenTarget[isDomSymbol]) {
- const targetStyle = /** @type {DOMTarget} */ (tweenTarget).style;
- const originalInlinedValue = animation._inlineStyles[tweenProperty];
- if (tween._tweenType === tweenTypes.TRANSFORM) {
- const cachedTransforms = tweenTarget[transformsSymbol];
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
- delete cachedTransforms[tweenProperty];
- }
- else {
- cachedTransforms[tweenProperty] = originalInlinedValue;
- }
- if (tween._renderTransforms) {
- if (!Object.keys(cachedTransforms).length) {
- targetStyle.removeProperty('transform');
- }
- else {
- let str = emptyString;
- for (let key in cachedTransforms) {
- str += transformsFragmentStrings[key] + cachedTransforms[key] + ') ';
- }
- targetStyle.transform = str;
- }
- }
- }
- else {
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
- targetStyle.removeProperty(tweenProperty);
- }
- else {
- targetStyle[tweenProperty] = originalInlinedValue;
- }
- }
- if (animation._tail === tween) {
- animation.targets.forEach(t => {
- if (t.getAttribute && t.getAttribute('style') === emptyString) {
- t.removeAttribute('style');
- }
- });
- }
- }
- });
- }
- return renderable;
-};
-// Defines decomposed values target objects only once and mutate their properties later to avoid GC
-// TODO: Maybe move the objects creation to values.js and use the decompose function to create the base object
-const fromTargetObject = createDecomposedValueTargetObject();
-const toTargetObject = createDecomposedValueTargetObject();
-const toFunctionStore = { func: null };
-const keyframesTargetArray = [null];
-const fastSetValuesArray = [null, null];
-/** @type {TweenKeyValue} */
-const keyObjectTarget = { to: null };
-let tweenId = 0;
-let keyframes;
-/** @type {TweenParamsOptions & TweenValues} */
-let key;
-/**
- * @param {DurationKeyframes | PercentageKeyframes} keyframes
- * @param {AnimationParams} parameters
- * @return {AnimationParams}
- */
-const generateKeyframes = (keyframes, parameters) => {
- /** @type {AnimationParams} */
- const properties = {};
- if (isArr(keyframes)) {
- const propertyNames = [].concat(... /** @type {DurationKeyframes} */(keyframes).map(key => Object.keys(key))).filter(isKey);
- for (let i = 0, l = propertyNames.length; i < l; i++) {
- const propName = propertyNames[i];
- const propArray = /** @type {DurationKeyframes} */ (keyframes).map(key => {
- /** @type {TweenKeyValue} */
- const newKey = {};
- for (let p in key) {
- const keyValue = /** @type {TweenPropValue} */ (key[p]);
- if (isKey(p)) {
- if (p === propName) {
- newKey.to = keyValue;
- }
- }
- else {
- newKey[p] = keyValue;
- }
- }
- return newKey;
- });
- properties[propName] = /** @type {ArraySyntaxValue} */ (propArray);
- }
- }
- else {
- const totalDuration = /** @type {Number} */ (setValue(parameters.duration, globals.defaults.duration));
- const keys = Object.keys(keyframes)
- .map(key => { return { o: parseFloat(key) / 100, p: keyframes[key] }; })
- .sort((a, b) => a.o - b.o);
- keys.forEach(key => {
- const offset = key.o;
- const prop = key.p;
- for (let name in prop) {
- if (isKey(name)) {
- let propArray = /** @type {Array} */ (properties[name]);
- if (!propArray)
- propArray = properties[name] = [];
- const duration = offset * totalDuration;
- let length = propArray.length;
- let prevKey = propArray[length - 1];
- const keyObj = { to: prop[name] };
- let durProgress = 0;
- for (let i = 0; i < length; i++) {
- durProgress += propArray[i].duration;
- }
- if (length === 1) {
- keyObj.from = prevKey.to;
- }
- if (prop.ease) {
- keyObj.ease = prop.ease;
- }
- keyObj.duration = duration - (length ? durProgress : 0);
- propArray.push(keyObj);
- }
- }
- return key;
- });
- for (let name in properties) {
- const propArray = /** @type {Array} */ (properties[name]);
- let prevEase;
- // let durProgress = 0
- for (let i = 0, l = propArray.length; i < l; i++) {
- const prop = propArray[i];
- // Emulate WAPPI easing parameter position
- const currentEase = prop.ease;
- prop.ease = prevEase ? prevEase : undefined;
- prevEase = currentEase;
- // durProgress += prop.duration;
- // if (i === l - 1 && durProgress !== totalDuration) {
- // propArray.push({ from: prop.to, ease: prop.ease, duration: totalDuration - durProgress })
- // }
- }
- if (!propArray[0].duration) {
- propArray.shift();
- }
- }
- }
- return properties;
-};
-class JSAnimation extends Timer {
- /**
- * @param {TargetsParam} targets
- * @param {AnimationParams} parameters
- * @param {Timeline} [parent]
- * @param {Number} [parentPosition]
- * @param {Boolean} [fastSet=false]
- * @param {Number} [index=0]
- * @param {Number} [length=0]
- */
- constructor(targets, parameters, parent, parentPosition, fastSet = false, index = 0, length = 0) {
- super(/** @type {TimerParams&AnimationParams} */ (parameters), parent, parentPosition);
- const parsedTargets = registerTargets(targets);
- const targetsLength = parsedTargets.length;
- // If the parameters object contains a "keyframes" property, convert all the keyframes values to regular properties
- const kfParams = /** @type {AnimationParams} */ (parameters).keyframes;
- const params = /** @type {AnimationParams} */ (kfParams ? mergeObjects(generateKeyframes(/** @type {DurationKeyframes} */ (kfParams), parameters), parameters) : parameters);
- const { delay, duration, ease, playbackEase, modifier, composition, onRender, } = params;
- const animDefaults = parent ? parent.defaults : globals.defaults;
- const animaPlaybackEase = setValue(playbackEase, animDefaults.playbackEase);
- const animEase = animaPlaybackEase ? parseEasings(animaPlaybackEase) : null;
- const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */ (ease).ease);
- const tEasing = hasSpring ? /** @type {Spring} */ (ease).ease : setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */ (ease).duration : setValue(duration, animDefaults.duration);
- const tDelay = setValue(delay, animDefaults.delay);
- const tModifier = modifier || animDefaults.modifier;
- // If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
- const tComposition = isUnd(composition) && targetsLength >= K ? compositionTypes.none : !isUnd(composition) ? composition : animDefaults.composition;
- // TODO: Do not create an empty object until we know the animation will generate inline styles
- const animInlineStyles = {};
- // const absoluteOffsetTime = this._offset;
- const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
- let iterationDuration = NaN;
- let iterationDelay = NaN;
- let animationAnimationLength = 0;
- let shouldTriggerRender = 0;
- for (let targetIndex = 0; targetIndex < targetsLength; targetIndex++) {
- const target = parsedTargets[targetIndex];
- const ti = index || targetIndex;
- const tl = length || targetsLength;
- let lastTransformGroupIndex = NaN;
- let lastTransformGroupLength = NaN;
- for (let p in params) {
- if (isKey(p)) {
- const tweenType = getTweenType(target, p);
- const propName = sanitizePropertyName(p, target, tweenType);
- let propValue = params[p];
- const isPropValueArray = isArr(propValue);
- if (fastSet && !isPropValueArray) {
- fastSetValuesArray[0] = propValue;
- fastSetValuesArray[1] = propValue;
- propValue = fastSetValuesArray;
- }
- // TODO: Allow nested keyframes inside ObjectValue value (prop: { to: [.5, 1, .75, 2, 3] })
- // Normalize property values to valid keyframe syntax:
- // [x, y] to [{to: [x, y]}] or {to: x} to [{to: x}] or keep keys syntax [{}, {}, {}...]
- // const keyframes = isArr(propValue) ? propValue.length === 2 && !isObj(propValue[0]) ? [{ to: propValue }] : propValue : [propValue];
- if (isPropValueArray) {
- const arrayLength = /** @type {Array} */ (propValue).length;
- const isNotObjectValue = !isObj(propValue[0]);
- // Convert [x, y] to [{to: [x, y]}]
- if (arrayLength === 2 && isNotObjectValue) {
- keyObjectTarget.to = /** @type {TweenParamValue} */ ( /** @type {unknown} */(propValue));
- keyframesTargetArray[0] = keyObjectTarget;
- keyframes = keyframesTargetArray;
- // Convert [x, y, z] to [[x, y], z]
- }
- else if (arrayLength > 2 && isNotObjectValue) {
- keyframes = [];
- /** @type {Array.<Number>} */ (propValue).forEach((v, i) => {
- if (!i) {
- fastSetValuesArray[0] = v;
- }
- else if (i === 1) {
- fastSetValuesArray[1] = v;
- keyframes.push(fastSetValuesArray);
- }
- else {
- keyframes.push(v);
- }
- });
- }
- else {
- keyframes = /** @type {Array.<TweenKeyValue>} */ (propValue);
- }
- }
- else {
- keyframesTargetArray[0] = propValue;
- keyframes = keyframesTargetArray;
- }
- let siblings = null;
- let prevTween = null;
- let firstTweenChangeStartTime = NaN;
- let lastTweenChangeEndTime = 0;
- let tweenIndex = 0;
- for (let l = keyframes.length; tweenIndex < l; tweenIndex++) {
- const keyframe = keyframes[tweenIndex];
- if (isObj(keyframe)) {
- key = keyframe;
- }
- else {
- keyObjectTarget.to = /** @type {TweenParamValue} */ (keyframe);
- key = keyObjectTarget;
- }
- toFunctionStore.func = null;
- const computedToValue = getFunctionValue(key.to, target, ti, tl, toFunctionStore);
- let tweenToValue;
- // Allows function based values to return an object syntax value ({to: v})
- if (isObj(computedToValue) && !isUnd(computedToValue.to)) {
- key = computedToValue;
- tweenToValue = computedToValue.to;
- }
- else {
- tweenToValue = computedToValue;
- }
- const tweenFromValue = getFunctionValue(key.from, target, ti, tl);
- const keyEasing = key.ease;
- const hasSpring = !isUnd(keyEasing) && !isUnd(/** @type {Spring} */ (keyEasing).ease);
- // Easing are treated differently and don't accept function based value to prevent having to pass a function wrapper that returns an other function all the time
- const tweenEasing = hasSpring ? /** @type {Spring} */ (keyEasing).ease : keyEasing || tEasing;
- // Calculate default individual keyframe duration by dividing the tl of keyframes
- const tweenDuration = hasSpring ? /** @type {Spring} */ (keyEasing).duration : getFunctionValue(setValue(key.duration, (l > 1 ? getFunctionValue(tDuration, target, ti, tl) / l : tDuration)), target, ti, tl);
- // Default delay value should only be applied to the first tween
- const tweenDelay = getFunctionValue(setValue(key.delay, (!tweenIndex ? tDelay : 0)), target, ti, tl);
- const computedComposition = getFunctionValue(setValue(key.composition, tComposition), target, ti, tl);
- const tweenComposition = isNum(computedComposition) ? computedComposition : compositionTypes[computedComposition];
- // Modifiers are treated differently and don't accept function based value to prevent having to pass a function wrapper
- const tweenModifier = key.modifier || tModifier;
- const hasFromvalue = !isUnd(tweenFromValue);
- const hasToValue = !isUnd(tweenToValue);
- const isFromToArray = isArr(tweenToValue);
- const isFromToValue = isFromToArray || (hasFromvalue && hasToValue);
- const tweenStartTime = prevTween ? lastTweenChangeEndTime + tweenDelay : tweenDelay;
- // Rounding is necessary here to minimize floating point errors when working in seconds
- const absoluteStartTime = round(absoluteOffsetTime + tweenStartTime, 12);
- // Force a onRender callback if the animation contains at least one from value and autoplay is set to false
- if (!shouldTriggerRender && (hasFromvalue || isFromToArray))
- shouldTriggerRender = 1;
- let prevSibling = prevTween;
- if (tweenComposition !== compositionTypes.none) {
- if (!siblings)
- siblings = getTweenSiblings(target, propName);
- let nextSibling = siblings._head;
- // Iterate trough all the next siblings until we find a sibling with an equal or inferior start time
- while (nextSibling && !nextSibling._isOverridden && nextSibling._absoluteStartTime <= absoluteStartTime) {
- prevSibling = nextSibling;
- nextSibling = nextSibling._nextRep;
- // Overrides all the next siblings if the next sibling starts at the same time of after as the new tween start time
- if (nextSibling && nextSibling._absoluteStartTime >= absoluteStartTime) {
- while (nextSibling) {
- overrideTween(nextSibling);
- // This will ends both the current while loop and the upper one once all the next sibllings have been overriden
- nextSibling = nextSibling._nextRep;
- }
- }
- }
- }
- // Decompose values
- if (isFromToValue) {
- decomposeRawValue(isFromToArray ? getFunctionValue(tweenToValue[0], target, ti, tl) : tweenFromValue, fromTargetObject);
- decomposeRawValue(isFromToArray ? getFunctionValue(tweenToValue[1], target, ti, tl, toFunctionStore) : tweenToValue, toTargetObject);
- if (fromTargetObject.t === valueTypes.NUMBER) {
- if (prevSibling) {
- if (prevSibling._valueType === valueTypes.UNIT) {
- fromTargetObject.t = valueTypes.UNIT;
- fromTargetObject.u = prevSibling._unit;
- }
- }
- else {
- decomposeRawValue(getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), decomposedOriginalValue);
- if (decomposedOriginalValue.t === valueTypes.UNIT) {
- fromTargetObject.t = valueTypes.UNIT;
- fromTargetObject.u = decomposedOriginalValue.u;
- }
- }
- }
- }
- else {
- if (hasToValue) {
- decomposeRawValue(tweenToValue, toTargetObject);
- }
- else {
- if (prevTween) {
- decomposeTweenValue(prevTween, toTargetObject);
- }
- else {
- // No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
- decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), toTargetObject);
- }
- }
- if (hasFromvalue) {
- decomposeRawValue(tweenFromValue, fromTargetObject);
- }
- else {
- if (prevTween) {
- decomposeTweenValue(prevTween, fromTargetObject);
- }
- else {
- decomposeRawValue(parent && prevSibling && prevSibling.parent.parent === parent ? prevSibling._value :
- // No need to get and parse the original value if the tween is part of a timeline and has a previous sibling part of the same timeline
- getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), fromTargetObject);
- }
- }
- }
- // Apply operators
- if (fromTargetObject.o) {
- fromTargetObject.n = getRelativeValue(!prevSibling ? decomposeRawValue(getOriginalAnimatableValue(target, propName, tweenType, animInlineStyles), decomposedOriginalValue).n : prevSibling._toNumber, fromTargetObject.n, fromTargetObject.o);
- }
- if (toTargetObject.o) {
- toTargetObject.n = getRelativeValue(fromTargetObject.n, toTargetObject.n, toTargetObject.o);
- }
- // Values omogenisation in cases of type difference between "from" and "to"
- if (fromTargetObject.t !== toTargetObject.t) {
- if (fromTargetObject.t === valueTypes.COMPLEX || toTargetObject.t === valueTypes.COMPLEX) {
- const complexValue = fromTargetObject.t === valueTypes.COMPLEX ? fromTargetObject : toTargetObject;
- const notComplexValue = fromTargetObject.t === valueTypes.COMPLEX ? toTargetObject : fromTargetObject;
- notComplexValue.t = valueTypes.COMPLEX;
- notComplexValue.s = cloneArray(complexValue.s);
- notComplexValue.d = complexValue.d.map(() => notComplexValue.n);
- }
- else if (fromTargetObject.t === valueTypes.UNIT || toTargetObject.t === valueTypes.UNIT) {
- const unitValue = fromTargetObject.t === valueTypes.UNIT ? fromTargetObject : toTargetObject;
- const notUnitValue = fromTargetObject.t === valueTypes.UNIT ? toTargetObject : fromTargetObject;
- notUnitValue.t = valueTypes.UNIT;
- notUnitValue.u = unitValue.u;
- }
- else if (fromTargetObject.t === valueTypes.COLOR || toTargetObject.t === valueTypes.COLOR) {
- const colorValue = fromTargetObject.t === valueTypes.COLOR ? fromTargetObject : toTargetObject;
- const notColorValue = fromTargetObject.t === valueTypes.COLOR ? toTargetObject : fromTargetObject;
- notColorValue.t = valueTypes.COLOR;
- notColorValue.s = colorValue.s;
- notColorValue.d = [0, 0, 0, 1];
- }
- }
- // Unit conversion
- if (fromTargetObject.u !== toTargetObject.u) {
- let valueToConvert = toTargetObject.u ? fromTargetObject : toTargetObject;
- valueToConvert = convertValueUnit(/** @type {DOMTarget} */ (target), valueToConvert, toTargetObject.u ? toTargetObject.u : fromTargetObject.u, false);
- // TODO:
- // convertValueUnit(target, to.u ? from : to, to.u ? to.u : from.u);
- }
- // Fill in non existing complex values
- if (toTargetObject.d && fromTargetObject.d && (toTargetObject.d.length !== fromTargetObject.d.length)) {
- const longestValue = fromTargetObject.d.length > toTargetObject.d.length ? fromTargetObject : toTargetObject;
- const shortestValue = longestValue === fromTargetObject ? toTargetObject : fromTargetObject;
- // TODO: Check if n should be used instead of 0 for default complex values
- shortestValue.d = longestValue.d.map((_, i) => isUnd(shortestValue.d[i]) ? 0 : shortestValue.d[i]);
- shortestValue.s = cloneArray(longestValue.s);
- }
- // Tween factory
- // Rounding is necessary here to minimize floating point errors when working in seconds
- const tweenUpdateDuration = round(+tweenDuration || minValue, 12);
- /** @type {Tween} */
- const tween = {
- parent: this,
- id: tweenId++,
- property: propName,
- target: target,
- _value: null,
- _func: toFunctionStore.func,
- _ease: parseEasings(tweenEasing),
- _fromNumbers: cloneArray(fromTargetObject.d),
- _toNumbers: cloneArray(toTargetObject.d),
- _strings: cloneArray(toTargetObject.s),
- _fromNumber: fromTargetObject.n,
- _toNumber: toTargetObject.n,
- _numbers: cloneArray(fromTargetObject.d),
- _number: fromTargetObject.n,
- _unit: toTargetObject.u,
- _modifier: tweenModifier,
- _currentTime: 0,
- _startTime: tweenStartTime,
- _delay: +tweenDelay,
- _updateDuration: tweenUpdateDuration,
- _changeDuration: tweenUpdateDuration,
- _absoluteStartTime: absoluteStartTime,
- // NOTE: Investigate bit packing to stores ENUM / BOOL
- _tweenType: tweenType,
- _valueType: toTargetObject.t,
- _composition: tweenComposition,
- _isOverlapped: 0,
- _isOverridden: 0,
- _renderTransforms: 0,
- _prevRep: null,
- _nextRep: null,
- _prevAdd: null,
- _nextAdd: null,
- _prev: null,
- _next: null,
- };
- if (tweenComposition !== compositionTypes.none) {
- composeTween(tween, siblings);
- }
- if (isNaN(firstTweenChangeStartTime)) {
- firstTweenChangeStartTime = tween._startTime;
- }
- // Rounding is necessary here to minimize floating point errors when working in seconds
- lastTweenChangeEndTime = round(tweenStartTime + tweenUpdateDuration, 12);
- prevTween = tween;
- animationAnimationLength++;
- addChild(this, tween);
- }
- // Update animation timings with the added tweens properties
- if (isNaN(iterationDelay) || firstTweenChangeStartTime < iterationDelay) {
- iterationDelay = firstTweenChangeStartTime;
- }
- if (isNaN(iterationDuration) || lastTweenChangeEndTime > iterationDuration) {
- iterationDuration = lastTweenChangeEndTime;
- }
- // TODO: Find a way to inline tween._renderTransforms = 1 here
- if (tweenType === tweenTypes.TRANSFORM) {
- lastTransformGroupIndex = animationAnimationLength - tweenIndex;
- lastTransformGroupLength = animationAnimationLength;
- }
- }
- }
- // Set _renderTransforms to last transform property to correctly render the transforms list
- if (!isNaN(lastTransformGroupIndex)) {
- let i = 0;
- forEachChildren(this, (/** @type {Tween} */ tween) => {
- if (i >= lastTransformGroupIndex && i < lastTransformGroupLength) {
- tween._renderTransforms = 1;
- if (tween._composition === compositionTypes.blend) {
- forEachChildren(additive.animation, (/** @type {Tween} */ additiveTween) => {
- if (additiveTween.id === tween.id) {
- additiveTween._renderTransforms = 1;
- }
- });
- }
- }
- i++;
- });
- }
- }
- if (!targetsLength) {
- console.warn(`No target found. Make sure the element you're trying to animate is accessible before creating your animation.`);
- }
- if (iterationDelay) {
- forEachChildren(this, (/** @type {Tween} */ tween) => {
- // If (startTime - delay) equals 0, this means the tween is at the begining of the animation so we need to trim the delay too
- if (!(tween._startTime - tween._delay)) {
- tween._delay -= iterationDelay;
- }
- tween._startTime -= iterationDelay;
- });
- iterationDuration -= iterationDelay;
- }
- else {
- iterationDelay = 0;
- }
- // Prevents iterationDuration to be NaN if no valid animatable props have been provided
- // Prevents _iterationCount to be NaN if no valid animatable props have been provided
- if (!iterationDuration) {
- iterationDuration = minValue;
- this.iterationCount = 0;
- }
- /** @type {TargetsArray} */
- this.targets = parsedTargets;
- /** @type {Number} */
- this.duration = iterationDuration === minValue ? minValue : clampInfinity(((iterationDuration + this._loopDelay) * this.iterationCount) - this._loopDelay) || minValue;
- /** @type {Callback<this>} */
- this.onRender = onRender || animDefaults.onRender;
- /** @type {EasingFunction} */
- this._ease = animEase;
- /** @type {Number} */
- this._delay = iterationDelay;
- // NOTE: I'm keeping delay values separated from offsets in timelines because delays can override previous tweens and it could be confusing to debug a timeline with overridden tweens and no associated visible delays.
- // this._delay = parent ? 0 : iterationDelay;
- // this._offset += parent ? iterationDelay : 0;
- /** @type {Number} */
- this.iterationDuration = iterationDuration;
- /** @type {{}} */
- this._inlineStyles = animInlineStyles;
- if (!this._autoplay && shouldTriggerRender)
- this.onRender(this);
- }
- /**
- * @param {Number} newDuration
- * @return {this}
- */
- stretch(newDuration) {
- const currentDuration = this.duration;
- if (currentDuration === normalizeTime(newDuration))
- return this;
- const timeScale = newDuration / currentDuration;
- // NOTE: Find a better way to handle the stretch of an animation after stretch = 0
- forEachChildren(this, (/** @type {Tween} */ tween) => {
- // Rounding is necessary here to minimize floating point errors
- tween._updateDuration = normalizeTime(tween._updateDuration * timeScale);
- tween._changeDuration = normalizeTime(tween._changeDuration * timeScale);
- tween._currentTime *= timeScale;
- tween._startTime *= timeScale;
- tween._absoluteStartTime *= timeScale;
- });
- return super.stretch(newDuration);
- }
- /**
- * @return {this}
- */
- refresh() {
- forEachChildren(this, (/** @type {Tween} */ tween) => {
- const tweenFunc = tween._func;
- if (tweenFunc) {
- const ogValue = getOriginalAnimatableValue(tween.target, tween.property, tween._tweenType);
- decomposeRawValue(ogValue, decomposedOriginalValue);
- decomposeRawValue(tweenFunc(), toTargetObject);
- tween._fromNumbers = cloneArray(decomposedOriginalValue.d);
- tween._fromNumber = decomposedOriginalValue.n;
- tween._toNumbers = cloneArray(toTargetObject.d);
- tween._strings = cloneArray(toTargetObject.s);
- // Make sure to apply relative operators https://github.com/juliangarnier/anime/issues/1025
- tween._toNumber = toTargetObject.o ? getRelativeValue(decomposedOriginalValue.n, toTargetObject.n, toTargetObject.o) : toTargetObject.n;
- }
- });
- return this;
- }
- /**
- * Cancel the animation and revert all the values affected by this animation to their original state
- * @return {this}
- */
- revert() {
- super.revert();
- return cleanInlineStyles(this);
- }
- /**
- * @param {Callback<this>} [callback]
- * @return {Promise}
- */
- then(callback) {
- return super.then(callback);
- }
-}
-/**
- * @param {TargetsParam} targets
- * @param {AnimationParams} parameters
- * @return {JSAnimation}
- */
-const animate = (targets, parameters) => new JSAnimation(targets, parameters, null, 0, false).init();
-
-
-/**
- * Converts an easing function into a valid CSS linear() timing function string
- * @param {EasingFunction} fn
- * @param {number} [samples=100]
- * @returns {string} CSS linear() timing function
- */
-const easingToLinear = (fn, samples = 100) => {
- const points = [];
- for (let i = 0; i <= samples; i++)
- points.push(fn(i / samples));
- return `linear(${points.join(', ')})`;
-};
-const WAAPIEasesLookups = {
- in: 'ease-in',
- out: 'ease-out',
- inOut: 'ease-in-out',
-};
-const WAAPIeases = /*#__PURE__*/ (() => {
- const list = {};
- for (let type in easeTypes)
- list[type] = (/** @type {String|Number} */ p) => easeTypes[type](easeInPower(p));
- return /** @type {Record<String, EasingFunction>} */ (list);
-})();
-/**
- * @param {EasingParam} ease
- * @return {String}
- */
-const parseWAAPIEasing = (ease) => {
- let parsedEase = WAAPIEasesLookups[ease];
- if (parsedEase)
- return parsedEase;
- parsedEase = 'linear';
- if (isStr(ease)) {
- if (stringStartsWith(ease, 'linear') ||
- stringStartsWith(ease, 'cubic-') ||
- stringStartsWith(ease, 'steps') ||
- stringStartsWith(ease, 'ease')) {
- parsedEase = ease;
- }
- else if (stringStartsWith(ease, 'cubicB')) {
- parsedEase = toLowerCase(ease);
- }
- else {
- const parsed = parseEaseString(ease, WAAPIeases, WAAPIEasesLookups);
- if (isFnc(parsed))
- parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
- }
- WAAPIEasesLookups[ease] = parsedEase;
- }
- else if (isFnc(ease)) {
- const easing = easingToLinear(ease);
- if (easing)
- parsedEase = easing;
- }
- else if ( /** @type {Spring} */(ease).ease) {
- parsedEase = easingToLinear(/** @type {Spring} */ (ease).ease);
- }
- return parsedEase;
-};
-const transformsShorthands = ['x', 'y', 'z'];
-const commonDefaultPXProperties = [
- 'perspective',
- 'width',
- 'height',
- 'margin',
- 'padding',
- 'top',
- 'right',
- 'bottom',
- 'left',
- 'borderWidth',
- 'fontSize',
- 'borderRadius',
- ...transformsShorthands
-];
-const validIndividualTransforms = /*#__PURE__*/ (() => [...transformsShorthands, ...validTransforms.filter(t => ['X', 'Y', 'Z'].some(axis => t.endsWith(axis)))])();
-let transformsPropertiesRegistered = null;
-const WAAPIAnimationsLookups = {
- _head: null,
- _tail: null,
-};
-/**
- * @param {DOMTarget} $el
- * @param {String} [property]
- * @param {WAAPIAnimation} [parent]
- */
-const removeWAAPIAnimation = ($el, property, parent) => {
- let nextLookup = WAAPIAnimationsLookups._head;
- while (nextLookup) {
- const next = nextLookup._next;
- const matchTarget = nextLookup.$el === $el;
- const matchProperty = !property || nextLookup.property === property;
- const matchParent = !parent || nextLookup.parent === parent;
- if (matchTarget && matchProperty && matchParent) {
- const anim = nextLookup.animation;
- try {
- anim.commitStyles();
- }
- catch { }
- anim.cancel();
- removeChild(WAAPIAnimationsLookups, nextLookup);
- const lookupParent = nextLookup.parent;
- if (lookupParent) {
- lookupParent._completed++;
- if (lookupParent.animations.length === lookupParent._completed) {
- lookupParent.completed = true;
- if (!lookupParent.muteCallbacks) {
- lookupParent.paused = true;
- lookupParent.onComplete(lookupParent);
- lookupParent._resolve(lookupParent);
- }
- }
- }
- }
- nextLookup = next;
- }
-};
-/**
- * @param {WAAPIAnimation} parent
- * @param {DOMTarget} $el
- * @param {String} property
- * @param {PropertyIndexedKeyframes} keyframes
- * @param {KeyframeAnimationOptions} params
- * @retun {Animation}
- */
-const addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
- const animation = $el.animate(keyframes, params);
- const animTotalDuration = params.delay + (+params.duration * params.iterations);
- animation.playbackRate = parent._speed;
- if (parent.paused)
- animation.pause();
- if (parent.duration < animTotalDuration) {
- parent.duration = animTotalDuration;
- parent.controlAnimation = animation;
- }
- parent.animations.push(animation);
- removeWAAPIAnimation($el, property);
- addChild(WAAPIAnimationsLookups, { parent, animation, $el, property, _next: null, _prev: null });
- const handleRemove = () => { removeWAAPIAnimation($el, property, parent); };
- animation.onremove = handleRemove;
- animation.onfinish = handleRemove;
- return animation;
-};
-/**
- * @param {String} propName
- * @param {WAAPIKeyframeValue} value
- * @param {DOMTarget} $el
- * @param {Number} i
- * @param {Number} targetsLength
- * @return {String}
- */
-const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
- let v = getFunctionValue(/** @type {any} */ (value), $el, i, targetsLength);
- if (!isNum(v))
- return v;
- if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate'))
- return `${v}px`;
- if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew'))
- return `${v}deg`;
- return `${v}`;
-};
-/**
- * @param {DOMTarget} $el
- * @param {String} propName
- * @param {WAAPIKeyframeValue} from
- * @param {WAAPIKeyframeValue} to
- * @param {Number} i
- * @param {Number} targetsLength
- * @return {WAAPITweenValue}
- */
-const parseIndividualTweenValue = ($el, propName, from, to, i, targetsLength) => {
- /** @type {WAAPITweenValue} */
- let tweenValue = '0';
- const computedTo = !isUnd(to) ? normalizeTweenValue(propName, to, $el, i, targetsLength) : getComputedStyle($el)[propName];
- if (!isUnd(from)) {
- const computedFrom = normalizeTweenValue(propName, from, $el, i, targetsLength);
- tweenValue = [computedFrom, computedTo];
- }
- else {
- tweenValue = isArr(to) ? to.map((/** @type {any} */ v) => normalizeTweenValue(propName, v, $el, i, targetsLength)) : computedTo;
- }
- return tweenValue;
-};
-class WAAPIAnimation {
- /**
- * @param {DOMTargetsParam} targets
- * @param {WAAPIAnimationParams} params
- */
- constructor(targets, params) {
- if (scope.current)
- scope.current.register(this);
- // Skip the registration and fallback to no animation in case CSS.registerProperty is not supported
- if (isNil(transformsPropertiesRegistered)) {
- if (isBrowser && (isUnd(CSS) || !Object.hasOwnProperty.call(CSS, 'registerProperty'))) {
- transformsPropertiesRegistered = false;
- }
- else {
- validTransforms.forEach(t => {
- const isSkew = stringStartsWith(t, 'skew');
- const isScale = stringStartsWith(t, 'scale');
- const isRotate = stringStartsWith(t, 'rotate');
- const isTranslate = stringStartsWith(t, 'translate');
- const isAngle = isRotate || isSkew;
- const syntax = isAngle ? '<angle>' : isScale ? "<number>" : isTranslate ? "<length-percentage>" : "*";
- try {
- CSS.registerProperty({
- name: '--' + t,
- syntax,
- inherits: false,
- initialValue: isTranslate ? '0px' : isAngle ? '0deg' : isScale ? '1' : '0',
- });
- }
- catch { }
- });
- transformsPropertiesRegistered = true;
- }
- }
- const parsedTargets = registerTargets(targets);
- const targetsLength = parsedTargets.length;
- if (!targetsLength) {
- console.warn(`No target found. Make sure the element you're trying to animate is accessible before creating your animation.`);
- }
- const ease = setValue(params.ease, parseWAAPIEasing(globals.defaults.ease));
- const spring = /** @type {Spring} */ (ease).ease && ease;
- const autoplay = setValue(params.autoplay, globals.defaults.autoplay);
- const scroll = autoplay && /** @type {ScrollObserver} */ (autoplay).link ? autoplay : false;
- const alternate = params.alternate && /** @type {Boolean} */ (params.alternate) === true;
- const reversed = params.reversed && /** @type {Boolean} */ (params.reversed) === true;
- const loop = setValue(params.loop, globals.defaults.loop);
- const iterations = /** @type {Number} */ ((loop === true || loop === Infinity) ? Infinity : isNum(loop) ? loop + 1 : 1);
- /** @type {PlaybackDirection} */
- const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
- /** @type {FillMode} */
- const fill = 'forwards';
- /** @type {String} */
- const easing = parseWAAPIEasing(ease);
- const timeScale = (globals.timeScale === 1 ? 1 : K);
- /** @type {DOMTargetsArray}] */
- this.targets = parsedTargets;
- /** @type {Array<globalThis.Animation>}] */
- this.animations = [];
- /** @type {globalThis.Animation}] */
- this.controlAnimation = null;
- /** @type {Callback<this>} */
- this.onComplete = params.onComplete || noop;
- /** @type {Number} */
- this.duration = 0;
- /** @type {Boolean} */
- this.muteCallbacks = false;
- /** @type {Boolean} */
- this.completed = false;
- /** @type {Boolean} */
- this.paused = !autoplay || scroll !== false;
- /** @type {Boolean} */
- this.reversed = reversed;
- /** @type {Boolean|ScrollObserver} */
- this.autoplay = autoplay;
- /** @type {Number} */
- this._speed = setValue(params.playbackRate, globals.defaults.playbackRate);
- /** @type {Function} */
- this._resolve = noop; // Used by .then()
- /** @type {Number} */
- this._completed = 0;
- /** @type {Array<Object>}] */
- this._inlineStyles = parsedTargets.map($el => $el.getAttribute('style'));
- parsedTargets.forEach(($el, i) => {
- const cachedTransforms = $el[transformsSymbol];
- const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
- /** @type {Number} */
- const duration = (spring ? /** @type {Spring} */ (spring).duration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
- /** @type {Number} */
- const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
- /** @type {CompositeOperation} */
- const composite = /** @type {CompositeOperation} */ (setValue(params.composition, 'replace'));
- for (let name in params) {
- if (!isKey(name))
- continue;
- /** @type {PropertyIndexedKeyframes} */
- const keyframes = {};
- /** @type {KeyframeAnimationOptions} */
- const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
- const propertyValue = params[name];
- const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
- let parsedPropertyValue;
- if (isObj(propertyValue)) {
- const tweenOptions = /** @type {WAAPITweenOptions} */ (propertyValue);
- const tweenOptionsEase = setValue(tweenOptions.ease, ease);
- const tweenOptionsSpring = /** @type {Spring} */ (tweenOptionsEase).ease && tweenOptionsEase;
- const to = /** @type {WAAPITweenOptions} */ (tweenOptions).to;
- const from = /** @type {WAAPITweenOptions} */ (tweenOptions).from;
- /** @type {Number} */
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */ (tweenOptionsSpring).duration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
- /** @type {Number} */
- tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
- /** @type {CompositeOperation} */
- tweenParams.composite = /** @type {CompositeOperation} */ (setValue(tweenOptions.composition, composite));
- /** @type {String} */
- tweenParams.easing = parseWAAPIEasing(tweenOptionsEase);
- parsedPropertyValue = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
- if (individualTransformProperty) {
- keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
- cachedTransforms[individualTransformProperty] = parsedPropertyValue;
- }
- else {
- keyframes[name] = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
- }
- addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
- if (!isUnd(from)) {
- if (!individualTransformProperty) {
- $el.style[name] = keyframes[name][0];
- }
- else {
- const key = `--${individualTransformProperty}`;
- $el.style.setProperty(key, keyframes[key][0]);
- }
- }
- }
- else {
- parsedPropertyValue = isArr(propertyValue) ?
- propertyValue.map((/** @type {any} */ v) => normalizeTweenValue(name, v, $el, i, targetsLength)) :
- normalizeTweenValue(name, /** @type {any} */ (propertyValue), $el, i, targetsLength);
- if (individualTransformProperty) {
- keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
- cachedTransforms[individualTransformProperty] = parsedPropertyValue;
- }
- else {
- keyframes[name] = parsedPropertyValue;
- }
- addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
- }
- }
- if (hasIndividualTransforms) {
- let transforms = emptyString;
- for (let t in cachedTransforms) {
- transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
- }
- $el.style.transform = transforms;
- }
- });
- if (scroll) {
- /** @type {ScrollObserver} */ (this.autoplay).link(this);
- }
- }
- /**
- * @callback forEachCallback
- * @param {globalThis.Animation} animation
- */
- /**
- * @param {forEachCallback|String} callback
- * @return {this}
- */
- forEach(callback) {
- const cb = isStr(callback) ? (/** @type {globalThis.Animation} */ a) => a[callback]() : callback;
- this.animations.forEach(cb);
- return this;
- }
- get speed() {
- return this._speed;
- }
- /** @param {Number} speed */
- set speed(speed) {
- this._speed = +speed;
- this.forEach(anim => anim.playbackRate = speed);
- }
- get currentTime() {
- const controlAnimation = this.controlAnimation;
- const timeScale = globals.timeScale;
- return this.completed ? this.duration : controlAnimation ? +controlAnimation.currentTime * (timeScale === 1 ? 1 : timeScale) : 0;
- }
- /** @param {Number} time */
- set currentTime(time) {
- const t = time * (globals.timeScale === 1 ? 1 : K);
- this.forEach(anim => {
- // Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
- // The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
- // https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
- if (t >= this.duration)
- anim.play();
- anim.currentTime = t;
- });
- }
- get progress() {
- return this.currentTime / this.duration;
- }
- /** @param {Number} progress */
- set progress(progress) {
- this.forEach(anim => anim.currentTime = progress * this.duration || 0);
- }
- resume() {
- if (!this.paused)
- return this;
- this.paused = false;
- // TODO: Store the current time, and seek back to the last position
- return this.forEach('play');
- }
- pause() {
- if (this.paused)
- return this;
- this.paused = true;
- return this.forEach('pause');
- }
- alternate() {
- this.reversed = !this.reversed;
- this.forEach('reverse');
- if (this.paused)
- this.forEach('pause');
- return this;
- }
- play() {
- if (this.reversed)
- this.alternate();
- return this.resume();
- }
- reverse() {
- if (!this.reversed)
- this.alternate();
- return this.resume();
- }
- /**
- * @param {Number} time
- * @param {Boolean} muteCallbacks
- */
- seek(time, muteCallbacks = false) {
- if (muteCallbacks)
- this.muteCallbacks = true;
- if (time < this.duration)
- this.completed = false;
- this.currentTime = time;
- this.muteCallbacks = false;
- if (this.paused)
- this.pause();
- return this;
- }
- restart() {
- this.completed = false;
- return this.seek(0, true).resume();
- }
- commitStyles() {
- return this.forEach('commitStyles');
- }
- complete() {
- return this.seek(this.duration);
- }
- cancel() {
- this.forEach('cancel');
- return this.pause();
- }
- revert() {
- this.cancel();
- this.targets.forEach(($el, i) => $el.setAttribute('style', this._inlineStyles[i]));
- return this;
- }
- /**
- * @param {WAAPICallback} [callback]
- * @return {Promise}
- */
- then(callback = noop) {
- const then = this.then;
- const onResolve = () => {
- this.then = null;
- callback(this);
- this.then = then;
- this._resolve = noop;
- };
- return new Promise(r => {
- this._resolve = () => r(onResolve());
- if (this.completed)
- this._resolve();
- return this;
- });
- }
-}
-const waapi = {
- /**
- * @param {DOMTargetsParam} targets
- * @param {WAAPIAnimationParams} params
- * @return {WAAPIAnimation}
- */
- animate: (targets, params) => new WAAPIAnimation(targets, params),
- convertEase: easingToLinear
-};
-
-
-/**
- * @param {Callback<Timer>} [callback]
- * @return {Timer}
- */
-const sync = (callback = noop) => {
- return new Timer({ duration: 1 * globals.timeScale, onComplete: callback }, null, 0).resume();
-};
-/**
- * @overload
- * @param {DOMTargetSelector} targetSelector
- * @param {String} propName
- * @return {String}
- *
- * @overload
- * @param {JSTargetsParam} targetSelector
- * @param {String} propName
- * @return {Number|String}
- *
- * @overload
- * @param {DOMTargetsParam} targetSelector
- * @param {String} propName
- * @param {String} unit
- * @return {String}
- *
- * @overload
- * @param {TargetsParam} targetSelector
- * @param {String} propName
- * @param {Boolean} unit
- * @return {Number}
- *
- * @param {TargetsParam} targetSelector
- * @param {String} propName
- * @param {String|Boolean} [unit]
- */
-function getTargetValue(targetSelector, propName, unit) {
- const targets = registerTargets(targetSelector);
- if (!targets.length)
- return;
- const [target] = targets;
- const tweenType = getTweenType(target, propName);
- const normalizePropName = sanitizePropertyName(propName, target, tweenType);
- let originalValue = getOriginalAnimatableValue(target, normalizePropName);
- if (isUnd(unit)) {
- return originalValue;
- }
- else {
- decomposeRawValue(originalValue, decomposedOriginalValue);
- if (decomposedOriginalValue.t === valueTypes.NUMBER || decomposedOriginalValue.t === valueTypes.UNIT) {
- if (unit === false) {
- return decomposedOriginalValue.n;
- }
- else {
- const convertedValue = convertValueUnit(/** @type {DOMTarget} */ (target), decomposedOriginalValue, /** @type {String} */ (unit), false);
- return `${round(convertedValue.n, globals.precision)}${convertedValue.u}`;
- }
- }
- }
-}
-/**
- * @param {TargetsParam} targets
- * @param {AnimationParams} parameters
- * @return {JSAnimation}
- */
-const setTargetValues = (targets, parameters) => {
- if (isUnd(parameters))
- return;
- parameters.duration = minValue;
- // Do not overrides currently active tweens by default
- parameters.composition = setValue(parameters.composition, compositionTypes.none);
- // Skip init() and force rendering by playing the animation
- return new JSAnimation(targets, parameters, null, 0, true).resume();
-};
-/**
- * @param {TargetsArray} targetsArray
- * @param {JSAnimation} animation
- * @param {String} [propertyName]
- * @return {Boolean}
- */
-const removeTargetsFromAnimation = (targetsArray, animation, propertyName) => {
- let tweensMatchesTargets = false;
- forEachChildren(animation, (/**@type {Tween} */ tween) => {
- const tweenTarget = tween.target;
- if (targetsArray.includes(tweenTarget)) {
- const tweenName = tween.property;
- const tweenType = tween._tweenType;
- const normalizePropName = sanitizePropertyName(propertyName, tweenTarget, tweenType);
- if (!normalizePropName || normalizePropName && normalizePropName === tweenName) {
- // Make sure to flag the previous CSS transform tween to renderTransform
- if (tween.parent._tail === tween &&
- tween._tweenType === tweenTypes.TRANSFORM &&
- tween._prev &&
- tween._prev._tweenType === tweenTypes.TRANSFORM) {
- tween._prev._renderTransforms = 1;
- }
- // Removes the tween from the selected animation
- removeChild(animation, tween);
- // Detach the tween from its siblings to make sure blended tweens are correctlly removed
- removeTweenSliblings(tween);
- tweensMatchesTargets = true;
- }
- }
- }, true);
- return tweensMatchesTargets;
-};
-/**
- * @param {TargetsParam} targets
- * @param {Renderable|WAAPIAnimation} [renderable]
- * @param {String} [propertyName]
- * @return {TargetsArray}
- */
-const remove = (targets, renderable, propertyName) => {
- const targetsArray = parseTargets(targets);
- const parent = /** @type {Renderable|typeof engine} **/ (renderable ? renderable : engine);
- const waapiAnimation = renderable && /** @type {WAAPIAnimation} */ (renderable).controlAnimation && /** @type {WAAPIAnimation} */ (renderable);
- for (let i = 0, l = targetsArray.length; i < l; i++) {
- const $el = /** @type {DOMTarget} */ (targetsArray[i]);
- removeWAAPIAnimation($el, propertyName, waapiAnimation);
- }
- let removeMatches;
- if (parent._hasChildren) {
- let iterationDuration = 0;
- forEachChildren(parent, (/** @type {Renderable} */ child) => {
- if (!child._hasChildren) {
- removeMatches = removeTargetsFromAnimation(targetsArray, /** @type {JSAnimation} */ (child), propertyName);
- // Remove the child from its parent if no tweens and no children left after the removal
- if (removeMatches && !child._head) {
- child.cancel();
- removeChild(parent, child);
- }
- else {
- // Calculate the new iterationDuration value to handle onComplete with last child in render()
- const childTLOffset = child._offset + child._delay;
- const childDur = childTLOffset + child.duration;
- if (childDur > iterationDuration) {
- iterationDuration = childDur;
- }
- }
- }
- // Make sure to also remove engine's children targets
- // NOTE: Avoid recursion?
- if (child._head) {
- remove(targets, child, propertyName);
- }
- else {
- child._hasChildren = false;
- }
- }, true);
- // Update iterationDuration value to handle onComplete with last child in render()
- if (!isUnd(/** @type {Renderable} */ (parent).iterationDuration)) {
- /** @type {Renderable} */ (parent).iterationDuration = iterationDuration;
- }
- }
- else {
- removeMatches = removeTargetsFromAnimation(targetsArray,
- /** @type {JSAnimation} */ (parent), propertyName);
- }
- if (removeMatches && !parent._head) {
- parent._hasChildren = false;
- // Cancel the parent if there are no tweens and no children left after the removal
- // We have to check if the .cancel() method exist to handle cases where the parent is the engine itself
- if ( /** @type {Renderable} */(parent).cancel) /** @type {Renderable} */
- (parent).cancel();
- }
- return targetsArray;
-};
-/**
- * @param {(...args: any[]) => Tickable} constructor
- * @return {(...args: any[]) => Tickable}
- */
-const keepTime = createRefreshable;
-/**
- * @param {String|Array} items
- * @return {any}
- */
-const randomPick = items => items[random(0, items.length - 1)];
-/**
- * @param {Number|String} v
- * @param {Number} decimalLength
- * @return {String}
- */
-const roundPad = (v, decimalLength) => (+v).toFixed(decimalLength);
-/**
- * @param {Number} v
- * @param {Number} totalLength
- * @param {String} padString
- * @return {String}
- */
-const padStart = (v, totalLength, padString) => `${v}`.padStart(totalLength, padString);
-/**
- * @param {Number} v
- * @param {Number} totalLength
- * @param {String} padString
- * @return {String}
- */
-const padEnd = (v, totalLength, padString) => `${v}`.padEnd(totalLength, padString);
-/**
- * @param {Number} v
- * @param {Number} min
- * @param {Number} max
- * @return {Number}
- */
-const wrap = (v, min, max) => (((v - min) % (max - min) + (max - min)) % (max - min)) + min;
-/**
- * @param {Number} value
- * @param {Number} inLow
- * @param {Number} inHigh
- * @param {Number} outLow
- * @param {Number} outHigh
- * @return {Number}
- */
-const mapRange = (value, inLow, inHigh, outLow, outHigh) => outLow + ((value - inLow) / (inHigh - inLow)) * (outHigh - outLow);
-/**
- * @param {Number} degrees
- * @return {Number}
- */
-const degToRad = degrees => degrees * PI / 180;
-/**
- * @param {Number} radians
- * @return {Number}
- */
-const radToDeg = radians => radians * 180 / PI;
-/**
- * https://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
- * @param {Number} start
- * @param {Number} end
- * @param {Number} amount
- * @param {Renderable|Boolean} [renderable]
- * @return {Number}
- */
-const lerp = (start, end, amount, renderable) => {
- let dt = K / globals.defaults.frameRate;
- if (renderable !== false) {
- const ticker = /** @type Renderable */ (renderable) ||
- (engine._hasChildren && engine);
- if (ticker && ticker.deltaTime) {
- dt = ticker.deltaTime;
- }
- }
- const t = 1 - Math.exp(-amount * dt * .1);
- return !amount ? start : amount === 1 ? end : (1 - t) * start + t * end;
-};
-// Chain-able utilities
-/**
- * @callback UtilityFunction
- * @param {...*} args
- * @return {Number|String}
- *
- * @param {UtilityFunction} fn
- * @param {Number} [last=0]
- * @return {function(...(Number|String)): function(Number|String): (Number|String)}
- */
-const curry = (fn, last = 0) => (...args) => last ? v => fn(...args, v) : v => fn(v, ...args);
-/**
- * @param {Function} fn
- * @return {function(...(Number|String))}
- */
-const chain = fn => {
- return (...args) => {
- const result = fn(...args);
- return new Proxy(noop, {
- apply: (_, __, [v]) => result(v),
- get: (_, prop) => chain(/**@param {...Number|String} nextArgs */ (...nextArgs) => {
- const nextResult = utils[prop](...nextArgs);
- return (/**@type {Number|String} */ v) => nextResult(result(v));
- })
- });
- };
-};
-/**
- * @param {UtilityFunction} fn
- * @param {Number} [right]
- * @return {function(...(Number|String)): UtilityFunction}
- */
-const makeChainable = (fn, right = 0) => (...args) => (args.length < fn.length ? chain(curry(fn, right)) : fn)(...args);
-/**
- * @callback ChainedUtilsResult
- * @param {Number} value
- * @return {Number}
- *
- * @typedef {Object} ChainableUtils
- * @property {ChainedClamp} clamp
- * @property {ChainedRound} round
- * @property {ChainedSnap} snap
- * @property {ChainedWrap} wrap
- * @property {ChainedInterpolate} interpolate
- * @property {ChainedMapRange} mapRange
- * @property {ChainedRoundPad} roundPad
- * @property {ChainedPadStart} padStart
- * @property {ChainedPadEnd} padEnd
- * @property {ChainedDegToRad} degToRad
- * @property {ChainedRadToDeg} radToDeg
- *
- * @typedef {ChainableUtils & ChainedUtilsResult} ChainableUtil
- *
- * @callback ChainedClamp
- * @param {Number} min
- * @param {Number} max
- * @return {ChainableUtil}
- *
- * @callback ChainedRound
- * @param {Number} decimalLength
- * @return {ChainableUtil}
- *
- * @callback ChainedSnap
- * @param {Number} increment
- * @return {ChainableUtil}
- *
- * @callback ChainedWrap
- * @param {Number} min
- * @param {Number} max
- * @return {ChainableUtil}
- *
- * @callback ChainedInterpolate
- * @param {Number} start
- * @param {Number} end
- * @return {ChainableUtil}
- *
- * @callback ChainedMapRange
- * @param {Number} inLow
- * @param {Number} inHigh
- * @param {Number} outLow
- * @param {Number} outHigh
- * @return {ChainableUtil}
- *
- * @callback ChainedRoundPad
- * @param {Number} decimalLength
- * @return {ChainableUtil}
- *
- * @callback ChainedPadStart
- * @param {Number} totalLength
- * @param {String} padString
- * @return {ChainableUtil}
- *
- * @callback ChainedPadEnd
- * @param {Number} totalLength
- * @param {String} padString
- * @return {ChainableUtil}
- *
- * @callback ChainedDegToRad
- * @return {ChainableUtil}
- *
- * @callback ChainedRadToDeg
- * @return {ChainableUtil}
- */
-const utils = {
- $: registerTargets,
- get: getTargetValue,
- set: setTargetValues,
- remove,
- cleanInlineStyles,
- random,
- randomPick,
- shuffle,
- lerp,
- sync,
- keepTime,
- clamp: /** @type {typeof clamp & ChainedClamp} */ (makeChainable(clamp)),
- round: /** @type {typeof round & ChainedRound} */ (makeChainable(round)),
- snap: /** @type {typeof snap & ChainedSnap} */ (makeChainable(snap)),
- wrap: /** @type {typeof wrap & ChainedWrap} */ (makeChainable(wrap)),
- interpolate: /** @type {typeof interpolate & ChainedInterpolate} */ (makeChainable(interpolate, 1)),
- mapRange: /** @type {typeof mapRange & ChainedMapRange} */ (makeChainable(mapRange)),
- roundPad: /** @type {typeof roundPad & ChainedRoundPad} */ (makeChainable(roundPad)),
- padStart: /** @type {typeof padStart & ChainedPadStart} */ (makeChainable(padStart)),
- padEnd: /** @type {typeof padEnd & ChainedPadEnd} */ (makeChainable(padEnd)),
- degToRad: /** @type {typeof degToRad & ChainedDegToRad} */ (makeChainable(degToRad)),
- radToDeg: /** @type {typeof radToDeg & ChainedRadToDeg} */ (makeChainable(radToDeg)),
-};
-
-
-/**
- * Timeline's children offsets positions parser
- * @param {Timeline} timeline
- * @param {String} timePosition
- * @return {Number}
- */
-const getPrevChildOffset = (timeline, timePosition) => {
- if (stringStartsWith(timePosition, '<')) {
- const goToPrevAnimationOffset = timePosition[1] === '<';
- const prevAnimation = /** @type {Tickable} */ (timeline._tail);
- const prevOffset = prevAnimation ? prevAnimation._offset + prevAnimation._delay : 0;
- return goToPrevAnimationOffset ? prevOffset : prevOffset + prevAnimation.duration;
- }
-};
-/**
- * @param {Timeline} timeline
- * @param {TimelinePosition} [timePosition]
- * @return {Number}
- */
-const parseTimelinePosition = (timeline, timePosition) => {
- let tlDuration = timeline.iterationDuration;
- if (tlDuration === minValue)
- tlDuration = 0;
- if (isUnd(timePosition))
- return tlDuration;
- if (isNum(+timePosition))
- return +timePosition;
- const timePosStr = /** @type {String} */ (timePosition);
- const tlLabels = timeline ? timeline.labels : null;
- const hasLabels = !isNil(tlLabels);
- const prevOffset = getPrevChildOffset(timeline, timePosStr);
- const hasSibling = !isUnd(prevOffset);
- const matchedRelativeOperator = relativeValuesExecRgx.exec(timePosStr);
- if (matchedRelativeOperator) {
- const fullOperator = matchedRelativeOperator[0];
- const split = timePosStr.split(fullOperator);
- const labelOffset = hasLabels && split[0] ? tlLabels[split[0]] : tlDuration;
- const parsedOffset = hasSibling ? prevOffset : hasLabels ? labelOffset : tlDuration;
- const parsedNumericalOffset = +split[1];
- return getRelativeValue(parsedOffset, parsedNumericalOffset, fullOperator[0]);
- }
- else {
- return hasSibling ? prevOffset :
- hasLabels ? !isUnd(tlLabels[timePosStr]) ? tlLabels[timePosStr] :
- tlDuration : tlDuration;
- }
-};
-/**
- * @param {Timeline} tl
- * @return {Number}
- */
-function getTimelineTotalDuration(tl) {
- return clampInfinity(((tl.iterationDuration + tl._loopDelay) * tl.iterationCount) - tl._loopDelay) || minValue;
-}
-/**
- * @overload
- * @param {TimerParams} childParams
- * @param {Timeline} tl
- * @param {Number} timePosition
- * @return {Timeline}
- *
- * @overload
- * @param {AnimationParams} childParams
- * @param {Timeline} tl
- * @param {Number} timePosition
- * @param {TargetsParam} targets
- * @param {Number} [index]
- * @param {Number} [length]
- * @return {Timeline}
- *
- * @param {TimerParams|AnimationParams} childParams
- * @param {Timeline} tl
- * @param {Number} timePosition
- * @param {TargetsParam} [targets]
- * @param {Number} [index]
- * @param {Number} [length]
- */
-function addTlChild(childParams, tl, timePosition, targets, index, length) {
- const isSetter = isNum(childParams.duration) && /** @type {Number} */ (childParams.duration) <= minValue;
- // Offset the tl position with -minValue for 0 duration animations or .set() calls in order to align their end value with the defined position
- const adjustedPosition = isSetter ? timePosition - minValue : timePosition;
- tick(tl, adjustedPosition, 1, 1, tickModes.AUTO);
- const tlChild = targets ?
- new JSAnimation(targets, /** @type {AnimationParams} */ (childParams), tl, adjustedPosition, false, index, length) :
- new Timer(/** @type {TimerParams} */ (childParams), tl, adjustedPosition);
- tlChild.init(1);
- // TODO: Might be better to insert at a position relative to startTime?
- addChild(tl, tlChild);
- forEachChildren(tl, (/** @type {Renderable} */ child) => {
- const childTLOffset = child._offset + child._delay;
- const childDur = childTLOffset + child.duration;
- if (childDur > tl.iterationDuration)
- tl.iterationDuration = childDur;
- });
- tl.duration = getTimelineTotalDuration(tl);
- return tl;
-}
-class Timeline extends Timer {
- /**
- * @param {TimelineParams} [parameters]
- */
- constructor(parameters = {}) {
- super(/** @type {TimerParams&TimelineParams} */ (parameters), null, 0);
- /** @type {Number} */
- this.duration = 0; // TL duration starts at 0 and grows when adding children
- /** @type {Record<String, Number>} */
- this.labels = {};
- const defaultsParams = parameters.defaults;
- const globalDefaults = globals.defaults;
- /** @type {DefaultsParams} */
- this.defaults = defaultsParams ? mergeObjects(defaultsParams, globalDefaults) : globalDefaults;
- /** @type {Callback<this>} */
- this.onRender = parameters.onRender || globalDefaults.onRender;
- const tlPlaybackEase = setValue(parameters.playbackEase, globalDefaults.playbackEase);
- this._ease = tlPlaybackEase ? parseEasings(tlPlaybackEase) : null;
- /** @type {Number} */
- this.iterationDuration = 0;
- }
- /**
- * @overload
- * @param {TargetsParam} a1
- * @param {AnimationParams} a2
- * @param {TimelinePosition|StaggerFunction<Number|String>} [a3]
- * @return {this}
- *
- * @overload
- * @param {TimerParams} a1
- * @param {TimelinePosition} [a2]
- * @return {this}
- *
- * @param {TargetsParam|TimerParams} a1
- * @param {TimelinePosition|AnimationParams} a2
- * @param {TimelinePosition|StaggerFunction<Number|String>} [a3]
- */
- add(a1, a2, a3) {
- const isAnim = isObj(a2);
- const isTimer = isObj(a1);
- if (isAnim || isTimer) {
- this._hasChildren = true;
- if (isAnim) {
- const childParams = /** @type {AnimationParams} */ (a2);
- // Check for function for children stagger positions
- if (isFnc(a3)) {
- const staggeredPosition = a3;
- const parsedTargetsArray = parseTargets(/** @type {TargetsParam} */ (a1));
- // Store initial duration before adding new children that will change the duration
- const tlDuration = this.duration;
- // Store initial _iterationDuration before adding new children that will change the duration
- const tlIterationDuration = this.iterationDuration;
- // Store the original id in order to add specific indexes to the new animations ids
- const id = childParams.id;
- let i = 0;
- /** @type {Number} */
- const parsedLength = (parsedTargetsArray.length);
- parsedTargetsArray.forEach((/** @type {Target} */ target) => {
- // Create a new parameter object for each staggered children
- const staggeredChildParams = { ...childParams };
- // Reset the duration of the timeline iteration before each stagger to prevent wrong start value calculation
- this.duration = tlDuration;
- this.iterationDuration = tlIterationDuration;
- if (!isUnd(id))
- staggeredChildParams.id = id + '-' + i;
- addTlChild(staggeredChildParams, this, parseTimelinePosition(this, staggeredPosition(target, i, parsedLength, this)), target, i, parsedLength);
- i++;
- });
- }
- else {
- addTlChild(childParams, this, parseTimelinePosition(this, a3),
- /** @type {TargetsParam} */ (a1));
- }
- }
- else {
- // It's a Timer
- addTlChild(
- /** @type TimerParams */ (a1), this, parseTimelinePosition(this, a2));
- }
- return this.init(1); // 1 = internalRender
- }
- }
- /**
- * @overload
- * @param {Tickable} [synced]
- * @param {TimelinePosition} [position]
- * @return {this}
- *
- * @overload
- * @param {globalThis.Animation} [synced]
- * @param {TimelinePosition} [position]
- * @return {this}
- *
- * @overload
- * @param {WAAPIAnimation} [synced]
- * @param {TimelinePosition} [position]
- * @return {this}
- *
- * @param {Tickable|WAAPIAnimation|globalThis.Animation} [synced]
- * @param {TimelinePosition} [position]
- */
- sync(synced, position) {
- if (isUnd(synced) || synced && isUnd(synced.pause))
- return this;
- synced.pause();
- const duration = +( /** @type {globalThis.Animation} */(synced).effect ? /** @type {globalThis.Animation} */ (synced).effect.getTiming().duration : /** @type {Tickable} */ (synced).duration);
- return this.add(synced, { currentTime: [0, duration], duration, ease: 'linear' }, position);
- }
- /**
- * @param {TargetsParam} targets
- * @param {AnimationParams} parameters
- * @param {TimelinePosition} [position]
- * @return {this}
- */
- set(targets, parameters, position) {
- if (isUnd(parameters))
- return this;
- parameters.duration = minValue;
- parameters.composition = compositionTypes.replace;
- return this.add(targets, parameters, position);
- }
- /**
- * @param {Callback<Timer>} callback
- * @param {TimelinePosition} [position]
- * @return {this}
- */
- call(callback, position) {
- if (isUnd(callback) || callback && !isFnc(callback))
- return this;
- return this.add({ duration: 0, onComplete: () => callback(this) }, position);
- }
- /**
- * @param {String} labelName
- * @param {TimelinePosition} [position]
- * @return {this}
- *
- */
- label(labelName, position) {
- if (isUnd(labelName) || labelName && !isStr(labelName))
- return this;
- this.labels[labelName] = parseTimelinePosition(this, position);
- return this;
- }
- /**
- * @param {TargetsParam} targets
- * @param {String} [propertyName]
- * @return {this}
- */
- remove(targets, propertyName) {
- remove(targets, this, propertyName);
- return this;
- }
- /**
- * @param {Number} newDuration
- * @return {this}
- */
- stretch(newDuration) {
- const currentDuration = this.duration;
- if (currentDuration === normalizeTime(newDuration))
- return this;
- const timeScale = newDuration / currentDuration;
- const labels = this.labels;
- forEachChildren(this, (/** @type {JSAnimation} */ child) => child.stretch(child.duration * timeScale));
- for (let labelName in labels)
- labels[labelName] *= timeScale;
- return super.stretch(newDuration);
- }
- /**
- * @return {this}
- */
- refresh() {
- forEachChildren(this, (/** @type {JSAnimation} */ child) => {
- if (child.refresh)
- child.refresh();
- });
- return this;
- }
- /**
- * @return {this}
- */
- revert() {
- super.revert();
- forEachChildren(this, (/** @type {JSAnimation} */ child) => child.revert, true);
- return cleanInlineStyles(this);
- }
- /**
- * @param {Callback<this>} [callback]
- * @return {Promise}
- */
- then(callback) {
- return super.then(callback);
- }
-}
-/**
- * @param {TimelineParams} [parameters]
- * @return {Timeline}
- */
-const createTimeline = parameters => new Timeline(parameters).init();
-
-
-class Animatable {
- /**
- * @param {TargetsParam} targets
- * @param {AnimatableParams} parameters
- */
- constructor(targets, parameters) {
- if (scope.current)
- scope.current.register(this);
- const beginHandler = () => {
- if (this.callbacks.completed)
- this.callbacks.reset();
- this.callbacks.play();
- };
- const pauseHandler = () => {
- if (this.callbacks.completed)
- return;
- let paused = true;
- for (let name in this.animations) {
- const anim = this.animations[name];
- if (!anim.paused && paused) {
- paused = false;
- break;
- }
- }
- if (paused) {
- this.callbacks.complete();
- }
- };
- /** @type {AnimationParams} */
- const globalParams = {
- onBegin: beginHandler,
- onComplete: pauseHandler,
- onPause: pauseHandler,
- };
- /** @type {AnimationParams} */
- const callbacksAnimationParams = { v: 1, autoplay: false };
- const properties = {};
- this.targets = [];
- this.animations = {};
- /** @type {JSAnimation|null} */
- this.callbacks = null;
- if (isUnd(targets) || isUnd(parameters))
- return;
- for (let propName in parameters) {
- const paramValue = parameters[propName];
- if (isKey(propName)) {
- properties[propName] = paramValue;
- }
- else if (stringStartsWith(propName, 'on')) {
- callbacksAnimationParams[propName] = paramValue;
- }
- else {
- globalParams[propName] = paramValue;
- }
- }
- this.callbacks = new JSAnimation({ v: 0 }, callbacksAnimationParams);
- for (let propName in properties) {
- const propValue = properties[propName];
- const isObjValue = isObj(propValue);
- /** @type {TweenParamsOptions} */
- let propParams = {};
- let to = '+=0';
- if (isObjValue) {
- const unit = propValue.unit;
- if (isStr(unit))
- to += unit;
- }
- else {
- propParams.duration = propValue;
- }
- propParams[propName] = isObjValue ? mergeObjects({ to }, propValue) : to;
- const animParams = mergeObjects(globalParams, propParams);
- animParams.composition = compositionTypes.replace;
- animParams.autoplay = false;
- const animation = this.animations[propName] = new JSAnimation(targets, animParams, null, 0, false).init();
- if (!this.targets.length)
- this.targets.push(...animation.targets);
- /** @type {AnimatableProperty} */
- this[propName] = (to, duration, ease) => {
- const tween = /** @type {Tween} */ (animation._head);
- if (isUnd(to) && tween) {
- const numbers = tween._numbers;
- if (numbers && numbers.length) {
- return numbers;
- }
- else {
- return tween._modifier(tween._number);
- }
- }
- else {
- forEachChildren(animation, (/** @type {Tween} */ tween) => {
- if (isArr(to)) {
- for (let i = 0, l = /** @type {Array} */ (to).length; i < l; i++) {
- if (!isUnd(tween._numbers[i])) {
- tween._fromNumbers[i] = /** @type {Number} */ (tween._modifier(tween._numbers[i]));
- tween._toNumbers[i] = to[i];
- }
- }
- }
- else {
- tween._fromNumber = /** @type {Number} */ (tween._modifier(tween._number));
- tween._toNumber = /** @type {Number} */ (to);
- }
- if (!isUnd(ease))
- tween._ease = parseEasings(ease);
- tween._currentTime = 0;
- });
- if (!isUnd(duration))
- animation.stretch(duration);
- animation.reset(1).resume();
- return this;
- }
- };
- }
- }
- revert() {
- for (let propName in this.animations) {
- this[propName] = noop;
- this.animations[propName].revert();
- }
- this.animations = {};
- this.targets.length = 0;
- if (this.callbacks)
- this.callbacks.revert();
- return this;
- }
-}
-/**
- * @param {TargetsParam} targets
- * @param {AnimatableParams} parameters
- * @return {AnimatableObject}
- */
-const createAnimatable = (targets, parameters) => /** @type {AnimatableObject} */ (new Animatable(targets, parameters));
-
-
-/*
- * Spring ease solver adapted from https://webkit.org/demos/spring/spring.js
- * Webkit Copyright © 2016 Apple Inc
- */
-const maxSpringParamValue = K * 10;
-/**
- * @typedef {Object} SpringParams
- * @property {Number} [mass=1] - Mass, default 1
- * @property {Number} [stiffness=100] - Stiffness, default 100
- * @property {Number} [damping=10] - Damping, default 10
- * @property {Number} [velocity=0] - Initial velocity, default 0
- */
-class Spring {
- /**
- * @param {SpringParams} [parameters]
- */
- constructor(parameters = {}) {
- this.timeStep = .02; // Interval fed to the solver to calculate duration
- this.restThreshold = .0005; // Values below this threshold are considered resting position
- this.restDuration = 200; // Duration in ms used to check if the spring is resting after reaching restThreshold
- this.maxDuration = 60000; // The maximum allowed spring duration in ms (default 1 min)
- this.maxRestSteps = this.restDuration / this.timeStep / K; // How many steps allowed after reaching restThreshold before stopping the duration calculation
- this.maxIterations = this.maxDuration / this.timeStep / K; // Calculate the maximum iterations allowed based on maxDuration
- this.m = clamp(setValue(parameters.mass, 1), 0, maxSpringParamValue);
- this.s = clamp(setValue(parameters.stiffness, 100), 1, maxSpringParamValue);
- this.d = clamp(setValue(parameters.damping, 10), .1, maxSpringParamValue);
- this.v = clamp(setValue(parameters.velocity, 0), -1e4, maxSpringParamValue);
- this.w0 = 0;
- this.zeta = 0;
- this.wd = 0;
- this.b = 0;
- this.solverDuration = 0;
- this.duration = 0;
- this.compute();
- /** @type {EasingFunction} */
- this.ease = t => t === 0 || t === 1 ? t : this.solve(t * this.solverDuration);
- }
- /** @type {EasingFunction} */
- solve(time) {
- const { zeta, w0, wd, b } = this;
- let t = time;
- if (zeta < 1) {
- t = exp(-t * zeta * w0) * (1 * cos(wd * t) + b * sin(wd * t));
- }
- else {
- t = (1 + b * t) * exp(-t * w0);
- }
- return 1 - t;
- }
- compute() {
- const { maxRestSteps, maxIterations, restThreshold, timeStep, m, d, s, v } = this;
- const w0 = this.w0 = clamp(sqrt(s / m), minValue, K);
- const zeta = this.zeta = d / (2 * sqrt(s * m));
- const wd = this.wd = zeta < 1 ? w0 * sqrt(1 - zeta * zeta) : 0;
- this.b = zeta < 1 ? (zeta * w0 + -v) / wd : -v + w0;
- let solverTime = 0;
- let restSteps = 0;
- let iterations = 0;
- while (restSteps < maxRestSteps && iterations < maxIterations) {
- if (abs(1 - this.solve(solverTime)) < restThreshold) {
- restSteps++;
- }
- else {
- restSteps = 0;
- }
- this.solverDuration = solverTime;
- solverTime += timeStep;
- iterations++;
- }
- this.duration = round(this.solverDuration * K, 0) * globals.timeScale;
- }
- get mass() {
- return this.m;
- }
- set mass(v) {
- this.m = clamp(setValue(v, 1), 0, maxSpringParamValue);
- this.compute();
- }
- get stiffness() {
- return this.s;
- }
- set stiffness(v) {
- this.s = clamp(setValue(v, 100), 1, maxSpringParamValue);
- this.compute();
- }
- get damping() {
- return this.d;
- }
- set damping(v) {
- this.d = clamp(setValue(v, 10), .1, maxSpringParamValue);
- this.compute();
- }
- get velocity() {
- return this.v;
- }
- set velocity(v) {
- this.v = clamp(setValue(v, 0), -1e4, maxSpringParamValue);
- this.compute();
- }
-}
-/**
- * @param {SpringParams} [parameters]
- * @returns {Spring}
- */
-const createSpring = (parameters) => new Spring(parameters);
-
-
-/**
- * @param {Event} e
- */
-const preventDefault = e => {
- if (e.cancelable)
- e.preventDefault();
-};
-class DOMProxy {
- /** @param {Object} el */
- constructor(el) {
- this.el = el;
- this.zIndex = 0;
- this.parentElement = null;
- this.classList = {
- add: noop,
- remove: noop,
- };
- }
- get x() { return this.el.x || 0; }
- ;
- set x(v) { this.el.x = v; }
- ;
- get y() { return this.el.y || 0; }
- ;
- set y(v) { this.el.y = v; }
- ;
- get width() { return this.el.width || 0; }
- ;
- set width(v) { this.el.width = v; }
- ;
- get height() { return this.el.height || 0; }
- ;
- set height(v) { this.el.height = v; }
- ;
- getBoundingClientRect() {
- return {
- top: this.y,
- right: this.x,
- bottom: this.y + this.height,
- left: this.x + this.width,
- };
- }
-}
-class Transforms {
- /**
- * @param {DOMTarget|DOMProxy} $el
- */
- constructor($el) {
- this.$el = $el;
- this.inlineTransforms = [];
- this.point = new DOMPoint();
- this.inversedMatrix = this.getMatrix().inverse();
- }
- /**
- * @param {Number} x
- * @param {Number} y
- * @return {DOMPoint}
- */
- normalizePoint(x, y) {
- this.point.x = x;
- this.point.y = y;
- return this.point.matrixTransform(this.inversedMatrix);
- }
- /**
- * @callback TraverseParentsCallback
- * @param {DOMTarget} $el
- * @param {Number} i
- */
- /**
- * @param {TraverseParentsCallback} cb
- */
- traverseUp(cb) {
- let $el = /** @type {DOMTarget|Document} */ (this.$el.parentElement), i = 0;
- while ($el && $el !== doc) {
- cb(/** @type {DOMTarget} */ ($el), i);
- $el = /** @type {DOMTarget} */ ($el.parentElement);
- i++;
- }
- }
- getMatrix() {
- const matrix = new DOMMatrix();
- this.traverseUp($el => {
- const transformValue = getComputedStyle($el).transform;
- if (transformValue) {
- const elMatrix = new DOMMatrix(transformValue);
- matrix.preMultiplySelf(elMatrix);
- }
- });
- return matrix;
- }
- remove() {
- this.traverseUp(($el, i) => {
- this.inlineTransforms[i] = $el.style.transform;
- $el.style.transform = 'none';
- });
- }
- revert() {
- this.traverseUp(($el, i) => {
- const ct = this.inlineTransforms[i];
- if (ct === '') {
- $el.style.removeProperty('transform');
- }
- else {
- $el.style.transform = ct;
- }
- });
- }
-}
-/**
- * @template {Array<Number>|DOMTargetSelector|String|Number|Boolean|Function|DraggableCursorParams} T
- * @param {T | ((draggable: Draggable) => T)} value
- * @param {Draggable} draggable
- * @return {T}
- */
-const parseDraggableFunctionParameter = (value, draggable) => value && isFnc(value) ? /** @type {Function} */ (value)(draggable) : value;
-let zIndex = 0;
-class Draggable {
- /**
- * @param {TargetsParam} target
- * @param {DraggableParams} [parameters]
- */
- constructor(target, parameters = {}) {
- if (!target)
- return;
- if (scope.current)
- scope.current.register(this);
- const paramX = parameters.x;
- const paramY = parameters.y;
- const trigger = parameters.trigger;
- const modifier = parameters.modifier;
- const ease = parameters.releaseEase;
- const customEase = ease && parseEasings(ease);
- const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */ (ease).ease);
- const xProp = /** @type {String} */ (isObj(paramX) && !isUnd(/** @type {Object} */ (paramX).mapTo) ? /** @type {Object} */ (paramX).mapTo : 'translateX');
- const yProp = /** @type {String} */ (isObj(paramY) && !isUnd(/** @type {Object} */ (paramY).mapTo) ? /** @type {Object} */ (paramY).mapTo : 'translateY');
- const container = parseDraggableFunctionParameter(parameters.container, this);
- this.containerArray = isArr(container) ? container : null;
- this.$container = /** @type {HTMLElement} */ (container && !this.containerArray ? parseTargets(/** @type {DOMTarget} */ (container))[0] : doc.body);
- this.useWin = this.$container === doc.body;
- /** @type {Window | HTMLElement} */
- this.$scrollContainer = this.useWin ? win : this.$container;
- this.$target = /** @type {HTMLElement} */ (isObj(target) ? new DOMProxy(target) : parseTargets(target)[0]);
- this.$trigger = /** @type {HTMLElement} */ (parseTargets(trigger ? trigger : target)[0]);
- this.fixed = getTargetValue(this.$target, 'position') === 'fixed';
- // Refreshable parameters
- this.isFinePointer = true;
- /** @type {[Number, Number, Number, Number]} */
- this.containerPadding = [0, 0, 0, 0];
- /** @type {Number} */
- this.containerFriction = 0;
- /** @type {Number} */
- this.releaseContainerFriction = 0;
- /** @type {Number|Array<Number>} */
- this.snapX = 0;
- /** @type {Number|Array<Number>} */
- this.snapY = 0;
- /** @type {Number} */
- this.scrollSpeed = 0;
- /** @type {Number} */
- this.scrollThreshold = 0;
- /** @type {Number} */
- this.dragSpeed = 0;
- /** @type {Number} */
- this.maxVelocity = 0;
- /** @type {Number} */
- this.minVelocity = 0;
- /** @type {Number} */
- this.velocityMultiplier = 0;
- /** @type {Boolean|DraggableCursorParams} */
- this.cursor = false;
- /** @type {Spring} */
- this.releaseXSpring = hasSpring ? /** @type {Spring} */ (ease) : createSpring({
- mass: setValue(parameters.releaseMass, 1),
- stiffness: setValue(parameters.releaseStiffness, 80),
- damping: setValue(parameters.releaseDamping, 20),
- });
- /** @type {Spring} */
- this.releaseYSpring = hasSpring ? /** @type {Spring} */ (ease) : createSpring({
- mass: setValue(parameters.releaseMass, 1),
- stiffness: setValue(parameters.releaseStiffness, 80),
- damping: setValue(parameters.releaseDamping, 20),
- });
- /** @type {EasingFunction} */
- this.releaseEase = customEase || eases.outQuint;
- /** @type {Boolean} */
- this.hasReleaseSpring = hasSpring;
- /** @type {Callback<this>} */
- this.onGrab = parameters.onGrab || noop;
- /** @type {Callback<this>} */
- this.onDrag = parameters.onDrag || noop;
- /** @type {Callback<this>} */
- this.onRelease = parameters.onRelease || noop;
- /** @type {Callback<this>} */
- this.onUpdate = parameters.onUpdate || noop;
- /** @type {Callback<this>} */
- this.onSettle = parameters.onSettle || noop;
- /** @type {Callback<this>} */
- this.onSnap = parameters.onSnap || noop;
- /** @type {Callback<this>} */
- this.onResize = parameters.onResize || noop;
- /** @type {Callback<this>} */
- this.onAfterResize = parameters.onAfterResize || noop;
- /** @type {[Number, Number]} */
- this.disabled = [0, 0];
- /** @type {AnimatableParams} */
- const animatableParams = {};
- if (modifier)
- animatableParams.modifier = modifier;
- if (isUnd(paramX) || paramX === true) {
- animatableParams[xProp] = 0;
- }
- else if (isObj(paramX)) {
- const paramXObject = /** @type {DraggableAxisParam} */ (paramX);
- const animatableXParams = {};
- if (paramXObject.modifier)
- animatableXParams.modifier = paramXObject.modifier;
- if (paramXObject.composition)
- animatableXParams.composition = paramXObject.composition;
- animatableParams[xProp] = animatableXParams;
- }
- else if (paramX === false) {
- animatableParams[xProp] = 0;
- this.disabled[0] = 1;
- }
- if (isUnd(paramY) || paramY === true) {
- animatableParams[yProp] = 0;
- }
- else if (isObj(paramY)) {
- const paramYObject = /** @type {DraggableAxisParam} */ (paramY);
- const animatableYParams = {};
- if (paramYObject.modifier)
- animatableYParams.modifier = paramYObject.modifier;
- if (paramYObject.composition)
- animatableYParams.composition = paramYObject.composition;
- animatableParams[yProp] = animatableYParams;
- }
- else if (paramY === false) {
- animatableParams[yProp] = 0;
- this.disabled[1] = 1;
- }
- /** @type {AnimatableObject} */
- this.animate = /** @type {AnimatableObject} */ (new Animatable(this.$target, animatableParams));
- // Internal props
- this.xProp = xProp;
- this.yProp = yProp;
- this.destX = 0;
- this.destY = 0;
- this.deltaX = 0;
- this.deltaY = 0;
- this.scroll = { x: 0, y: 0 };
- /** @type {[Number, Number, Number, Number]} */
- this.coords = [this.x, this.y, 0, 0]; // x, y, temp x, temp y
- /** @type {[Number, Number]} */
- this.snapped = [0, 0]; // x, y
- /** @type {[Number, Number, Number, Number, Number, Number, Number, Number]} */
- this.pointer = [0, 0, 0, 0, 0, 0, 0, 0]; // x1, y1, x2, y2, temp x1, temp y1, temp x2, temp y2
- /** @type {[Number, Number]} */
- this.scrollView = [0, 0]; // w, h
- /** @type {[Number, Number, Number, Number]} */
- this.dragArea = [0, 0, 0, 0]; // x, y, w, h
- /** @type {[Number, Number, Number, Number]} */
- this.containerBounds = [-1e12, maxValue, maxValue, -1e12]; // t, r, b, l
- /** @type {[Number, Number, Number, Number]} */
- this.scrollBounds = [0, 0, 0, 0]; // t, r, b, l
- /** @type {[Number, Number, Number, Number]} */
- this.targetBounds = [0, 0, 0, 0]; // t, r, b, l
- /** @type {[Number, Number]} */
- this.window = [0, 0]; // w, h
- /** @type {[Number, Number, Number]} */
- this.velocityStack = [0, 0, 0];
- /** @type {Number} */
- this.velocityStackIndex = 0;
- /** @type {Number} */
- this.velocityTime = now();
- /** @type {Number} */
- this.velocity = 0;
- /** @type {Number} */
- this.angle = 0;
- /** @type {JSAnimation} */
- this.cursorStyles = null;
- /** @type {JSAnimation} */
- this.triggerStyles = null;
- /** @type {JSAnimation} */
- this.bodyStyles = null;
- /** @type {JSAnimation} */
- this.targetStyles = null;
- /** @type {JSAnimation} */
- this.touchActionStyles = null;
- this.transforms = new Transforms(this.$target);
- this.overshootCoords = { x: 0, y: 0 };
- this.overshootTicker = new Timer({
- autoplay: false,
- onUpdate: () => {
- this.updated = true;
- this.manual = true;
- // Use a duration of 1 to prevent the animatable from completing immediately to prevent issues with onSettle()
- // https://github.com/juliangarnier/anime/issues/1045
- if (!this.disabled[0])
- this.animate[this.xProp](this.overshootCoords.x, 1);
- if (!this.disabled[1])
- this.animate[this.yProp](this.overshootCoords.y, 1);
- },
- onComplete: () => {
- this.manual = false;
- if (!this.disabled[0])
- this.animate[this.xProp](this.overshootCoords.x, 0);
- if (!this.disabled[1])
- this.animate[this.yProp](this.overshootCoords.y, 0);
- },
- }, null, 0).init();
- this.updateTicker = new Timer({ autoplay: false, onUpdate: () => this.update() }, null, 0).init();
- this.contained = !isUnd(container);
- this.manual = false;
- this.grabbed = false;
- this.dragged = false;
- this.updated = false;
- this.released = false;
- this.canScroll = false;
- this.enabled = false;
- this.initialized = false;
- this.activeProp = this.disabled[1] ? xProp : yProp;
- this.animate.callbacks.onRender = () => {
- const hasUpdated = this.updated;
- const hasMoved = this.grabbed && hasUpdated;
- const hasReleased = !hasMoved && this.released;
- const x = this.x;
- const y = this.y;
- const dx = x - this.coords[2];
- const dy = y - this.coords[3];
- this.deltaX = dx;
- this.deltaY = dy;
- this.coords[2] = x;
- this.coords[3] = y;
- // Check if dx or dy are not 0 to check if the draggable has actually moved
- // https://github.com/juliangarnier/anime/issues/1032
- if (hasUpdated && (dx || dy)) {
- this.onUpdate(this);
- }
- if (!hasReleased) {
- this.updated = false;
- }
- else {
- this.computeVelocity(dx, dy);
- this.angle = atan2(dy, dx);
- }
- };
- this.animate.callbacks.onComplete = () => {
- if ((!this.grabbed && this.released)) {
- // Set released to false before calling onSettle to avoid recursion
- this.released = false;
- }
- if (!this.manual) {
- this.deltaX = 0;
- this.deltaY = 0;
- this.velocity = 0;
- this.velocityStack[0] = 0;
- this.velocityStack[1] = 0;
- this.velocityStack[2] = 0;
- this.velocityStackIndex = 0;
- this.onSettle(this);
- }
- };
- this.resizeTicker = new Timer({
- autoplay: false,
- duration: 150 * globals.timeScale,
- onComplete: () => {
- this.onResize(this);
- this.refresh();
- this.onAfterResize(this);
- },
- }).init();
- this.parameters = parameters;
- this.resizeObserver = new ResizeObserver(() => {
- if (this.initialized) {
- this.resizeTicker.restart();
- }
- else {
- this.initialized = true;
- }
- });
- this.enable();
- this.refresh();
- this.resizeObserver.observe(this.$container);
- if (!isObj(target))
- this.resizeObserver.observe(this.$target);
- }
- /**
- * @param {Number} dx
- * @param {Number} dy
- * @return {Number}
- */
- computeVelocity(dx, dy) {
- const prevTime = this.velocityTime;
- const curTime = now();
- const elapsed = curTime - prevTime;
- if (elapsed < 17)
- return this.velocity;
- this.velocityTime = curTime;
- const velocityStack = this.velocityStack;
- const vMul = this.velocityMultiplier;
- const minV = this.minVelocity;
- const maxV = this.maxVelocity;
- const vi = this.velocityStackIndex;
- velocityStack[vi] = round(clamp((sqrt(dx * dx + dy * dy) / elapsed) * vMul, minV, maxV), 5);
- const velocity = max(velocityStack[0], velocityStack[1], velocityStack[2]);
- this.velocity = velocity;
- this.velocityStackIndex = (vi + 1) % 3;
- return velocity;
- }
- /**
- * @param {Number} x
- * @param {Boolean} [muteUpdateCallback]
- * @return {this}
- */
- setX(x, muteUpdateCallback = false) {
- if (this.disabled[0])
- return;
- const v = round(x, 5);
- this.overshootTicker.pause();
- this.manual = true;
- this.updated = !muteUpdateCallback;
- this.destX = v;
- this.snapped[0] = snap(v, this.snapX);
- this.animate[this.xProp](v, 0);
- this.manual = false;
- return this;
- }
- /**
- * @param {Number} y
- * @param {Boolean} [muteUpdateCallback]
- * @return {this}
- */
- setY(y, muteUpdateCallback = false) {
- if (this.disabled[1])
- return;
- const v = round(y, 5);
- this.overshootTicker.pause();
- this.manual = true;
- this.updated = !muteUpdateCallback;
- this.destY = v;
- this.snapped[1] = snap(v, this.snapY);
- this.animate[this.yProp](v, 0);
- this.manual = false;
- return this;
- }
- get x() {
- return round(/** @type {Number} */ (this.animate[this.xProp]()), globals.precision);
- }
- set x(x) {
- this.setX(x, false);
- }
- get y() {
- return round(/** @type {Number} */ (this.animate[this.yProp]()), globals.precision);
- }
- set y(y) {
- this.setY(y, false);
- }
- get progressX() {
- return mapRange(this.x, this.containerBounds[3], this.containerBounds[1], 0, 1);
- }
- set progressX(x) {
- this.setX(mapRange(x, 0, 1, this.containerBounds[3], this.containerBounds[1]), false);
- }
- get progressY() {
- return mapRange(this.y, this.containerBounds[0], this.containerBounds[2], 0, 1);
- }
- set progressY(y) {
- this.setY(mapRange(y, 0, 1, this.containerBounds[0], this.containerBounds[2]), false);
- }
- updateScrollCoords() {
- const sx = round(this.useWin ? win.scrollX : this.$container.scrollLeft, 0);
- const sy = round(this.useWin ? win.scrollY : this.$container.scrollTop, 0);
- const [cpt, cpr, cpb, cpl] = this.containerPadding;
- const threshold = this.scrollThreshold;
- this.scroll.x = sx;
- this.scroll.y = sy;
- this.scrollBounds[0] = sy - this.targetBounds[0] + cpt - threshold;
- this.scrollBounds[1] = sx - this.targetBounds[1] - cpr + threshold;
- this.scrollBounds[2] = sy - this.targetBounds[2] - cpb + threshold;
- this.scrollBounds[3] = sx - this.targetBounds[3] + cpl - threshold;
- }
- updateBoundingValues() {
- const $container = this.$container;
- // Return early if no $container defined to prevents error when reading scrollWidth / scrollHeight
- // https://github.com/juliangarnier/anime/issues/1064
- if (!$container)
- return;
- const cx = this.x;
- const cy = this.y;
- const cx2 = this.coords[2];
- const cy2 = this.coords[3];
- // Prevents interfering with the scroll area in cases the target is outside of the container
- // Make sure the temp coords are also adjuset to prevents wrong delta calculation on updates
- this.coords[2] = 0;
- this.coords[3] = 0;
- this.setX(0, true);
- this.setY(0, true);
- this.transforms.remove();
- const iw = this.window[0] = win.innerWidth;
- const ih = this.window[1] = win.innerHeight;
- const uw = this.useWin;
- const sw = $container.scrollWidth;
- const sh = $container.scrollHeight;
- const fx = this.fixed;
- const transformContainerRect = $container.getBoundingClientRect();
- const [cpt, cpr, cpb, cpl] = this.containerPadding;
- this.dragArea[0] = uw ? 0 : transformContainerRect.left;
- this.dragArea[1] = uw ? 0 : transformContainerRect.top;
- this.scrollView[0] = uw ? clamp(sw, iw, sw) : sw;
- this.scrollView[1] = uw ? clamp(sh, ih, sh) : sh;
- this.updateScrollCoords();
- const { width, height, left, top, right, bottom } = $container.getBoundingClientRect();
- this.dragArea[2] = round(uw ? clamp(width, iw, iw) : width, 0);
- this.dragArea[3] = round(uw ? clamp(height, ih, ih) : height, 0);
- const containerOverflow = getTargetValue($container, 'overflow');
- const visibleOverflow = containerOverflow === 'visible';
- const hiddenOverflow = containerOverflow === 'hidden';
- this.canScroll = fx ? false :
- this.contained &&
- (($container === doc.body && visibleOverflow) || (!hiddenOverflow && !visibleOverflow)) &&
- (sw > this.dragArea[2] + cpl - cpr || sh > this.dragArea[3] + cpt - cpb) &&
- (!this.containerArray || (this.containerArray && !isArr(this.containerArray)));
- if (this.contained) {
- const sx = this.scroll.x;
- const sy = this.scroll.y;
- const canScroll = this.canScroll;
- const targetRect = this.$target.getBoundingClientRect();
- const hiddenLeft = canScroll ? uw ? 0 : $container.scrollLeft : 0;
- const hiddenTop = canScroll ? uw ? 0 : $container.scrollTop : 0;
- const hiddenRight = canScroll ? this.scrollView[0] - hiddenLeft - width : 0;
- const hiddenBottom = canScroll ? this.scrollView[1] - hiddenTop - height : 0;
- this.targetBounds[0] = round((targetRect.top + sy) - (uw ? 0 : top), 0);
- this.targetBounds[1] = round((targetRect.right + sx) - (uw ? iw : right), 0);
- this.targetBounds[2] = round((targetRect.bottom + sy) - (uw ? ih : bottom), 0);
- this.targetBounds[3] = round((targetRect.left + sx) - (uw ? 0 : left), 0);
- if (this.containerArray) {
- this.containerBounds[0] = this.containerArray[0] + cpt;
- this.containerBounds[1] = this.containerArray[1] - cpr;
- this.containerBounds[2] = this.containerArray[2] - cpb;
- this.containerBounds[3] = this.containerArray[3] + cpl;
- }
- else {
- this.containerBounds[0] = -round(targetRect.top - (fx ? clamp(top, 0, ih) : top) + hiddenTop - cpt, 0);
- this.containerBounds[1] = -round(targetRect.right - (fx ? clamp(right, 0, iw) : right) - hiddenRight + cpr, 0);
- this.containerBounds[2] = -round(targetRect.bottom - (fx ? clamp(bottom, 0, ih) : bottom) - hiddenBottom + cpb, 0);
- this.containerBounds[3] = -round(targetRect.left - (fx ? clamp(left, 0, iw) : left) + hiddenLeft - cpl, 0);
- }
- }
- this.transforms.revert();
- // Restore coordinates
- this.coords[2] = cx2;
- this.coords[3] = cy2;
- this.setX(cx, true);
- this.setY(cy, true);
- }
- /**
- * @param {Array} bounds
- * @param {Number} x
- * @param {Number} y
- * @return {Number}
- */
- isOutOfBounds(bounds, x, y) {
- // Returns 0 if not OB, 1 if x is OB, 2 if y is OB, 3 if both x and y are OB
- if (!this.contained)
- return 0;
- const [bt, br, bb, bl] = bounds;
- const [dx, dy] = this.disabled;
- const obx = !dx && x < bl || !dx && x > br;
- const oby = !dy && y < bt || !dy && y > bb;
- return obx && !oby ? 1 : !obx && oby ? 2 : obx && oby ? 3 : 0;
- }
- refresh() {
- const params = this.parameters;
- const paramX = params.x;
- const paramY = params.y;
- const container = parseDraggableFunctionParameter(params.container, this);
- const cp = parseDraggableFunctionParameter(params.containerPadding, this) || 0;
- const containerPadding = /** @type {[Number, Number, Number, Number]} */ (isArr(cp) ? cp : [cp, cp, cp, cp]);
- const cx = this.x;
- const cy = this.y;
- const parsedCursorStyles = parseDraggableFunctionParameter(params.cursor, this);
- const cursorStyles = { onHover: 'grab', onGrab: 'grabbing' };
- if (parsedCursorStyles) {
- const { onHover, onGrab } = /** @type {DraggableCursorParams} */ (parsedCursorStyles);
- if (onHover)
- cursorStyles.onHover = onHover;
- if (onGrab)
- cursorStyles.onGrab = onGrab;
- }
- this.containerArray = isArr(container) ? container : null;
- this.$container = /** @type {HTMLElement} */ (container && !this.containerArray ? parseTargets(/** @type {DOMTarget} */ (container))[0] : doc.body);
- this.useWin = this.$container === doc.body;
- /** @type {Window | HTMLElement} */
- this.$scrollContainer = this.useWin ? win : this.$container;
- this.isFinePointer = matchMedia('(pointer:fine)').matches;
- this.containerPadding = setValue(containerPadding, [0, 0, 0, 0]);
- this.containerFriction = clamp(setValue(parseDraggableFunctionParameter(params.containerFriction, this), .8), 0, 1);
- this.releaseContainerFriction = clamp(setValue(parseDraggableFunctionParameter(params.releaseContainerFriction, this), this.containerFriction), 0, 1);
- this.snapX = parseDraggableFunctionParameter(isObj(paramX) && !isUnd(paramX.snap) ? paramX.snap : params.snap, this);
- this.snapY = parseDraggableFunctionParameter(isObj(paramY) && !isUnd(paramY.snap) ? paramY.snap : params.snap, this);
- this.scrollSpeed = setValue(parseDraggableFunctionParameter(params.scrollSpeed, this), 1.5);
- this.scrollThreshold = setValue(parseDraggableFunctionParameter(params.scrollThreshold, this), 20);
- this.dragSpeed = setValue(parseDraggableFunctionParameter(params.dragSpeed, this), 1);
- this.minVelocity = setValue(parseDraggableFunctionParameter(params.minVelocity, this), 0);
- this.maxVelocity = setValue(parseDraggableFunctionParameter(params.maxVelocity, this), 50);
- this.velocityMultiplier = setValue(parseDraggableFunctionParameter(params.velocityMultiplier, this), 1);
- this.cursor = parsedCursorStyles === false ? false : cursorStyles;
- this.updateBoundingValues();
- // const ob = this.isOutOfBounds(this.containerBounds, this.x, this.y);
- // if (ob === 1 || ob === 3) this.progressX = px;
- // if (ob === 2 || ob === 3) this.progressY = py;
- // if (this.initialized && this.contained) {
- // if (this.progressX !== px) this.progressX = px;
- // if (this.progressY !== py) this.progressY = py;
- // }
- const [bt, br, bb, bl] = this.containerBounds;
- this.setX(clamp(cx, bl, br), true);
- this.setY(clamp(cy, bt, bb), true);
- }
- update() {
- this.updateScrollCoords();
- if (this.canScroll) {
- const [cpt, cpr, cpb, cpl] = this.containerPadding;
- const [sw, sh] = this.scrollView;
- const daw = this.dragArea[2];
- const dah = this.dragArea[3];
- const csx = this.scroll.x;
- const csy = this.scroll.y;
- const nsw = this.$container.scrollWidth;
- const nsh = this.$container.scrollHeight;
- const csw = this.useWin ? clamp(nsw, this.window[0], nsw) : nsw;
- const csh = this.useWin ? clamp(nsh, this.window[1], nsh) : nsh;
- const swd = sw - csw;
- const shd = sh - csh;
- // Handle cases where the scrollarea dimensions changes during drag
- if (this.dragged && swd > 0) {
- this.coords[0] -= swd;
- this.scrollView[0] = csw;
- }
- if (this.dragged && shd > 0) {
- this.coords[1] -= shd;
- this.scrollView[1] = csh;
- }
- // Handle autoscroll when target is at the edges of the scroll bounds
- const s = this.scrollSpeed * 10;
- const threshold = this.scrollThreshold;
- const [x, y] = this.coords;
- const [st, sr, sb, sl] = this.scrollBounds;
- const t = round(clamp((y - st + cpt) / threshold, -1, 0) * s, 0);
- const r = round(clamp((x - sr - cpr) / threshold, 0, 1) * s, 0);
- const b = round(clamp((y - sb - cpb) / threshold, 0, 1) * s, 0);
- const l = round(clamp((x - sl + cpl) / threshold, -1, 0) * s, 0);
- if (t || b || l || r) {
- const [nx, ny] = this.disabled;
- let scrollX = csx;
- let scrollY = csy;
- if (!nx) {
- scrollX = round(clamp(csx + (l || r), 0, sw - daw), 0);
- this.coords[0] -= csx - scrollX;
- }
- if (!ny) {
- scrollY = round(clamp(csy + (t || b), 0, sh - dah), 0);
- this.coords[1] -= csy - scrollY;
- }
- // Note: Safari mobile requires to use different scroll methods depending if using the window or not
- if (this.useWin) {
- this.$scrollContainer.scrollBy(-(csx - scrollX), -(csy - scrollY));
- }
- else {
- this.$scrollContainer.scrollTo(scrollX, scrollY);
- }
- }
- }
- const [ct, cr, cb, cl] = this.containerBounds;
- const [px1, py1, px2, py2, px3, py3] = this.pointer;
- this.coords[0] += (px1 - px3) * this.dragSpeed;
- this.coords[1] += (py1 - py3) * this.dragSpeed;
- this.pointer[4] = px1;
- this.pointer[5] = py1;
- const [cx, cy] = this.coords;
- const [sx, sy] = this.snapped;
- const cf = (1 - this.containerFriction) * this.dragSpeed;
- this.setX(cx > cr ? cr + (cx - cr) * cf : cx < cl ? cl + (cx - cl) * cf : cx, false);
- this.setY(cy > cb ? cb + (cy - cb) * cf : cy < ct ? ct + (cy - ct) * cf : cy, false);
- this.computeVelocity(px1 - px3, py1 - py3);
- this.angle = atan2(py1 - py2, px1 - px2);
- const [nsx, nsy] = this.snapped;
- if (nsx !== sx && this.snapX || nsy !== sy && this.snapY) {
- this.onSnap(this);
- }
- }
- stop() {
- this.updateTicker.pause();
- this.overshootTicker.pause();
- // Pauses the in bounds onRelease animations
- for (let prop in this.animate.animations)
- this.animate.animations[prop].pause();
- remove(this, null, 'x');
- remove(this, null, 'y');
- remove(this, null, 'progressX');
- remove(this, null, 'progressY');
- remove(this.scroll); // Removes any active animations on the container scroll
- remove(this.overshootCoords); // Removes active overshoot animations
- return this;
- }
- /**
- * @param {Number} [duration]
- * @param {Number} [gap]
- * @param {EasingParam} [ease]
- * @return {this}
- */
- scrollInView(duration, gap = 0, ease = eases.inOutQuad) {
- this.updateScrollCoords();
- const x = this.destX;
- const y = this.destY;
- const scroll = this.scroll;
- const scrollBounds = this.scrollBounds;
- const canScroll = this.canScroll;
- if (!this.containerArray && this.isOutOfBounds(scrollBounds, x, y)) {
- const [st, sr, sb, sl] = scrollBounds;
- const t = round(clamp(y - st, -1e12, 0), 0);
- const r = round(clamp(x - sr, 0, maxValue), 0);
- const b = round(clamp(y - sb, 0, maxValue), 0);
- const l = round(clamp(x - sl, -1e12, 0), 0);
- new JSAnimation(scroll, {
- x: round(scroll.x + (l ? l - gap : r ? r + gap : 0), 0),
- y: round(scroll.y + (t ? t - gap : b ? b + gap : 0), 0),
- duration: isUnd(duration) ? 350 * globals.timeScale : duration,
- ease,
- onUpdate: () => {
- this.canScroll = false;
- this.$scrollContainer.scrollTo(scroll.x, scroll.y);
- }
- }).init().then(() => {
- this.canScroll = canScroll;
- });
- }
- return this;
- }
- handleHover() {
- if (this.isFinePointer && this.cursor && !this.cursorStyles) {
- this.cursorStyles = setTargetValues(this.$trigger, {
- cursor: /** @type {DraggableCursorParams} */ (this.cursor).onHover
- });
- }
- }
- /**
- * @param {Number} [duration]
- * @param {Number} [gap]
- * @param {EasingParam} [ease]
- * @return {this}
- */
- animateInView(duration, gap = 0, ease = eases.inOutQuad) {
- this.stop();
- this.updateBoundingValues();
- const x = this.x;
- const y = this.y;
- const [cpt, cpr, cpb, cpl] = this.containerPadding;
- const bt = this.scroll.y - this.targetBounds[0] + cpt + gap;
- const br = this.scroll.x - this.targetBounds[1] - cpr - gap;
- const bb = this.scroll.y - this.targetBounds[2] - cpb - gap;
- const bl = this.scroll.x - this.targetBounds[3] + cpl + gap;
- const ob = this.isOutOfBounds([bt, br, bb, bl], x, y);
- if (ob) {
- const [disabledX, disabledY] = this.disabled;
- const destX = clamp(snap(x, this.snapX), bl, br);
- const destY = clamp(snap(y, this.snapY), bt, bb);
- const dur = isUnd(duration) ? 350 * globals.timeScale : duration;
- if (!disabledX && (ob === 1 || ob === 3))
- this.animate[this.xProp](destX, dur, ease);
- if (!disabledY && (ob === 2 || ob === 3))
- this.animate[this.yProp](destY, dur, ease);
- }
- return this;
- }
- /**
- * @param {MouseEvent|TouchEvent} e
- */
- handleDown(e) {
- const $eTarget = /** @type {HTMLElement} */ (e.target);
- if (this.grabbed || /** @type {HTMLInputElement} */ ($eTarget).type === 'range')
- return;
- e.stopPropagation();
- this.grabbed = true;
- this.released = false;
- this.stop();
- this.updateBoundingValues();
- const touches = /** @type {TouchEvent} */ (e).changedTouches;
- const eventX = touches ? touches[0].clientX : /** @type {MouseEvent} */ (e).clientX;
- const eventY = touches ? touches[0].clientY : /** @type {MouseEvent} */ (e).clientY;
- const { x, y } = this.transforms.normalizePoint(eventX, eventY);
- const [ct, cr, cb, cl] = this.containerBounds;
- const cf = (1 - this.containerFriction) * this.dragSpeed;
- const cx = this.x;
- const cy = this.y;
- this.coords[0] = this.coords[2] = !cf ? cx : cx > cr ? cr + (cx - cr) / cf : cx < cl ? cl + (cx - cl) / cf : cx;
- this.coords[1] = this.coords[3] = !cf ? cy : cy > cb ? cb + (cy - cb) / cf : cy < ct ? ct + (cy - ct) / cf : cy;
- this.pointer[0] = x;
- this.pointer[1] = y;
- this.pointer[2] = x;
- this.pointer[3] = y;
- this.pointer[4] = x;
- this.pointer[5] = y;
- this.pointer[6] = x;
- this.pointer[7] = y;
- this.deltaX = 0;
- this.deltaY = 0;
- this.velocity = 0;
- this.velocityStack[0] = 0;
- this.velocityStack[1] = 0;
- this.velocityStack[2] = 0;
- this.velocityStackIndex = 0;
- this.angle = 0;
- if (this.targetStyles) {
- this.targetStyles.revert();
- this.targetStyles = null;
- }
- const z = /** @type {Number} */ (getTargetValue(this.$target, 'zIndex', false));
- zIndex = (z > zIndex ? z : zIndex) + 1;
- this.targetStyles = setTargetValues(this.$target, { zIndex });
- if (this.triggerStyles) {
- this.triggerStyles.revert();
- this.triggerStyles = null;
- }
- if (this.cursorStyles) {
- this.cursorStyles.revert();
- this.cursorStyles = null;
- }
- if (this.isFinePointer && this.cursor) {
- this.bodyStyles = setTargetValues(doc.body, {
- cursor: /** @type {DraggableCursorParams} */ (this.cursor).onGrab
- });
- }
- this.scrollInView(100, 0, eases.out(3));
- this.onGrab(this);
- doc.addEventListener('touchmove', this);
- doc.addEventListener('touchend', this);
- doc.addEventListener('touchcancel', this);
- doc.addEventListener('mousemove', this);
- doc.addEventListener('mouseup', this);
- doc.addEventListener('selectstart', this);
- }
- /**
- * @param {MouseEvent|TouchEvent} e
- */
- handleMove(e) {
- if (!this.grabbed)
- return;
- const touches = /** @type {TouchEvent} */ (e).changedTouches;
- const eventX = touches ? touches[0].clientX : /** @type {MouseEvent} */ (e).clientX;
- const eventY = touches ? touches[0].clientY : /** @type {MouseEvent} */ (e).clientY;
- const { x, y } = this.transforms.normalizePoint(eventX, eventY);
- const movedX = x - this.pointer[6];
- const movedY = y - this.pointer[7];
- let $parent = /** @type {HTMLElement} */ (e.target);
- let isAtTop = false;
- let isAtBottom = false;
- let canTouchScroll = false;
- while (touches && $parent && $parent !== this.$trigger) {
- const overflowY = getTargetValue($parent, 'overflow-y');
- if (overflowY !== 'hidden' && overflowY !== 'visible') {
- const { scrollTop, scrollHeight, clientHeight } = $parent;
- if (scrollHeight > clientHeight) {
- canTouchScroll = true;
- isAtTop = scrollTop <= 3;
- isAtBottom = scrollTop >= (scrollHeight - clientHeight) - 3;
- break;
- }
- }
- $parent = $parent.parentElement;
- }
- if (canTouchScroll && ((!isAtTop && !isAtBottom) || (isAtTop && movedY < 0) || (isAtBottom && movedY > 0))) {
- this.pointer[0] = x;
- this.pointer[1] = y;
- this.pointer[2] = x;
- this.pointer[3] = y;
- this.pointer[4] = x;
- this.pointer[5] = y;
- this.pointer[6] = x;
- this.pointer[7] = y;
- }
- else {
- preventDefault(e);
- // Needed to prevents click on handleUp
- if (!this.triggerStyles)
- this.triggerStyles = setTargetValues(this.$trigger, { pointerEvents: 'none' });
- // Needed to prevent page scroll while dragging on touch devvice
- this.$trigger.addEventListener('touchstart', preventDefault, { passive: false });
- this.$trigger.addEventListener('touchmove', preventDefault, { passive: false });
- this.$trigger.addEventListener('touchend', preventDefault);
- if ((!this.disabled[0] && abs(movedX) > 3) || (!this.disabled[1] && abs(movedY) > 3)) {
- this.updateTicker.resume();
- this.pointer[2] = this.pointer[0];
- this.pointer[3] = this.pointer[1];
- this.pointer[0] = x;
- this.pointer[1] = y;
- this.dragged = true;
- this.released = false;
- this.onDrag(this);
- }
- }
- }
- handleUp() {
- if (!this.grabbed)
- return;
- this.updateTicker.pause();
- if (this.triggerStyles) {
- this.triggerStyles.revert();
- this.triggerStyles = null;
- }
- if (this.bodyStyles) {
- this.bodyStyles.revert();
- this.bodyStyles = null;
- }
- const [disabledX, disabledY] = this.disabled;
- const [px1, py1, px2, py2, px3, py3] = this.pointer;
- const [ct, cr, cb, cl] = this.containerBounds;
- const [sx, sy] = this.snapped;
- const springX = this.releaseXSpring;
- const springY = this.releaseYSpring;
- const releaseEase = this.releaseEase;
- const hasReleaseSpring = this.hasReleaseSpring;
- const overshootCoords = this.overshootCoords;
- const cx = this.x;
- const cy = this.y;
- const pv = this.computeVelocity(px1 - px3, py1 - py3);
- const pa = this.angle = atan2(py1 - py2, px1 - px2);
- const ds = pv * 150;
- const cf = (1 - this.releaseContainerFriction) * this.dragSpeed;
- const nx = cx + (cos(pa) * ds);
- const ny = cy + (sin(pa) * ds);
- const bx = nx > cr ? cr + (nx - cr) * cf : nx < cl ? cl + (nx - cl) * cf : nx;
- const by = ny > cb ? cb + (ny - cb) * cf : ny < ct ? ct + (ny - ct) * cf : ny;
- const dx = this.destX = clamp(round(snap(bx, this.snapX), 5), cl, cr);
- const dy = this.destY = clamp(round(snap(by, this.snapY), 5), ct, cb);
- const ob = this.isOutOfBounds(this.containerBounds, nx, ny);
- let durationX = 0;
- let durationY = 0;
- let easeX = releaseEase;
- let easeY = releaseEase;
- let longestReleaseDuration = 0;
- overshootCoords.x = cx;
- overshootCoords.y = cy;
- if (!disabledX) {
- const directionX = dx === cr ? cx > cr ? -1 : 1 : cx < cl ? -1 : 1;
- const distanceX = round(cx - dx, 0);
- springX.velocity = disabledY && hasReleaseSpring ? distanceX ? (ds * directionX) / abs(distanceX) : 0 : pv;
- const { ease, duration, restDuration } = springX;
- durationX = cx === dx ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
- if (hasReleaseSpring)
- easeX = ease;
- if (durationX > longestReleaseDuration)
- longestReleaseDuration = durationX;
- }
- if (!disabledY) {
- const directionY = dy === cb ? cy > cb ? -1 : 1 : cy < ct ? -1 : 1;
- const distanceY = round(cy - dy, 0);
- springY.velocity = disabledX && hasReleaseSpring ? distanceY ? (ds * directionY) / abs(distanceY) : 0 : pv;
- const { ease, duration, restDuration } = springY;
- durationY = cy === dy ? 0 : hasReleaseSpring ? duration : duration - (restDuration * globals.timeScale);
- if (hasReleaseSpring)
- easeY = ease;
- if (durationY > longestReleaseDuration)
- longestReleaseDuration = durationY;
- }
- if (!hasReleaseSpring && ob && cf && (durationX || durationY)) {
- const composition = compositionTypes.blend;
- new JSAnimation(overshootCoords, {
- x: { to: bx, duration: durationX * .65 },
- y: { to: by, duration: durationY * .65 },
- ease: releaseEase,
- composition,
- }).init();
- new JSAnimation(overshootCoords, {
- x: { to: dx, duration: durationX },
- y: { to: dy, duration: durationY },
- ease: releaseEase,
- composition,
- }).init();
- this.overshootTicker.stretch(max(durationX, durationY)).restart();
- }
- else {
- if (!disabledX)
- this.animate[this.xProp](dx, durationX, easeX);
- if (!disabledY)
- this.animate[this.yProp](dy, durationY, easeY);
- }
- this.scrollInView(longestReleaseDuration, this.scrollThreshold, releaseEase);
- let hasSnapped = false;
- if (dx !== sx) {
- this.snapped[0] = dx;
- if (this.snapX)
- hasSnapped = true;
- }
- if (dy !== sy && this.snapY) {
- this.snapped[1] = dy;
- if (this.snapY)
- hasSnapped = true;
- }
- if (hasSnapped)
- this.onSnap(this);
- this.grabbed = false;
- this.dragged = false;
- this.updated = true;
- this.released = true;
- // It's important to trigger the callback after the release animations to be able to cancel them
- this.onRelease(this);
- this.$trigger.removeEventListener('touchstart', preventDefault);
- this.$trigger.removeEventListener('touchmove', preventDefault);
- this.$trigger.removeEventListener('touchend', preventDefault);
- doc.removeEventListener('touchmove', this);
- doc.removeEventListener('touchend', this);
- doc.removeEventListener('touchcancel', this);
- doc.removeEventListener('mousemove', this);
- doc.removeEventListener('mouseup', this);
- doc.removeEventListener('selectstart', this);
- }
- reset() {
- this.stop();
- this.resizeTicker.pause();
- this.grabbed = false;
- this.dragged = false;
- this.updated = false;
- this.released = false;
- this.canScroll = false;
- this.setX(0, true);
- this.setY(0, true);
- this.coords[0] = 0;
- this.coords[1] = 0;
- this.pointer[0] = 0;
- this.pointer[1] = 0;
- this.pointer[2] = 0;
- this.pointer[3] = 0;
- this.pointer[4] = 0;
- this.pointer[5] = 0;
- this.pointer[6] = 0;
- this.pointer[7] = 0;
- this.velocity = 0;
- this.velocityStack[0] = 0;
- this.velocityStack[1] = 0;
- this.velocityStack[2] = 0;
- this.velocityStackIndex = 0;
- this.angle = 0;
- return this;
- }
- enable() {
- if (!this.enabled) {
- this.enabled = true;
- this.$target.classList.remove('is-disabled');
- this.touchActionStyles = setTargetValues(this.$trigger, {
- touchAction: this.disabled[0] ? 'pan-x' : this.disabled[1] ? 'pan-y' : 'none'
- });
- this.$trigger.addEventListener('touchstart', this, { passive: true });
- this.$trigger.addEventListener('mousedown', this, { passive: true });
- this.$trigger.addEventListener('mouseenter', this);
- }
- return this;
- }
- disable() {
- this.enabled = false;
- this.grabbed = false;
- this.dragged = false;
- this.updated = false;
- this.released = false;
- this.canScroll = false;
- this.touchActionStyles.revert();
- if (this.cursorStyles) {
- this.cursorStyles.revert();
- this.cursorStyles = null;
- }
- if (this.triggerStyles) {
- this.triggerStyles.revert();
- this.triggerStyles = null;
- }
- if (this.bodyStyles) {
- this.bodyStyles.revert();
- this.bodyStyles = null;
- }
- if (this.targetStyles) {
- this.targetStyles.revert();
- this.targetStyles = null;
- }
- this.$target.classList.add('is-disabled');
- this.$trigger.removeEventListener('touchstart', this);
- this.$trigger.removeEventListener('mousedown', this);
- this.$trigger.removeEventListener('mouseenter', this);
- doc.removeEventListener('touchmove', this);
- doc.removeEventListener('touchend', this);
- doc.removeEventListener('touchcancel', this);
- doc.removeEventListener('mousemove', this);
- doc.removeEventListener('mouseup', this);
- doc.removeEventListener('selectstart', this);
- return this;
- }
- revert() {
- this.reset();
- this.disable();
- this.$target.classList.remove('is-disabled');
- this.updateTicker.revert();
- this.overshootTicker.revert();
- this.resizeTicker.revert();
- this.animate.revert();
- this.resizeObserver.disconnect();
- return this;
- }
- /**
- * @param {Event} e
- */
- handleEvent(e) {
- switch (e.type) {
- case 'mousedown':
- this.handleDown(/** @type {MouseEvent} */ (e));
- break;
- case 'touchstart':
- this.handleDown(/** @type {TouchEvent} */ (e));
- break;
- case 'mousemove':
- this.handleMove(/** @type {MouseEvent} */ (e));
- break;
- case 'touchmove':
- this.handleMove(/** @type {TouchEvent} */ (e));
- break;
- case 'mouseup':
- this.handleUp();
- break;
- case 'touchend':
- this.handleUp();
- break;
- case 'touchcancel':
- this.handleUp();
- break;
- case 'mouseenter':
- this.handleHover();
- break;
- case 'selectstart':
- preventDefault(e);
- break;
- }
- }
-}
-/**
- * @param {TargetsParam} target
- * @param {DraggableParams} [parameters]
- * @return {Draggable}
- */
-const createDraggable = (target, parameters) => new Draggable(target, parameters);
-
-
-class Scope {
- /** @param {ScopeParams} [parameters] */
- constructor(parameters = {}) {
- if (scope.current)
- scope.current.register(this);
- const rootParam = parameters.root;
- /** @type {Document|DOMTarget} */
- let root = doc;
- if (rootParam) {
- root = /** @type {ReactRef} */ (rootParam).current ||
- /** @type {AngularRef} */ (rootParam).nativeElement ||
- parseTargets(/** @type {DOMTargetSelector} */ (rootParam))[0] ||
- doc;
- }
- const scopeDefaults = parameters.defaults;
- const globalDefault = globals.defaults;
- const mediaQueries = parameters.mediaQueries;
- /** @type {DefaultsParams} */
- this.defaults = scopeDefaults ? mergeObjects(scopeDefaults, globalDefault) : globalDefault;
- /** @type {Document|DOMTarget} */
- this.root = root;
- /** @type {Array<ScopeConstructorCallback>} */
- this.constructors = [];
- /** @type {Array<ScopeCleanupCallback>} */
- this.revertConstructors = [];
- /** @type {Array<Revertible>} */
- this.revertibles = [];
- /** @type {Array<ScopeConstructorCallback | ((scope: this) => Tickable)>} */
- this.constructorsOnce = [];
- /** @type {Array<ScopeCleanupCallback>} */
- this.revertConstructorsOnce = [];
- /** @type {Array<Revertible>} */
- this.revertiblesOnce = [];
- /** @type {Boolean} */
- this.once = false;
- /** @type {Number} */
- this.onceIndex = 0;
- /** @type {Record<String, ScopeMethod>} */
- this.methods = {};
- /** @type {Record<String, Boolean>} */
- this.matches = {};
- /** @type {Record<String, MediaQueryList>} */
- this.mediaQueryLists = {};
- /** @type {Record<String, any>} */
- this.data = {};
- if (mediaQueries) {
- for (let mq in mediaQueries) {
- const _mq = win.matchMedia(mediaQueries[mq]);
- this.mediaQueryLists[mq] = _mq;
- _mq.addEventListener('change', this);
- }
- }
- }
- /**
- * @param {Revertible} revertible
- */
- register(revertible) {
- const store = this.once ? this.revertiblesOnce : this.revertibles;
- store.push(revertible);
- }
- /**
- * @template T
- * @param {ScopedCallback<T>} cb
- * @return {T}
- */
- execute(cb) {
- let activeScope = scope.current;
- let activeRoot = scope.root;
- let activeDefaults = globals.defaults;
- scope.current = this;
- scope.root = this.root;
- globals.defaults = this.defaults;
- const mqs = this.mediaQueryLists;
- for (let mq in mqs)
- this.matches[mq] = mqs[mq].matches;
- const returned = cb(this);
- scope.current = activeScope;
- scope.root = activeRoot;
- globals.defaults = activeDefaults;
- return returned;
- }
- /**
- * @return {this}
- */
- refresh() {
- this.onceIndex = 0;
- this.execute(() => {
- let i = this.revertibles.length;
- let y = this.revertConstructors.length;
- while (i--)
- this.revertibles[i].revert();
- while (y--)
- this.revertConstructors[y](this);
- this.revertibles.length = 0;
- this.revertConstructors.length = 0;
- this.constructors.forEach((/** @type {ScopeConstructorCallback} */ constructor) => {
- const revertConstructor = constructor(this);
- if (isFnc(revertConstructor)) {
- this.revertConstructors.push(revertConstructor);
- }
- });
- });
- return this;
- }
- /**
- * @overload
- * @param {String} a1
- * @param {ScopeMethod} a2
- * @return {this}
- *
- * @overload
- * @param {ScopeConstructorCallback} a1
- * @return {this}
- *
- * @param {String|ScopeConstructorCallback} a1
- * @param {ScopeMethod} [a2]
- */
- add(a1, a2) {
- this.once = false;
- if (isFnc(a1)) {
- const constructor = /** @type {ScopeConstructorCallback} */ (a1);
- this.constructors.push(constructor);
- this.execute(() => {
- const revertConstructor = constructor(this);
- if (isFnc(revertConstructor)) {
- this.revertConstructors.push(revertConstructor);
- }
- });
- }
- else {
- this.methods[ /** @type {String} */(a1)] = (/** @type {any} */ ...args) => this.execute(() => a2(...args));
- }
- return this;
- }
- /**
- * @param {ScopeConstructorCallback} scopeConstructorCallback
- * @return {this}
- */
- addOnce(scopeConstructorCallback) {
- this.once = true;
- if (isFnc(scopeConstructorCallback)) {
- const currentIndex = this.onceIndex++;
- const tracked = this.constructorsOnce[currentIndex];
- if (tracked)
- return this;
- const constructor = /** @type {ScopeConstructorCallback} */ (scopeConstructorCallback);
- this.constructorsOnce[currentIndex] = constructor;
- this.execute(() => {
- const revertConstructor = constructor(this);
- if (isFnc(revertConstructor)) {
- this.revertConstructorsOnce.push(revertConstructor);
- }
- });
- }
- return this;
- }
- /**
- * @param {(scope: this) => Tickable} cb
- * @return {Tickable}
- */
- keepTime(cb) {
- this.once = true;
- const currentIndex = this.onceIndex++;
- const tracked = /** @type {(scope: this) => Tickable} */ (this.constructorsOnce[currentIndex]);
- if (isFnc(tracked))
- return tracked(this);
- const constructor = /** @type {(scope: this) => Tickable} */ (createRefreshable(cb));
- this.constructorsOnce[currentIndex] = constructor;
- let trackedTickable;
- this.execute(() => {
- trackedTickable = constructor(this);
- });
- return trackedTickable;
- }
- /**
- * @param {Event} e
- */
- handleEvent(e) {
- switch (e.type) {
- case 'change':
- this.refresh();
- break;
- }
- }
- revert() {
- const revertibles = this.revertibles;
- const revertConstructors = this.revertConstructors;
- const revertiblesOnce = this.revertiblesOnce;
- const revertConstructorsOnce = this.revertConstructorsOnce;
- const mqs = this.mediaQueryLists;
- let i = revertibles.length;
- let j = revertConstructors.length;
- let k = revertiblesOnce.length;
- let l = revertConstructorsOnce.length;
- while (i--)
- revertibles[i].revert();
- while (j--)
- revertConstructors[j](this);
- while (k--)
- revertiblesOnce[k].revert();
- while (l--)
- revertConstructorsOnce[l](this);
- for (let mq in mqs)
- mqs[mq].removeEventListener('change', this);
- revertibles.length = 0;
- revertConstructors.length = 0;
- this.constructors.length = 0;
- revertiblesOnce.length = 0;
- revertConstructorsOnce.length = 0;
- this.constructorsOnce.length = 0;
- this.onceIndex = 0;
- this.matches = {};
- this.methods = {};
- this.mediaQueryLists = {};
- this.data = {};
- }
-}
-/**
- * @param {ScopeParams} [params]
- * @return {Scope}
- */
-const createScope = params => new Scope(params);
-
-/**
- * @return {Number}
- */
-const getMaxViewHeight = () => {
- const $el = doc.createElement('div');
- doc.body.appendChild($el);
- $el.style.height = '100lvh';
- const height = $el.offsetHeight;
- doc.body.removeChild($el);
- return height;
-};
-/**
- * @template {ScrollThresholdValue|String|Number|Boolean|Function|Object} T
- * @param {T | ((observer: ScrollObserver) => T)} value
- * @param {ScrollObserver} scroller
- * @return {T}
- */
-const parseScrollObserverFunctionParameter = (value, scroller) => value && isFnc(value) ? /** @type {Function} */ (value)(scroller) : value;
-const scrollContainers = new Map();
-class ScrollContainer {
- /**
- * @param {HTMLElement} $el
- */
- constructor($el) {
- /** @type {HTMLElement} */
- this.element = $el;
- /** @type {Boolean} */
- this.useWin = this.element === doc.body;
- /** @type {Number} */
- this.winWidth = 0;
- /** @type {Number} */
- this.winHeight = 0;
- /** @type {Number} */
- this.width = 0;
- /** @type {Number} */
- this.height = 0;
- /** @type {Number} */
- this.left = 0;
- /** @type {Number} */
- this.top = 0;
- /** @type {Number} */
- this.zIndex = 0;
- /** @type {Number} */
- this.scrollX = 0;
- /** @type {Number} */
- this.scrollY = 0;
- /** @type {Number} */
- this.prevScrollX = 0;
- /** @type {Number} */
- this.prevScrollY = 0;
- /** @type {Number} */
- this.scrollWidth = 0;
- /** @type {Number} */
- this.scrollHeight = 0;
- /** @type {Number} */
- this.velocity = 0;
- /** @type {Boolean} */
- this.backwardX = false;
- /** @type {Boolean} */
- this.backwardY = false;
- /** @type {Timer} */
- this.scrollTicker = new Timer({
- autoplay: false,
- onBegin: () => this.dataTimer.resume(),
- onUpdate: () => {
- const backwards = this.backwardX || this.backwardY;
- forEachChildren(this, (/** @type {ScrollObserver} */ child) => child.handleScroll(), backwards);
- },
- onComplete: () => this.dataTimer.pause()
- }).init();
- /** @type {Timer} */
- this.dataTimer = new Timer({
- autoplay: false,
- frameRate: 30,
- onUpdate: self => {
- const dt = self.deltaTime;
- const px = this.prevScrollX;
- const py = this.prevScrollY;
- const nx = this.scrollX;
- const ny = this.scrollY;
- const dx = px - nx;
- const dy = py - ny;
- this.prevScrollX = nx;
- this.prevScrollY = ny;
- if (dx)
- this.backwardX = px > nx;
- if (dy)
- this.backwardY = py > ny;
- this.velocity = round(dt > 0 ? Math.sqrt(dx * dx + dy * dy) / dt : 0, 5);
- }
- }).init();
- /** @type {Timer} */
- this.resizeTicker = new Timer({
- autoplay: false,
- duration: 250 * globals.timeScale,
- onComplete: () => {
- this.updateWindowBounds();
- this.refreshScrollObservers();
- this.handleScroll();
- }
- }).init();
- /** @type {Timer} */
- this.wakeTicker = new Timer({
- autoplay: false,
- duration: 500 * globals.timeScale,
- onBegin: () => {
- this.scrollTicker.resume();
- },
- onComplete: () => {
- this.scrollTicker.pause();
- }
- }).init();
- /** @type {ScrollObserver} */
- this._head = null;
- /** @type {ScrollObserver} */
- this._tail = null;
- this.updateScrollCoords();
- this.updateWindowBounds();
- this.updateBounds();
- this.refreshScrollObservers();
- this.handleScroll();
- this.resizeObserver = new ResizeObserver(() => this.resizeTicker.restart());
- this.resizeObserver.observe(this.element);
- (this.useWin ? win : this.element).addEventListener('scroll', this, false);
- }
- updateScrollCoords() {
- const useWin = this.useWin;
- const $el = this.element;
- this.scrollX = round(useWin ? win.scrollX : $el.scrollLeft, 0);
- this.scrollY = round(useWin ? win.scrollY : $el.scrollTop, 0);
- }
- updateWindowBounds() {
- this.winWidth = win.innerWidth;
- this.winHeight = getMaxViewHeight();
- }
- updateBounds() {
- const style = getComputedStyle(this.element);
- const $el = this.element;
- this.scrollWidth = $el.scrollWidth + parseFloat(style.marginLeft) + parseFloat(style.marginRight);
- this.scrollHeight = $el.scrollHeight + parseFloat(style.marginTop) + parseFloat(style.marginBottom);
- this.updateWindowBounds();
- let width, height;
- if (this.useWin) {
- width = this.winWidth;
- height = this.winHeight;
- }
- else {
- const elRect = $el.getBoundingClientRect();
- width = $el.clientWidth;
- height = $el.clientHeight;
- this.top = elRect.top;
- this.left = elRect.left;
- }
- this.width = width;
- this.height = height;
- }
- refreshScrollObservers() {
- forEachChildren(this, (/** @type {ScrollObserver} */ child) => {
- if (child._debug) {
- child.removeDebug();
- }
- });
- this.updateBounds();
- forEachChildren(this, (/** @type {ScrollObserver} */ child) => {
- child.refresh();
- if (child._debug) {
- child.debug();
- }
- });
- }
- refresh() {
- this.updateWindowBounds();
- this.updateBounds();
- this.refreshScrollObservers();
- this.handleScroll();
- }
- handleScroll() {
- this.updateScrollCoords();
- this.wakeTicker.restart();
- }
- /**
- * @param {Event} e
- */
- handleEvent(e) {
- switch (e.type) {
- case 'scroll':
- this.handleScroll();
- break;
- }
- }
- revert() {
- this.scrollTicker.cancel();
- this.dataTimer.cancel();
- this.resizeTicker.cancel();
- this.wakeTicker.cancel();
- this.resizeObserver.disconnect();
- (this.useWin ? win : this.element).removeEventListener('scroll', this);
- scrollContainers.delete(this.element);
- }
-}
-/**
- * @param {TargetsParam} target
- * @return {ScrollContainer}
- */
-const registerAndGetScrollContainer = target => {
- const $el = /** @type {HTMLElement} */ (target ? parseTargets(target)[0] || doc.body : doc.body);
- let scrollContainer = scrollContainers.get($el);
- if (!scrollContainer) {
- scrollContainer = new ScrollContainer($el);
- scrollContainers.set($el, scrollContainer);
- }
- return scrollContainer;
-};
-/**
- * @param {HTMLElement} $el
- * @param {Number|string} v
- * @param {Number} size
- * @param {Number} [under]
- * @param {Number} [over]
- * @return {Number}
- */
-const convertValueToPx = ($el, v, size, under, over) => {
- const clampMin = v === 'min';
- const clampMax = v === 'max';
- const value = v === 'top' || v === 'left' || v === 'start' || clampMin ? 0 :
- v === 'bottom' || v === 'right' || v === 'end' || clampMax ? '100%' :
- v === 'center' ? '50%' :
- v;
- const { n, u } = decomposeRawValue(value, decomposedOriginalValue);
- let px = n;
- if (u === '%') {
- px = (n / 100) * size;
- }
- else if (u) {
- px = convertValueUnit($el, decomposedOriginalValue, 'px', true).n;
- }
- if (clampMax && under < 0)
- px += under;
- if (clampMin && over > 0)
- px += over;
- return px;
-};
-/**
- * @param {HTMLElement} $el
- * @param {ScrollThresholdValue} v
- * @param {Number} size
- * @param {Number} [under]
- * @param {Number} [over]
- * @return {Number}
- */
-const parseBoundValue = ($el, v, size, under, over) => {
- /** @type {Number} */
- let value;
- if (isStr(v)) {
- const matchedOperator = relativeValuesExecRgx.exec(/** @type {String} */ (v));
- if (matchedOperator) {
- const splitter = matchedOperator[0];
- const operator = splitter[0];
- const splitted = /** @type {String} */ (v).split(splitter);
- const clampMin = splitted[0] === 'min';
- const clampMax = splitted[0] === 'max';
- const valueAPx = convertValueToPx($el, splitted[0], size, under, over);
- const valueBPx = convertValueToPx($el, splitted[1], size, under, over);
- if (clampMin) {
- const min = getRelativeValue(convertValueToPx($el, 'min', size), valueBPx, operator);
- value = min < valueAPx ? valueAPx : min;
- }
- else if (clampMax) {
- const max = getRelativeValue(convertValueToPx($el, 'max', size), valueBPx, operator);
- value = max > valueAPx ? valueAPx : max;
- }
- else {
- value = getRelativeValue(valueAPx, valueBPx, operator);
- }
- }
- else {
- value = convertValueToPx($el, v, size, under, over);
- }
- }
- else {
- value = /** @type {Number} */ (v);
- }
- return round(value, 0);
-};
-/**
- * @param {JSAnimation} linked
- * @return {HTMLElement}
- */
-const getAnimationDomTarget = linked => {
- let $linkedTarget;
- const linkedTargets = linked.targets;
- for (let i = 0, l = linkedTargets.length; i < l; i++) {
- const target = linkedTargets[i];
- if (target[isDomSymbol]) {
- $linkedTarget = /** @type {HTMLElement} */ (target);
- break;
- }
- }
- return $linkedTarget;
-};
-let scrollerIndex = 0;
-const debugColors$1 = ['#FF4B4B', '#FF971B', '#FFC730', '#F9F640', '#7AFF5A', '#18FF74', '#17E09B', '#3CFFEC', '#05DBE9', '#33B3F1', '#638CF9', '#C563FE', '#FF4FCF', '#F93F8A'];
-class ScrollObserver {
- /**
- * @param {ScrollObserverParams} parameters
- */
- constructor(parameters = {}) {
- if (scope.current)
- scope.current.register(this);
- const syncMode = setValue(parameters.sync, 'play pause');
- const ease = syncMode ? parseEasings(/** @type {EasingParam} */ (syncMode)) : null;
- const isLinear = syncMode && (syncMode === 'linear' || syncMode === none);
- const isEase = syncMode && !(ease === none && !isLinear);
- const isSmooth = syncMode && (isNum(syncMode) || syncMode === true || isLinear);
- const isMethods = syncMode && (isStr(syncMode) && !isEase && !isSmooth);
- const syncMethods = isMethods ? /** @type {String} */ (syncMode).split(' ').map((/** @type {String} */ m) => () => {
- const linked = this.linked;
- return linked && linked[m] ? linked[m]() : null;
- }) : null;
- const biDirSync = isMethods && syncMethods.length > 2;
- /** @type {Number} */
- this.index = scrollerIndex++;
- /** @type {String|Number} */
- this.id = !isUnd(parameters.id) ? parameters.id : this.index;
- /** @type {ScrollContainer} */
- this.container = registerAndGetScrollContainer(parameters.container);
- /** @type {HTMLElement} */
- this.target = null;
- /** @type {Tickable|WAAPIAnimation} */
- this.linked = null;
- /** @type {Boolean} */
- this.repeat = null;
- /** @type {Boolean} */
- this.horizontal = null;
- /** @type {ScrollThresholdParam|ScrollThresholdValue|ScrollThresholdCallback} */
- this.enter = null;
- /** @type {ScrollThresholdParam|ScrollThresholdValue|ScrollThresholdCallback} */
- this.leave = null;
- /** @type {Boolean} */
- this.sync = isEase || isSmooth || !!syncMethods;
- /** @type {EasingFunction} */
- this.syncEase = isEase ? ease : null;
- /** @type {Number} */
- this.syncSmooth = isSmooth ? syncMode === true || isLinear ? 1 : /** @type {Number} */ (syncMode) : null;
- /** @type {Callback<ScrollObserver>} */
- this.onSyncEnter = syncMethods && !biDirSync && syncMethods[0] ? syncMethods[0] : noop;
- /** @type {Callback<ScrollObserver>} */
- this.onSyncLeave = syncMethods && !biDirSync && syncMethods[1] ? syncMethods[1] : noop;
- /** @type {Callback<ScrollObserver>} */
- this.onSyncEnterForward = syncMethods && biDirSync && syncMethods[0] ? syncMethods[0] : noop;
- /** @type {Callback<ScrollObserver>} */
- this.onSyncLeaveForward = syncMethods && biDirSync && syncMethods[1] ? syncMethods[1] : noop;
- /** @type {Callback<ScrollObserver>} */
- this.onSyncEnterBackward = syncMethods && biDirSync && syncMethods[2] ? syncMethods[2] : noop;
- /** @type {Callback<ScrollObserver>} */
- this.onSyncLeaveBackward = syncMethods && biDirSync && syncMethods[3] ? syncMethods[3] : noop;
- /** @type {Callback<ScrollObserver>} */
- this.onEnter = parameters.onEnter || noop;
- /** @type {Callback<ScrollObserver>} */
- this.onLeave = parameters.onLeave || noop;
- /** @type {Callback<ScrollObserver>} */
- this.onEnterForward = parameters.onEnterForward || noop;
- /** @type {Callback<ScrollObserver>} */
- this.onLeaveForward = parameters.onLeaveForward || noop;
- /** @type {Callback<ScrollObserver>} */
- this.onEnterBackward = parameters.onEnterBackward || noop;
- /** @type {Callback<ScrollObserver>} */
- this.onLeaveBackward = parameters.onLeaveBackward || noop;
- /** @type {Callback<ScrollObserver>} */
- this.onUpdate = parameters.onUpdate || noop;
- /** @type {Callback<ScrollObserver>} */
- this.onSyncComplete = parameters.onSyncComplete || noop;
- /** @type {Boolean} */
- this.reverted = false;
- /** @type {Boolean} */
- this.completed = false;
- /** @type {Boolean} */
- this.began = false;
- /** @type {Boolean} */
- this.isInView = false;
- /** @type {Boolean} */
- this.forceEnter = false;
- /** @type {Boolean} */
- this.hasEntered = false;
- // /** @type {Array.<Number>} */
- // this.offsets = [];
- /** @type {Number} */
- this.offset = 0;
- /** @type {Number} */
- this.offsetStart = 0;
- /** @type {Number} */
- this.offsetEnd = 0;
- /** @type {Number} */
- this.distance = 0;
- /** @type {Number} */
- this.prevProgress = 0;
- /** @type {Array} */
- this.thresholds = ['start', 'end', 'end', 'start'];
- /** @type {[Number, Number, Number, Number]} */
- this.coords = [0, 0, 0, 0];
- /** @type {JSAnimation} */
- this.debugStyles = null;
- /** @type {HTMLElement} */
- this.$debug = null;
- /** @type {ScrollObserverParams} */
- this._params = parameters;
- /** @type {Boolean} */
- this._debug = setValue(parameters.debug, false);
- /** @type {ScrollObserver} */
- this._next = null;
- /** @type {ScrollObserver} */
- this._prev = null;
- addChild(this.container, this);
- // Wait for the next frame to add to the container in order to handle calls to link()
- sync(() => {
- if (this.reverted)
- return;
- if (!this.target) {
- const target = /** @type {HTMLElement} */ (parseTargets(parameters.target)[0]);
- this.target = target || doc.body;
- this.refresh();
- }
- if (this._debug)
- this.debug();
- });
- }
- /**
- * @param {Tickable|WAAPIAnimation} linked
- */
- link(linked) {
- if (linked) {
- // Make sure to pause the linked object in case it's added later
- linked.pause();
- this.linked = linked;
- // Try to use a target of the linked object if no target parameters specified
- if (!this._params.target) {
- /** @type {HTMLElement} */
- let $linkedTarget;
- if (!isUnd(/** @type {JSAnimation} */ (linked).targets)) {
- $linkedTarget = getAnimationDomTarget(/** @type {JSAnimation} */ (linked));
- }
- else {
- forEachChildren(/** @type {Timeline} */ (linked), (/** @type {JSAnimation} */ child) => {
- if (child.targets && !$linkedTarget) {
- $linkedTarget = getAnimationDomTarget(/** @type {JSAnimation} */ (child));
- }
- });
- }
- // Fallback to body if no target found
- this.target = $linkedTarget || doc.body;
- this.refresh();
- }
- }
- return this;
- }
- get velocity() {
- return this.container.velocity;
- }
- get backward() {
- return this.horizontal ? this.container.backwardX : this.container.backwardY;
- }
- get scroll() {
- return this.horizontal ? this.container.scrollX : this.container.scrollY;
- }
- get progress() {
- const p = (this.scroll - this.offsetStart) / this.distance;
- return p === Infinity || isNaN(p) ? 0 : round(clamp(p, 0, 1), 6);
- }
- refresh() {
- this.reverted = false;
- const params = this._params;
- this.repeat = setValue(parseScrollObserverFunctionParameter(params.repeat, this), true);
- this.horizontal = setValue(parseScrollObserverFunctionParameter(params.axis, this), 'y') === 'x';
- this.enter = setValue(parseScrollObserverFunctionParameter(params.enter, this), 'end start');
- this.leave = setValue(parseScrollObserverFunctionParameter(params.leave, this), 'start end');
- this.updateBounds();
- this.handleScroll();
- return this;
- }
- removeDebug() {
- if (this.$debug) {
- this.$debug.parentNode.removeChild(this.$debug);
- this.$debug = null;
- }
- if (this.debugStyles) {
- this.debugStyles.revert();
- this.$debug = null;
- }
- return this;
- }
- debug() {
- this.removeDebug();
- const container = this.container;
- const isHori = this.horizontal;
- const $existingDebug = container.element.querySelector(':scope > .animejs-onscroll-debug');
- const $debug = doc.createElement('div');
- const $thresholds = doc.createElement('div');
- const $triggers = doc.createElement('div');
- const color = debugColors$1[this.index % debugColors$1.length];
- const useWin = container.useWin;
- const containerWidth = useWin ? container.winWidth : container.width;
- const containerHeight = useWin ? container.winHeight : container.height;
- const scrollWidth = container.scrollWidth;
- const scrollHeight = container.scrollHeight;
- const size = this.container.width > 360 ? 320 : 260;
- const offLeft = isHori ? 0 : 10;
- const offTop = isHori ? 10 : 0;
- const half = isHori ? 24 : size / 2;
- const labelHeight = isHori ? half : 15;
- const labelWidth = isHori ? 60 : half;
- const labelSize = isHori ? labelWidth : labelHeight;
- const repeat = isHori ? 'repeat-x' : 'repeat-y';
- /**
- * @param {Number} v
- * @return {String}
- */
- const gradientOffset = v => isHori ? '0px ' + (v) + 'px' : (v) + 'px' + ' 2px';
- /**
- * @param {String} c
- * @return {String}
- */
- const lineCSS = (c) => `linear-gradient(${isHori ? 90 : 0}deg, ${c} 2px, transparent 1px)`;
- /**
- * @param {String} p
- * @param {Number} l
- * @param {Number} t
- * @param {Number} w
- * @param {Number} h
- * @return {String}
- */
- const baseCSS = (p, l, t, w, h) => `position:${p};left:${l}px;top:${t}px;width:${w}px;height:${h}px;`;
- $debug.style.cssText = `${baseCSS('absolute', offLeft, offTop, isHori ? scrollWidth : size, isHori ? size : scrollHeight)}
- pointer-events: none;
- z-index: ${this.container.zIndex++};
- display: flex;
- flex-direction: ${isHori ? 'column' : 'row'};
- filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));
- `;
- $thresholds.style.cssText = `${baseCSS('sticky', 0, 0, isHori ? containerWidth : half, isHori ? half : containerHeight)}`;
- if (!$existingDebug) {
- $thresholds.style.cssText += `background:
- ${lineCSS('#FFFF')}${gradientOffset(half - 10)} / ${isHori ? '100px 100px' : '100px 100px'} ${repeat},
- ${lineCSS('#FFF8')}${gradientOffset(half - 10)} / ${isHori ? '10px 10px' : '10px 10px'} ${repeat};
- `;
- }
- $triggers.style.cssText = `${baseCSS('relative', 0, 0, isHori ? scrollWidth : half, isHori ? half : scrollHeight)}`;
- if (!$existingDebug) {
- $triggers.style.cssText += `background:
- ${lineCSS('#FFFF')}${gradientOffset(0)} / ${isHori ? '100px 10px' : '10px 100px'} ${repeat},
- ${lineCSS('#FFF8')}${gradientOffset(0)} / ${isHori ? '10px 0px' : '0px 10px'} ${repeat};
- `;
- }
- const labels = [' enter: ', ' leave: '];
- this.coords.forEach((v, i) => {
- const isView = i > 1;
- const value = (isView ? 0 : this.offset) + v;
- const isTail = i % 2;
- const isFirst = value < labelSize;
- const isOver = value > (isView ? isHori ? containerWidth : containerHeight : isHori ? scrollWidth : scrollHeight) - labelSize;
- const isFlip = (isView ? isTail && !isFirst : !isTail && !isFirst) || isOver;
- const $label = doc.createElement('div');
- const $text = doc.createElement('div');
- const dirProp = isHori ? isFlip ? 'right' : 'left' : isFlip ? 'bottom' : 'top';
- const flipOffset = isFlip ? (isHori ? labelWidth : labelHeight) + (!isView ? isHori ? -1 : -2 : isHori ? -1 : isOver ? 0 : -2) : !isView ? isHori ? 1 : 0 : isHori ? 1 : 0;
- // $text.innerHTML = `${!isView ? '' : labels[isTail] + ' '}${this.id}: ${this.thresholds[i]} ${isView ? '' : labels[isTail]}`;
- $text.innerHTML = `${this.id}${labels[isTail]}${this.thresholds[i]}`;
- $label.style.cssText = `${baseCSS('absolute', 0, 0, labelWidth, labelHeight)}
- display: flex;
- flex-direction: ${isHori ? 'column' : 'row'};
- justify-content: flex-${isView ? 'start' : 'end'};
- align-items: flex-${isFlip ? 'end' : 'start'};
- border-${dirProp}: 2px ${isTail ? 'solid' : 'solid'} ${color};
- `;
- $text.style.cssText = `
- overflow: hidden;
- max-width: ${(size / 2) - 10}px;
- height: ${labelHeight};
- margin-${isHori ? isFlip ? 'right' : 'left' : isFlip ? 'bottom' : 'top'}: -2px;
- padding: 1px;
- font-family: ui-monospace, monospace;
- font-size: 10px;
- letter-spacing: -.025em;
- line-height: 9px;
- font-weight: 600;
- text-align: ${isHori && isFlip || !isHori && !isView ? 'right' : 'left'};
- white-space: pre;
- text-overflow: ellipsis;
- color: ${isTail ? color : 'rgba(0,0,0,.75)'};
- background-color: ${isTail ? 'rgba(0,0,0,.65)' : color};
- border: 2px solid ${isTail ? color : 'transparent'};
- border-${isHori ? isFlip ? 'top-left' : 'top-right' : isFlip ? 'top-left' : 'bottom-left'}-radius: 5px;
- border-${isHori ? isFlip ? 'bottom-left' : 'bottom-right' : isFlip ? 'top-right' : 'bottom-right'}-radius: 5px;
- `;
- $label.appendChild($text);
- let position = value - flipOffset + (isHori ? 1 : 0);
- $label.style[isHori ? 'left' : 'top'] = `${position}px`;
- // $label.style[isHori ? 'left' : 'top'] = value - flipOffset + (!isFlip && isFirst && !isView ? 1 : isFlip ? 0 : -2) + 'px';
- (isView ? $thresholds : $triggers).appendChild($label);
- });
- $debug.appendChild($thresholds);
- $debug.appendChild($triggers);
- container.element.appendChild($debug);
- if (!$existingDebug)
- $debug.classList.add('animejs-onscroll-debug');
- this.$debug = $debug;
- const containerPosition = getTargetValue(container.element, 'position');
- if (containerPosition === 'static') {
- this.debugStyles = setTargetValues(container.element, { position: 'relative ' });
- }
- }
- updateBounds() {
- if (this._debug) {
- this.removeDebug();
- }
- let stickys;
- const $target = this.target;
- const container = this.container;
- const isHori = this.horizontal;
- const linked = this.linked;
- let linkedTime;
- let $el = $target;
- // let offsetX = 0;
- // let offsetY = 0;
- // let $offsetParent = $el;
- /** @type {Element} */
- if (linked) {
- linkedTime = linked.currentTime;
- linked.seek(0, true);
- }
- /* Old implementation to get offset and targetSize before fixing https://github.com/juliangarnier/anime/issues/1021
- // const isContainerStatic = getTargetValue(container.element, 'position') === 'static' ? setTargetValues(container.element, { position: 'relative '}) : false;
- // while ($el && $el !== container.element && $el !== doc.body) {
- // const isSticky = getTargetValue($el, 'position') === 'sticky' ?
- // setTargetValues($el, { position: 'static' }) :
- // false;
- // if ($el === $offsetParent) {
- // offsetX += $el.offsetLeft || 0;
- // offsetY += $el.offsetTop || 0;
- // $offsetParent = $el.offsetParent;
- // }
- // $el = /** @type {HTMLElement} */ ($el.parentElement);
- // if (isSticky) {
- // if (!stickys) stickys = [];
- // stickys.push(isSticky);
- // }
- // }
- // if (isContainerStatic) isContainerStatic.revert();
- // const offset = isHori ? offsetX : offsetY;
- // const targetSize = isHori ? $target.offsetWidth : $target.offsetHeight;
- while ($el && $el !== container.element && $el !== doc.body) {
- const isSticky = getTargetValue($el, 'position') === 'sticky' ? setTargetValues($el, { position: 'static' }) : false;
- $el = $el.parentElement;
- if (isSticky) {
- if (!stickys)
- stickys = [];
- stickys.push(isSticky);
- }
- }
- const rect = $target.getBoundingClientRect();
- const offset = isHori ? rect.left + container.scrollX - container.left : rect.top + container.scrollY - container.top;
- const targetSize = isHori ? rect.width : rect.height;
- const containerSize = isHori ? container.width : container.height;
- const scrollSize = isHori ? container.scrollWidth : container.scrollHeight;
- const maxScroll = scrollSize - containerSize;
- const enter = this.enter;
- const leave = this.leave;
- /** @type {ScrollThresholdValue} */
- let enterTarget = 'start';
- /** @type {ScrollThresholdValue} */
- let leaveTarget = 'end';
- /** @type {ScrollThresholdValue} */
- let enterContainer = 'end';
- /** @type {ScrollThresholdValue} */
- let leaveContainer = 'start';
- if (isStr(enter)) {
- const splitted = /** @type {String} */ (enter).split(' ');
- enterContainer = splitted[0];
- enterTarget = splitted.length > 1 ? splitted[1] : enterTarget;
- }
- else if (isObj(enter)) {
- const e = /** @type {ScrollThresholdParam} */ (enter);
- if (!isUnd(e.container))
- enterContainer = e.container;
- if (!isUnd(e.target))
- enterTarget = e.target;
- }
- else if (isNum(enter)) {
- enterContainer = /** @type {Number} */ (enter);
- }
- if (isStr(leave)) {
- const splitted = /** @type {String} */ (leave).split(' ');
- leaveContainer = splitted[0];
- leaveTarget = splitted.length > 1 ? splitted[1] : leaveTarget;
- }
- else if (isObj(leave)) {
- const t = /** @type {ScrollThresholdParam} */ (leave);
- if (!isUnd(t.container))
- leaveContainer = t.container;
- if (!isUnd(t.target))
- leaveTarget = t.target;
- }
- else if (isNum(leave)) {
- leaveContainer = /** @type {Number} */ (leave);
- }
- const parsedEnterTarget = parseBoundValue($target, enterTarget, targetSize);
- const parsedLeaveTarget = parseBoundValue($target, leaveTarget, targetSize);
- const under = (parsedEnterTarget + offset) - containerSize;
- const over = (parsedLeaveTarget + offset) - maxScroll;
- const parsedEnterContainer = parseBoundValue($target, enterContainer, containerSize, under, over);
- const parsedLeaveContainer = parseBoundValue($target, leaveContainer, containerSize, under, over);
- const offsetStart = parsedEnterTarget + offset - parsedEnterContainer;
- const offsetEnd = parsedLeaveTarget + offset - parsedLeaveContainer;
- const scrollDelta = offsetEnd - offsetStart;
- // this.offsets[0] = offsetX;
- // this.offsets[1] = offsetY;
- this.offset = offset;
- this.offsetStart = offsetStart;
- this.offsetEnd = offsetEnd;
- this.distance = scrollDelta <= 0 ? 0 : scrollDelta;
- this.thresholds = [enterTarget, leaveTarget, enterContainer, leaveContainer];
- this.coords = [parsedEnterTarget, parsedLeaveTarget, parsedEnterContainer, parsedLeaveContainer];
- if (stickys) {
- stickys.forEach(sticky => sticky.revert());
- }
- if (linked) {
- linked.seek(linkedTime, true);
- }
- if (this._debug) {
- this.debug();
- }
- }
- handleScroll() {
- const linked = this.linked;
- const sync = this.sync;
- const syncEase = this.syncEase;
- const syncSmooth = this.syncSmooth;
- const shouldSeek = linked && (syncEase || syncSmooth);
- const isHori = this.horizontal;
- const container = this.container;
- const scroll = this.scroll;
- const isBefore = scroll <= this.offsetStart;
- const isAfter = scroll >= this.offsetEnd;
- const isInView = !isBefore && !isAfter;
- const isOnTheEdge = scroll === this.offsetStart || scroll === this.offsetEnd;
- const forceEnter = !this.hasEntered && isOnTheEdge;
- const $debug = this._debug && this.$debug;
- let hasUpdated = false;
- let syncCompleted = false;
- let p = this.progress;
- if (isBefore && this.began) {
- this.began = false;
- }
- if (p > 0 && !this.began) {
- this.began = true;
- }
- if (shouldSeek) {
- const lp = linked.progress;
- if (syncSmooth && isNum(syncSmooth)) {
- if ( /** @type {Number} */(syncSmooth) < 1) {
- const step = 0.0001;
- const snap = lp < p && p === 1 ? step : lp > p && !p ? -1e-4 : 0;
- p = round(lerp(lp, p, interpolate(.01, .2, /** @type {Number} */ (syncSmooth)), false) + snap, 6);
- }
- }
- else if (syncEase) {
- p = syncEase(p);
- }
- hasUpdated = p !== this.prevProgress;
- syncCompleted = lp === 1;
- if (hasUpdated && !syncCompleted && (syncSmooth && lp)) {
- container.wakeTicker.restart();
- }
- }
- if ($debug) {
- const sticky = isHori ? container.scrollY : container.scrollX;
- $debug.style[isHori ? 'top' : 'left'] = sticky + 10 + 'px';
- }
- // Trigger enter callbacks if already in view or when entering the view
- if ((isInView && !this.isInView) || (forceEnter && !this.forceEnter && !this.hasEntered)) {
- if (isInView)
- this.isInView = true;
- if (!this.forceEnter || !this.hasEntered) {
- if ($debug && isInView)
- $debug.style.zIndex = `${this.container.zIndex++}`;
- this.onSyncEnter(this);
- this.onEnter(this);
- if (this.backward) {
- this.onSyncEnterBackward(this);
- this.onEnterBackward(this);
- }
- else {
- this.onSyncEnterForward(this);
- this.onEnterForward(this);
- }
- this.hasEntered = true;
- if (forceEnter)
- this.forceEnter = true;
- }
- else if (isInView) {
- this.forceEnter = false;
- }
- }
- if (isInView || !isInView && this.isInView) {
- hasUpdated = true;
- }
- if (hasUpdated) {
- if (shouldSeek)
- linked.seek(linked.duration * p);
- this.onUpdate(this);
- }
- if (!isInView && this.isInView) {
- this.isInView = false;
- this.onSyncLeave(this);
- this.onLeave(this);
- if (this.backward) {
- this.onSyncLeaveBackward(this);
- this.onLeaveBackward(this);
- }
- else {
- this.onSyncLeaveForward(this);
- this.onLeaveForward(this);
- }
- if (sync && !syncSmooth) {
- syncCompleted = true;
- }
- }
- if (p >= 1 && this.began && !this.completed && (sync && syncCompleted || !sync)) {
- if (sync) {
- this.onSyncComplete(this);
- }
- this.completed = true;
- if ((!this.repeat && !linked) || (!this.repeat && linked && linked.completed)) {
- this.revert();
- }
- }
- if (p < 1 && this.completed) {
- this.completed = false;
- }
- this.prevProgress = p;
- }
- revert() {
- if (this.reverted)
- return;
- const container = this.container;
- removeChild(container, this);
- if (!container._head) {
- container.revert();
- }
- if (this._debug) {
- this.removeDebug();
- }
- this.reverted = true;
- return this;
- }
-}
-/**
- * @param {ScrollObserverParams} [parameters={}]
- * @return {ScrollObserver}
- */
-const onScroll = (parameters = {}) => new ScrollObserver(parameters);
-
-
-const segmenter = (typeof Intl !== 'undefined') && Intl.Segmenter;
-const valueRgx = /\{value\}/g;
-const indexRgx = /\{i\}/g;
-const whiteSpaceGroupRgx = /(\s+)/;
-const whiteSpaceRgx = /^\s+$/;
-const lineType = 'line';
-const wordType = 'word';
-const charType = 'char';
-const dataLine = `data-line`;
-/**
- * @typedef {Object} Segment
- * @property {String} segment
- * @property {Boolean} [isWordLike]
- */
-/**
- * @typedef {Object} Segmenter
- * @property {function(String): Iterable<Segment>} segment
- */
-/** @type {Segmenter} */
-let wordSegmenter = null;
-/** @type {Segmenter} */
-let graphemeSegmenter = null;
-let $splitTemplate = null;
-/**
- * @param {Segment} seg
- * @return {Boolean}
- */
-const isSegmentWordLike = seg => {
- return seg.isWordLike ||
- seg.segment === ' ' || // Consider spaces as words first, then handle them diffrently later
- isNum(+seg.segment); // Safari doesn't considers numbers as words
-};
-/**
- * @param {HTMLElement} $el
- */
-const setAriaHidden = $el => $el.setAttribute('aria-hidden', 'true');
-/**
- * @param {DOMTarget} $el
- * @param {String} type
- * @return {Array<HTMLElement>}
- */
-const getAllTopLevelElements = ($el, type) => [... /** @type {*} */($el.querySelectorAll(`[data-${type}]:not([data-${type}] [data-${type}])`))];
-const debugColors = { line: '#00D672', word: '#FF4B4B', char: '#5A87FF' };
-/**
- * @param {HTMLElement} $el
- */
-const filterEmptyElements = $el => {
- if (!$el.childElementCount && !$el.textContent.trim()) {
- const $parent = $el.parentElement;
- $el.remove();
- if ($parent)
- filterEmptyElements($parent);
- }
-};
-/**
- * @param {HTMLElement} $el
- * @param {Number} lineIndex
- * @param {Set<HTMLElement>} bin
- * @returns {Set<HTMLElement>}
- */
-const filterLineElements = ($el, lineIndex, bin) => {
- const dataLineAttr = $el.getAttribute(dataLine);
- if (dataLineAttr !== null && +dataLineAttr !== lineIndex || $el.tagName === 'BR')
- bin.add($el);
- let i = $el.childElementCount;
- while (i--)
- filterLineElements(/** @type {HTMLElement} */ ($el.children[i]), lineIndex, bin);
- return bin;
-};
-/**
- * @param {'line'|'word'|'char'} type
- * @param {splitTemplateParams} params
- * @return {String}
- */
-const generateTemplate = (type, params = {}) => {
- let template = ``;
- const classString = isStr(params.class) ? ` class="${params.class}"` : '';
- const cloneType = setValue(params.clone, false);
- const wrapType = setValue(params.wrap, false);
- const overflow = wrapType ? wrapType === true ? 'clip' : wrapType : cloneType ? 'clip' : false;
- if (wrapType)
- template += `<span${overflow ? ` style="overflow:${overflow};"` : ''}>`;
- template += `<span${classString}${cloneType ? ` style="position:relative;"` : ''} data-${type}="{i}">`;
- if (cloneType) {
- const left = cloneType === 'left' ? '-100%' : cloneType === 'right' ? '100%' : '0';
- const top = cloneType === 'top' ? '-100%' : cloneType === 'bottom' ? '100%' : '0';
- template += `<span>{value}</span>`;
- template += `<span inert style="position:absolute;top:${top};left:${left};white-space:nowrap;">{value}</span>`;
- }
- else {
- template += `{value}`;
- }
- template += `</span>`;
- if (wrapType)
- template += `</span>`;
- return template;
-};
-/**
- * @param {String|SplitFunctionValue} htmlTemplate
- * @param {Array<HTMLElement>} store
- * @param {Node|HTMLElement} node
- * @param {DocumentFragment} $parentFragment
- * @param {'line'|'word'|'char'} type
- * @param {Boolean} debug
- * @param {Number} lineIndex
- * @param {Number} [wordIndex]
- * @param {Number} [charIndex]
- * @return {HTMLElement}
- */
-const processHTMLTemplate = (htmlTemplate, store, node, $parentFragment, type, debug, lineIndex, wordIndex, charIndex) => {
- const isLine = type === lineType;
- const isChar = type === charType;
- const className = `_${type}_`;
- const template = isFnc(htmlTemplate) ? htmlTemplate(node) : htmlTemplate;
- const displayStyle = isLine ? 'block' : 'inline-block';
- $splitTemplate.innerHTML = template
- .replace(valueRgx, `<i class="${className}"></i>`)
- .replace(indexRgx, `${isChar ? charIndex : isLine ? lineIndex : wordIndex}`);
- const $content = $splitTemplate.content;
- const $highestParent = /** @type {HTMLElement} */ ($content.firstElementChild);
- const $split = /** @type {HTMLElement} */ ($content.querySelector(`[data-${type}]`)) || $highestParent;
- const $replacables = /** @type {NodeListOf<HTMLElement>} */ ($content.querySelectorAll(`i.${className}`));
- const replacablesLength = $replacables.length;
- if (replacablesLength) {
- $highestParent.style.display = displayStyle;
- $split.style.display = displayStyle;
- $split.setAttribute(dataLine, `${lineIndex}`);
- if (!isLine) {
- $split.setAttribute('data-word', `${wordIndex}`);
- if (isChar)
- $split.setAttribute('data-char', `${charIndex}`);
- }
- let i = replacablesLength;
- while (i--) {
- const $replace = $replacables[i];
- const $closestParent = $replace.parentElement;
- $closestParent.style.display = displayStyle;
- if (isLine) {
- $closestParent.innerHTML = /** @type {HTMLElement} */ (node).innerHTML;
- }
- else {
- $closestParent.replaceChild(node.cloneNode(true), $replace);
- }
- }
- store.push($split);
- $parentFragment.appendChild($content);
- }
- else {
- console.warn(`The expression "{value}" is missing from the provided template.`);
- }
- if (debug)
- $highestParent.style.outline = `1px dotted ${debugColors[type]}`;
- return $highestParent;
-};
-/**
- * A class that splits text into words and wraps them in span elements while preserving the original HTML structure.
- * @class
- */
-class TextSplitter {
- /**
- * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
- * @param {TextSplitterParams} [parameters]
- */
- constructor(target, parameters = {}) {
- // Only init segmenters when needed
- if (!wordSegmenter)
- wordSegmenter = segmenter ? new segmenter([], { granularity: wordType }) : {
- segment: (text) => {
- const segments = [];
- const words = text.split(whiteSpaceGroupRgx);
- for (let i = 0, l = words.length; i < l; i++) {
- const segment = words[i];
- segments.push({
- segment,
- isWordLike: !whiteSpaceRgx.test(segment), // Consider non-whitespace as word-like
- });
- }
- return segments;
- }
- };
- if (!graphemeSegmenter)
- graphemeSegmenter = segmenter ? new segmenter([], { granularity: 'grapheme' }) : {
- segment: text => [...text].map(char => ({ segment: char }))
- };
- if (!$splitTemplate && isBrowser)
- $splitTemplate = doc.createElement('template');
- if (scope.current)
- scope.current.register(this);
- const { words, chars, lines, accessible, includeSpaces, debug } = parameters;
- const $target = /** @type {HTMLElement} */ ((target = isArr(target) ? target[0] : target) && /** @type {Node} */ (target).nodeType ? target : (getNodeList(target) || [])[0]);
- const lineParams = lines === true ? {} : lines;
- const wordParams = words === true || isUnd(words) ? {} : words;
- const charParams = chars === true ? {} : chars;
- this.debug = setValue(debug, false);
- this.includeSpaces = setValue(includeSpaces, false);
- this.accessible = setValue(accessible, true);
- this.linesOnly = lineParams && (!wordParams && !charParams);
- /** @type {String|false|SplitFunctionValue} */
- this.lineTemplate = isObj(lineParams) ? generateTemplate(lineType, /** @type {splitTemplateParams} */ (lineParams)) : lineParams;
- /** @type {String|false|SplitFunctionValue} */
- this.wordTemplate = isObj(wordParams) || this.linesOnly ? generateTemplate(wordType, /** @type {splitTemplateParams} */ (wordParams)) : wordParams;
- /** @type {String|false|SplitFunctionValue} */
- this.charTemplate = isObj(charParams) ? generateTemplate(charType, /** @type {splitTemplateParams} */ (charParams)) : charParams;
- this.$target = $target;
- this.html = $target && $target.innerHTML;
- this.lines = [];
- this.words = [];
- this.chars = [];
- this.effects = [];
- this.effectsCleanups = [];
- this.cache = null;
- this.ready = false;
- this.width = 0;
- this.resizeTimeout = null;
- const handleSplit = () => this.html && (lineParams || wordParams || charParams) && this.split();
- // Make sure this is declared before calling handleSplit() in case revert() is called inside an effect callback
- this.resizeObserver = new ResizeObserver(() => {
- // Use a setTimeout instead of a Timer for better tree shaking
- clearTimeout(this.resizeTimeout);
- this.resizeTimeout = setTimeout(() => {
- const currentWidth = /** @type {HTMLElement} */ ($target).offsetWidth;
- if (currentWidth === this.width)
- return;
- this.width = currentWidth;
- handleSplit();
- }, 150);
- });
- // Only declare the font ready promise when splitting by lines and not alreay split
- if (this.lineTemplate && !this.ready) {
- doc.fonts.ready.then(handleSplit);
- }
- else {
- handleSplit();
- }
- $target ? this.resizeObserver.observe($target) : console.warn('No Text Splitter target found.');
- }
- /**
- * @param {(...args: any[]) => Tickable | (() => void)} effect
- * @return this
- */
- addEffect(effect) {
- if (!isFnc(effect))
- return console.warn('Effect must return a function.');
- const refreshableEffect = createRefreshable(effect);
- this.effects.push(refreshableEffect);
- if (this.ready)
- this.effectsCleanups[this.effects.length - 1] = refreshableEffect(this);
- return this;
- }
- revert() {
- clearTimeout(this.resizeTimeout);
- this.lines.length = this.words.length = this.chars.length = 0;
- this.resizeObserver.disconnect();
- // Make sure to revert the effects after disconnecting the resizeObserver to avoid triggering it in the process
- this.effectsCleanups.forEach(cleanup => isFnc(cleanup) ? cleanup(this) : cleanup.revert && cleanup.revert());
- this.$target.innerHTML = this.html;
- return this;
- }
- /**
- * Recursively processes a node and its children
- * @param {Node} node
- */
- splitNode(node) {
- const wordTemplate = this.wordTemplate;
- const charTemplate = this.charTemplate;
- const includeSpaces = this.includeSpaces;
- const debug = this.debug;
- const nodeType = node.nodeType;
- if (nodeType === 3) {
- const nodeText = node.nodeValue;
- // If the nodeText is only whitespace, leave it as is
- if (nodeText.trim()) {
- const tempWords = [];
- const words = this.words;
- const chars = this.chars;
- const wordSegments = wordSegmenter.segment(nodeText);
- const $wordsFragment = doc.createDocumentFragment();
- let prevSeg = null;
- for (const wordSegment of wordSegments) {
- const segment = wordSegment.segment;
- const isWordLike = isSegmentWordLike(wordSegment);
- // Determine if this segment should be a new word, first segment always becomes a new word
- if (!prevSeg || (isWordLike && (prevSeg && (isSegmentWordLike(prevSeg))))) {
- tempWords.push(segment);
- }
- else {
- // Only concatenate if both current and previous are non-word-like and don't contain spaces
- const lastWordIndex = tempWords.length - 1;
- const lastWord = tempWords[lastWordIndex];
- if (!lastWord.includes(' ') && !segment.includes(' ')) {
- tempWords[lastWordIndex] += segment;
- }
- else {
- tempWords.push(segment);
- }
- }
- prevSeg = wordSegment;
- }
- for (let i = 0, l = tempWords.length; i < l; i++) {
- const word = tempWords[i];
- if (!word.trim()) {
- // Preserve whitespace only if includeSpaces is false and if the current space is not the first node
- if (i && includeSpaces)
- continue;
- $wordsFragment.appendChild(doc.createTextNode(word));
- }
- else {
- const nextWord = tempWords[i + 1];
- const hasWordFollowingSpace = includeSpaces && nextWord && !nextWord.trim();
- const wordToProcess = word;
- const charSegments = charTemplate ? graphemeSegmenter.segment(wordToProcess) : null;
- const $charsFragment = charTemplate ? doc.createDocumentFragment() : doc.createTextNode(hasWordFollowingSpace ? word + '\xa0' : word);
- if (charTemplate) {
- const charSegmentsArray = [...charSegments];
- for (let j = 0, jl = charSegmentsArray.length; j < jl; j++) {
- const charSegment = charSegmentsArray[j];
- const isLastChar = j === jl - 1;
- // If this is the last character and includeSpaces is true with a following space, append the space
- const charText = isLastChar && hasWordFollowingSpace ? charSegment.segment + '\xa0' : charSegment.segment;
- const $charNode = doc.createTextNode(charText);
- processHTMLTemplate(charTemplate, chars, $charNode, /** @type {DocumentFragment} */ ($charsFragment), charType, debug, -1, words.length, chars.length);
- }
- }
- if (wordTemplate) {
- processHTMLTemplate(wordTemplate, words, $charsFragment, $wordsFragment, wordType, debug, -1, words.length, chars.length);
- // Chars elements must be re-parsed in the split() method if both words and chars are parsed
- }
- else if (charTemplate) {
- $wordsFragment.appendChild($charsFragment);
- }
- else {
- $wordsFragment.appendChild(doc.createTextNode(word));
- }
- // Skip the next iteration if we included a space
- if (hasWordFollowingSpace)
- i++;
- }
- }
- node.parentNode.replaceChild($wordsFragment, node);
- }
- }
- else if (nodeType === 1) {
- // Converting to an array is necessary to work around childNodes pottential mutation
- const childNodes = /** @type {Array<Node>} */ ([... /** @type {*} */(node.childNodes)]);
- for (let i = 0, l = childNodes.length; i < l; i++)
- this.splitNode(childNodes[i]);
- }
- }
- /**
- * @param {Boolean} clearCache
- * @return {this}
- */
- split(clearCache = false) {
- const $el = this.$target;
- const isCached = !!this.cache && !clearCache;
- const lineTemplate = this.lineTemplate;
- const wordTemplate = this.wordTemplate;
- const charTemplate = this.charTemplate;
- const fontsReady = doc.fonts.status !== 'loading';
- const canSplitLines = lineTemplate && fontsReady;
- this.ready = !lineTemplate || fontsReady;
- if (canSplitLines || clearCache) {
- // No need to revert effects animations here since it's already taken care by the refreshable
- this.effectsCleanups.forEach(cleanup => isFnc(cleanup) && cleanup(this));
- }
- if (!isCached) {
- if (clearCache) {
- $el.innerHTML = this.html;
- this.words.length = this.chars.length = 0;
- }
- this.splitNode($el);
- this.cache = $el.innerHTML;
- }
- if (canSplitLines) {
- if (isCached)
- $el.innerHTML = this.cache;
- this.lines.length = 0;
- if (wordTemplate)
- this.words = getAllTopLevelElements($el, wordType);
- }
- // Always reparse characters after a line reset or if both words and chars are activated
- if (charTemplate && (canSplitLines || wordTemplate)) {
- this.chars = getAllTopLevelElements($el, charType);
- }
- // Words are used when lines only and prioritized over chars
- const elementsArray = this.words.length ? this.words : this.chars;
- let y, linesCount = 0;
- for (let i = 0, l = elementsArray.length; i < l; i++) {
- const $el = elementsArray[i];
- const { top, height } = $el.getBoundingClientRect();
- if (y && top - y > height * .5)
- linesCount++;
- $el.setAttribute(dataLine, `${linesCount}`);
- const nested = $el.querySelectorAll(`[${dataLine}]`);
- let c = nested.length;
- while (c--)
- nested[c].setAttribute(dataLine, `${linesCount}`);
- y = top;
- }
- if (canSplitLines) {
- const linesFragment = doc.createDocumentFragment();
- const parents = new Set();
- const clones = [];
- for (let lineIndex = 0; lineIndex < linesCount + 1; lineIndex++) {
- const $clone = /** @type {HTMLElement} */ ($el.cloneNode(true));
- filterLineElements($clone, lineIndex, new Set()).forEach($el => {
- const $parent = $el.parentElement;
- if ($parent)
- parents.add($parent);
- $el.remove();
- });
- clones.push($clone);
- }
- parents.forEach(filterEmptyElements);
- for (let cloneIndex = 0, clonesLength = clones.length; cloneIndex < clonesLength; cloneIndex++) {
- processHTMLTemplate(lineTemplate, this.lines, clones[cloneIndex], linesFragment, lineType, this.debug, cloneIndex);
- }
- $el.innerHTML = '';
- $el.appendChild(linesFragment);
- if (wordTemplate)
- this.words = getAllTopLevelElements($el, wordType);
- if (charTemplate)
- this.chars = getAllTopLevelElements($el, charType);
- }
- // Remove the word wrappers and clear the words array if lines split only
- if (this.linesOnly) {
- const words = this.words;
- let w = words.length;
- while (w--) {
- const $word = words[w];
- $word.replaceWith($word.textContent);
- }
- words.length = 0;
- }
- if (this.accessible && (canSplitLines || !isCached)) {
- const $accessible = doc.createElement('span');
- // Make the accessible element visually-hidden (https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html)
- $accessible.style.cssText = `position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;`;
- // $accessible.setAttribute('tabindex', '-1');
- $accessible.innerHTML = this.html;
- $el.insertBefore($accessible, $el.firstChild);
- this.lines.forEach(setAriaHidden);
- this.words.forEach(setAriaHidden);
- this.chars.forEach(setAriaHidden);
- }
- this.width = /** @type {HTMLElement} */ ($el).offsetWidth;
- if (canSplitLines || clearCache) {
- this.effects.forEach((effect, i) => this.effectsCleanups[i] = effect(this));
- }
- return this;
- }
- refresh() {
- this.split(true);
- }
-}
-/**
- * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
- * @param {TextSplitterParams} [parameters]
- * @return {TextSplitter}
- */
-const split = (target, parameters) => new TextSplitter(target, parameters);
-const text = {
- split,
-};
-
-
-/**
- * @overload
- * @param {Number} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<Number>}
- */
-/**
- * @overload
- * @param {String} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<String>}
- */
-/**
- * @overload
- * @param {[Number, Number]} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<Number>}
- */
-/**
- * @overload
- * @param {[String, String]} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<String>}
- */
-/**
- * @param {Number|String|[Number, Number]|[String, String]} val The staggered value or range
- * @param {StaggerParams} [params] The stagger parameters
- * @return {StaggerFunction<Number|String>}
- */
-const stagger = (val, params = {}) => {
- let values = [];
- let maxValue = 0;
- const from = params.from;
- const reversed = params.reversed;
- const ease = params.ease;
- const hasEasing = !isUnd(ease);
- const hasSpring = hasEasing && !isUnd(/** @type {Spring} */ (ease).ease);
- const staggerEase = hasSpring ? /** @type {Spring} */ (ease).ease : hasEasing ? parseEasings(ease) : null;
- const grid = params.grid;
- const axis = params.axis;
- const customTotal = params.total;
- const fromFirst = isUnd(from) || from === 0 || from === 'first';
- const fromCenter = from === 'center';
- const fromLast = from === 'last';
- const fromRandom = from === 'random';
- const isRange = isArr(val);
- const useProp = params.use;
- const val1 = isRange ? parseNumber(val[0]) : parseNumber(val);
- const val2 = isRange ? parseNumber(val[1]) : 0;
- const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
- const start = params.start || 0 + (isRange ? val1 : 0);
- let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
- return (target, i, t, tl) => {
- const [registeredTarget] = registerTargets(target);
- const total = isUnd(customTotal) ? t : customTotal;
- const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
- const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
- if (fromCenter)
- fromIndex = (total - 1) / 2;
- if (fromLast)
- fromIndex = total - 1;
- if (!values.length) {
- for (let index = 0; index < total; index++) {
- if (!grid) {
- values.push(abs(fromIndex - index));
- }
- else {
- const fromX = !fromCenter ? fromIndex % grid[0] : (grid[0] - 1) / 2;
- const fromY = !fromCenter ? floor(fromIndex / grid[0]) : (grid[1] - 1) / 2;
- const toX = index % grid[0];
- const toY = floor(index / grid[0]);
- const distanceX = fromX - toX;
- const distanceY = fromY - toY;
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
- if (axis === 'x')
- value = -distanceX;
- if (axis === 'y')
- value = -distanceY;
- values.push(value);
- }
- maxValue = max(...values);
- }
- if (staggerEase)
- values = values.map(val => staggerEase(val / maxValue) * maxValue);
- if (reversed)
- values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
- if (fromRandom)
- values = shuffle(values);
- }
- const spacing = isRange ? (val2 - val1) / maxValue : val1;
- const offset = tl ? parseTimelinePosition(tl, isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */ (start);
- /** @type {String|Number} */
- let output = offset + ((spacing * round(values[staggerIndex], 2)) || 0);
- if (params.modifier)
- output = params.modifier(output);
- if (unitMatch)
- output = `${output}${unitMatch[2]}`;
- return output;
- };
-};
-
-export { Animatable, Draggable, JSAnimation, Scope, ScrollObserver, Spring, TextSplitter, Timeline, Timer, WAAPIAnimation, animate, createAnimatable, createDraggable, createScope, createSpring, createTimeline, createTimer, eases, engine, onScroll, scrollContainers, stagger, svg, text, utils, waapi };