Initial commit xmarticaims

This commit is contained in:
2026-11-02 10:26:32 -06:00
commit e74236f5c1
9764 changed files with 2880647 additions and 0 deletions
@@ -0,0 +1,64 @@
/**
* Anime.js - easings - CJS
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
'use strict';
var helpers = require('../../core/helpers.cjs');
var none = require('../none.cjs');
/**
* @import {
* EasingFunction,
* } from '../../types/index.js'
*/
/**
* 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 (helpers.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.none :
t => t === 0 || t === 1 ? t :
calcBezier(binarySubdivide(t, mX1, mX2), mY1, mY2);
exports.cubicBezier = cubicBezier;
@@ -0,0 +1,2 @@
export function cubicBezier(mX1?: number, mY1?: number, mX2?: number, mY2?: number): EasingFunction;
import type { EasingFunction } from '../../types/index.js';
@@ -0,0 +1,62 @@
/**
* Anime.js - easings - ESM
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
import { abs } from '../../core/helpers.js';
import { none } from '../none.js';
/**
* @import {
* EasingFunction,
* } from '../../types/index.js'
*/
/**
* 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);
export { cubicBezier };
@@ -0,0 +1,14 @@
/**
* Anime.js - easings - CJS
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
'use strict';
var parser = require('./parser.cjs');
exports.eases = parser.eases;
@@ -0,0 +1 @@
export { eases } from "./parser.js";
@@ -0,0 +1,8 @@
/**
* Anime.js - easings - ESM
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
export { eases } from './parser.js';
@@ -0,0 +1,191 @@
/**
* Anime.js - easings - CJS
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
'use strict';
var consts = require('../../core/consts.cjs');
var helpers = require('../../core/helpers.cjs');
var none = require('../none.cjs');
/**
* @import {
* EasingFunction,
* EasingFunctionWithParams,
* EasingParam,
* BackEasing,
* ElasticEasing,
* PowerEasing,
* } 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
*/
const halfPI = helpers.PI / 2;
const doublePI = helpers.PI * 2;
/** @type {Record<String, EasingFunctionWithParams|EasingFunction>} */
const easeInFunctions = {
[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} */
Circ: t => 1 - helpers.sqrt(1 - t * t),
/** @type {EasingFunction} */
Expo: t => t ? helpers.pow(2, 10 * t - 10) : 0,
/** @type {EasingFunction} */
Bounce: t => {
let pow2, b = 4;
while (t < ((pow2 = helpers.pow(2, --b)) - 1) / 11);
return 1 / helpers.pow(4, 3 - b) - 7.5625 * helpers.pow((pow2 * 3 - 2) / 22 - t, 2);
},
/** @type {BackEasing} */
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);
const p = helpers.clamp(+period, consts.minValue, 2);
const s = (p / doublePI) * helpers.asin(1 / a);
const e = doublePI / p;
return t => t === 0 || t === 1 ? t : -a * helpers.pow(2, -10 * (1 - t)) * helpers.sin(((1 - t) - s) * e);
}
};
/**
* @typedef {Object} EasesFunctions
* @property {EasingFunction} linear
* @property {EasingFunction} none
* @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: none.none, none: none.none };
for (let type in easeTypes) {
for (let name in easeInFunctions) {
const easeIn = easeInFunctions[name];
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)) :
easeType(/** @type {EasingFunction} */(easeIn))
);
}
}
return /** @type {EasesFunctions} */(list);
})());
/** @type {Record<String, EasingFunction>} */
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 => {
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;
@@ -0,0 +1,124 @@
/**
* @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: EasingFunction;
export let none: 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;
}
export function parseEaseString(string: string): EasingFunction;
export function parseEase(ease: EasingParam): EasingFunction;
export type EaseType = (Ease: EasingFunction) => EasingFunction;
export type EasesFunctions = {
linear: EasingFunction;
none: EasingFunction;
in: PowerEasing;
out: PowerEasing;
inOut: PowerEasing;
outIn: PowerEasing;
inQuad: EasingFunction;
outQuad: EasingFunction;
inOutQuad: EasingFunction;
outInQuad: EasingFunction;
inCubic: EasingFunction;
outCubic: EasingFunction;
inOutCubic: EasingFunction;
outInCubic: EasingFunction;
inQuart: EasingFunction;
outQuart: EasingFunction;
inOutQuart: EasingFunction;
outInQuart: EasingFunction;
inQuint: EasingFunction;
outQuint: EasingFunction;
inOutQuint: EasingFunction;
outInQuint: EasingFunction;
inSine: EasingFunction;
outSine: EasingFunction;
inOutSine: EasingFunction;
outInSine: EasingFunction;
inCirc: EasingFunction;
outCirc: EasingFunction;
inOutCirc: EasingFunction;
outInCirc: EasingFunction;
inExpo: EasingFunction;
outExpo: EasingFunction;
inOutExpo: EasingFunction;
outInExpo: EasingFunction;
inBounce: EasingFunction;
outBounce: EasingFunction;
inOutBounce: EasingFunction;
outInBounce: EasingFunction;
inBack: BackEasing;
outBack: BackEasing;
inOutBack: BackEasing;
outInBack: BackEasing;
inElastic: ElasticEasing;
outElastic: ElasticEasing;
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';
@@ -0,0 +1,185 @@
/**
* Anime.js - easings - ESM
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
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 {
* EasingFunction,
* EasingFunctionWithParams,
* EasingParam,
* BackEasing,
* ElasticEasing,
* PowerEasing,
* } 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
*/
const halfPI = PI / 2;
const doublePI = PI * 2;
/** @type {Record<String, EasingFunctionWithParams|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.7) => 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);
}
};
/**
* @typedef {Object} EasesFunctions
* @property {EasingFunction} linear
* @property {EasingFunction} none
* @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: none, none: none };
for (let type in easeTypes) {
for (let name in easeInFunctions) {
const easeIn = easeInFunctions[name];
const easeType = easeTypes[type];
list[type + name] = /** @type {EasingFunctionWithParams|EasingFunction} */(
name === emptyString || name === 'Back' || name === 'Elastic' ?
(a, b) => easeType(/** @type {EasingFunctionWithParams} */(easeIn)(a, b)) :
easeType(/** @type {EasingFunction} */(easeIn))
);
}
}
return /** @type {EasesFunctions} */(list);
})());
/** @type {Record<String, EasingFunction>} */
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 => {
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 { easeInPower, easeTypes, eases, parseEase, parseEaseString };
@@ -0,0 +1,26 @@
/**
* Anime.js - easings - CJS
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
'use strict';
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.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;
@@ -0,0 +1,6 @@
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";
@@ -0,0 +1,13 @@
/**
* Anime.js - easings - ESM
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
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';
@@ -0,0 +1,41 @@
/**
* Anime.js - easings - CJS
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
'use strict';
var helpers = require('../../core/helpers.cjs');
var index = require('../linear/index.cjs');
/**
* @import {
* EasingFunction,
* } from '../../types/index.js'
*/
/**
* 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(helpers.clamp(randomValue, previousValue, 1));
}
values.push(1);
return index.linear(...values);
};
exports.irregular = irregular;
@@ -0,0 +1,2 @@
export function irregular(length?: number, randomness?: number): EasingFunction;
import type { EasingFunction } from '../../types/index.js';
@@ -0,0 +1,39 @@
/**
* Anime.js - easings - ESM
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
import { clamp } from '../../core/helpers.js';
import { linear } from '../linear/index.js';
/**
* @import {
* EasingFunction,
* } from '../../types/index.js'
*/
/**
* 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);
};
export { irregular };
@@ -0,0 +1,59 @@
/**
* Anime.js - easings - CJS
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
'use strict';
var helpers = require('../../core/helpers.cjs');
var none = require('../none.cjs');
/**
* @import {
* EasingFunction,
* } from '../../types/index.js'
*/
/**
* 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.none;
const totalPoints = argsLength - 1;
const firstArg = args[0];
const lastArg = args[totalPoints];
const xPoints = [0];
const yPoints = [helpers.parseNumber(firstArg)];
for (let i = 1; i < totalPoints; i++) {
const arg = args[i];
const splitValue = helpers.isStr(arg) ?
/** @type {String} */(arg).trim().split(' ') :
[arg];
const value = splitValue[0];
const percent = splitValue[1];
xPoints.push(!helpers.isUnd(percent) ? helpers.parseNumber(percent) / 100 : i / totalPoints);
yPoints.push(helpers.parseNumber(value));
}
yPoints.push(helpers.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];
}
};
exports.linear = linear;
@@ -0,0 +1,2 @@
export function linear(...args: (string | number)[]): EasingFunction;
import type { EasingFunction } from '../../types/index.js';
@@ -0,0 +1,57 @@
/**
* Anime.js - easings - ESM
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
import { isStr, parseNumber, isUnd } from '../../core/helpers.js';
import { none } from '../none.js';
/**
* @import {
* EasingFunction,
* } from '../../types/index.js'
*/
/**
* 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];
}
};
export { linear };
@@ -0,0 +1,19 @@
/**
* Anime.js - easings - CJS
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
'use strict';
/**
* @import {
* EasingFunction,
* } from '../types/index.js'
*/
/** @type {EasingFunction} */
const none = t => t;
exports.none = none;
@@ -0,0 +1,8 @@
/**
* @import {
* EasingFunction,
* } from '../types/index.js'
*/
/** @type {EasingFunction} */
export const none: EasingFunction;
import type { EasingFunction } from '../types/index.js';
@@ -0,0 +1,17 @@
/**
* Anime.js - easings - ESM
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
/**
* @import {
* EasingFunction,
* } from '../types/index.js'
*/
/** @type {EasingFunction} */
const none = t => t;
export { none };
@@ -0,0 +1,255 @@
/**
* Anime.js - easings - CJS
* @version v4.5.0
* @license MIT
* @copyright 2026 - 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;
@@ -0,0 +1,53 @@
export class Spring {
/**
* @param {SpringParams} [parameters]
*/
constructor(parameters?: SpringParams);
timeStep: number;
restThreshold: number;
restDuration: number;
maxDuration: number;
maxRestSteps: number;
maxIterations: number;
bn: number;
pd: number;
m: number;
s: number;
d: number;
v: number;
w0: number;
zeta: number;
wd: number;
b: number;
completed: boolean;
solverDuration: 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 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 { 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';
@@ -0,0 +1,251 @@
/**
* Anime.js - easings - ESM
* @version v4.5.0
* @license MIT
* @copyright 2026 - 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 };
@@ -0,0 +1,30 @@
/**
* Anime.js - easings - CJS
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
'use strict';
var helpers = require('../../core/helpers.cjs');
/**
* @import {
* EasingFunction,
* } from '../../types/index.js'
*/
/**
* 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 ? helpers.ceil : helpers.floor;
return t => roundMethod(helpers.clamp(t, 0, 1) * steps) * (1 / steps);
};
exports.steps = steps;
@@ -0,0 +1,2 @@
export function steps(steps?: number, fromStart?: boolean): EasingFunction;
import type { EasingFunction } from '../../types/index.js';
@@ -0,0 +1,28 @@
/**
* Anime.js - easings - ESM
* @version v4.5.0
* @license MIT
* @copyright 2026 - Julian Garnier
*/
import { ceil, floor, clamp } from '../../core/helpers.js';
/**
* @import {
* EasingFunction,
* } from '../../types/index.js'
*/
/**
* 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);
};
export { steps };