motion-dom 12.20.3 → 12.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +25 -0
- package/dist/es/index.mjs +1 -0
- package/dist/es/utils/stagger.mjs +26 -0
- package/dist/index.d.ts +291 -279
- package/dist/motion-dom.dev.js +25 -0
- package/dist/motion-dom.js +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -4115,6 +4115,29 @@ function isSVGSVGElement(element) {
|
|
|
4115
4115
|
return isSVGElement(element) && element.tagName === "svg";
|
|
4116
4116
|
}
|
|
4117
4117
|
|
|
4118
|
+
function getOriginIndex(from, total) {
|
|
4119
|
+
if (from === "first") {
|
|
4120
|
+
return 0;
|
|
4121
|
+
}
|
|
4122
|
+
else {
|
|
4123
|
+
const lastIndex = total - 1;
|
|
4124
|
+
return from === "last" ? lastIndex : lastIndex / 2;
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
|
|
4128
|
+
return (i, total) => {
|
|
4129
|
+
const fromIndex = typeof from === "number" ? from : getOriginIndex(from, total);
|
|
4130
|
+
const distance = Math.abs(fromIndex - i);
|
|
4131
|
+
let delay = duration * distance;
|
|
4132
|
+
if (ease) {
|
|
4133
|
+
const maxDelay = total * duration;
|
|
4134
|
+
const easingFunction = motionUtils.easingDefinitionToFunction(ease);
|
|
4135
|
+
delay = easingFunction(delay / maxDelay) * maxDelay;
|
|
4136
|
+
}
|
|
4137
|
+
return startDelay + delay;
|
|
4138
|
+
};
|
|
4139
|
+
}
|
|
4140
|
+
|
|
4118
4141
|
function transform(...args) {
|
|
4119
4142
|
const useImmediate = !Array.isArray(args[0]);
|
|
4120
4143
|
const argOffset = useImmediate ? 0 : -1;
|
|
@@ -4667,6 +4690,7 @@ exports.getAnimationMap = getAnimationMap;
|
|
|
4667
4690
|
exports.getComputedStyle = getComputedStyle$1;
|
|
4668
4691
|
exports.getDefaultValueType = getDefaultValueType;
|
|
4669
4692
|
exports.getMixer = getMixer;
|
|
4693
|
+
exports.getOriginIndex = getOriginIndex;
|
|
4670
4694
|
exports.getValueAsType = getValueAsType;
|
|
4671
4695
|
exports.getValueTransition = getValueTransition;
|
|
4672
4696
|
exports.getVariableValue = getVariableValue;
|
|
@@ -4726,6 +4750,7 @@ exports.setDragLock = setDragLock;
|
|
|
4726
4750
|
exports.setStyle = setStyle;
|
|
4727
4751
|
exports.spring = spring;
|
|
4728
4752
|
exports.springValue = springValue;
|
|
4753
|
+
exports.stagger = stagger;
|
|
4729
4754
|
exports.startWaapiAnimation = startWaapiAnimation;
|
|
4730
4755
|
exports.statsBuffer = statsBuffer;
|
|
4731
4756
|
exports.styleEffect = styleEffect;
|
package/dist/es/index.mjs
CHANGED
|
@@ -65,6 +65,7 @@ export { mixImmediate } from './utils/mix/immediate.mjs';
|
|
|
65
65
|
export { mixNumber } from './utils/mix/number.mjs';
|
|
66
66
|
export { invisibleValues, mixVisibility } from './utils/mix/visibility.mjs';
|
|
67
67
|
export { resolveElements } from './utils/resolve-elements.mjs';
|
|
68
|
+
export { getOriginIndex, stagger } from './utils/stagger.mjs';
|
|
68
69
|
export { supportsFlags } from './utils/supports/flags.mjs';
|
|
69
70
|
export { supportsLinearEasing } from './utils/supports/linear-easing.mjs';
|
|
70
71
|
export { supportsScrollTimeline } from './utils/supports/scroll-timeline.mjs';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { easingDefinitionToFunction } from 'motion-utils';
|
|
2
|
+
|
|
3
|
+
function getOriginIndex(from, total) {
|
|
4
|
+
if (from === "first") {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
const lastIndex = total - 1;
|
|
9
|
+
return from === "last" ? lastIndex : lastIndex / 2;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
|
|
13
|
+
return (i, total) => {
|
|
14
|
+
const fromIndex = typeof from === "number" ? from : getOriginIndex(from, total);
|
|
15
|
+
const distance = Math.abs(fromIndex - i);
|
|
16
|
+
let delay = duration * distance;
|
|
17
|
+
if (ease) {
|
|
18
|
+
const maxDelay = total * duration;
|
|
19
|
+
const easingFunction = easingDefinitionToFunction(ease);
|
|
20
|
+
delay = easingFunction(delay / maxDelay) * maxDelay;
|
|
21
|
+
}
|
|
22
|
+
return startDelay + delay;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { getOriginIndex, stagger };
|