Files
SnowLuma/.pnpm-store/v11/files/38/c7cabbd7de8e3dfc1015e558d76c7c8b518abcc15e6f1fee7ec14fcf24623eabe90aebf8fee9d909bcb48811f8483098e8ab8ffda0baf64b3522e35bdbd38d
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

28 lines
879 B
Plaintext

import { easingDefinitionToFunction } from 'motion-utils';
function getOriginIndex(from, total) {
if (from === "first") {
return 0;
}
else {
const lastIndex = total - 1;
return from === "last" ? lastIndex : lastIndex / 2;
}
}
function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
return (i, total) => {
const fromIndex = typeof from === "number" ? from : getOriginIndex(from, total);
const distance = Math.abs(fromIndex - i);
let delay = duration * distance;
if (ease) {
const maxDelay = total * duration;
const easingFunction = easingDefinitionToFunction(ease);
delay = easingFunction(delay / maxDelay) * maxDelay;
}
return startDelay + delay;
};
}
export { getOriginIndex, stagger };
//# sourceMappingURL=stagger.mjs.map