framer-motion 12.7.3 → 12.7.5-alpha.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/README.md +1 -1
- package/dist/cjs/client.js +1 -1
- package/dist/cjs/{create-DwAwaNot.js → create-C7kXmWbI.js} +99 -2828
- package/dist/cjs/dom-mini.js +82 -66
- package/dist/cjs/dom.js +264 -3000
- package/dist/cjs/index.js +163 -218
- package/dist/cjs/m.js +13 -170
- package/dist/cjs/mini.js +77 -9
- package/dist/dom-mini.js +1 -1
- package/dist/dom.d.ts +5 -94
- package/dist/dom.js +1 -1
- package/dist/es/animation/animate/sequence.mjs +1 -1
- package/dist/es/animation/animators/waapi/animate-elements.mjs +78 -10
- package/dist/es/animation/interfaces/motion-value.mjs +11 -30
- package/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
- package/dist/es/animation/optimized-appear/store-id.mjs +1 -1
- package/dist/es/animation/sequence/create.mjs +2 -5
- package/dist/es/animation/sequence/utils/edit.mjs +2 -3
- package/dist/es/animation/utils/default-transitions.mjs +1 -1
- package/dist/es/animation/utils/stagger.mjs +1 -1
- package/dist/es/components/AnimatePresence/PresenceChild.mjs +26 -23
- package/dist/es/components/Reorder/utils/check-reorder.mjs +1 -1
- package/dist/es/dom.mjs +2 -18
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +1 -3
- package/dist/es/gestures/drag/utils/constraints.mjs +2 -3
- package/dist/es/gestures/focus.mjs +1 -1
- package/dist/es/gestures/pan/PanSession.mjs +1 -2
- package/dist/es/index.mjs +3 -24
- package/dist/es/motion/utils/is-forced-motion-value.mjs +1 -1
- package/dist/es/projection/animation/mix-values.mjs +2 -4
- package/dist/es/projection/geometry/delta-apply.mjs +1 -1
- package/dist/es/projection/geometry/delta-calc.mjs +1 -1
- package/dist/es/projection/geometry/delta-remove.mjs +1 -2
- package/dist/es/projection/node/create-projection-node.mjs +3 -7
- package/dist/es/projection/styles/scale-border-radius.mjs +1 -1
- package/dist/es/projection/styles/scale-box-shadow.mjs +1 -2
- package/dist/es/projection/styles/scale-correction.mjs +1 -1
- package/dist/es/projection.mjs +1 -3
- package/dist/es/render/VisualElement.mjs +2 -9
- package/dist/es/render/dom/DOMVisualElement.mjs +1 -1
- package/dist/es/render/dom/scroll/attach-animation.mjs +17 -0
- package/dist/es/render/dom/scroll/attach-function.mjs +23 -0
- package/dist/es/render/dom/scroll/index.mjs +6 -82
- package/dist/es/render/dom/scroll/offsets/index.mjs +2 -3
- package/dist/es/render/dom/scroll/utils/get-timeline.mjs +29 -0
- package/dist/es/render/html/HTMLVisualElement.mjs +1 -3
- package/dist/es/render/html/utils/build-styles.mjs +1 -4
- package/dist/es/render/html/utils/build-transform.mjs +1 -3
- package/dist/es/render/svg/SVGVisualElement.mjs +1 -3
- package/dist/es/render/svg/config-motion.mjs +1 -2
- package/dist/es/render/svg/utils/path.mjs +1 -1
- package/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -1
- package/dist/es/render/svg/utils/transform-origin.mjs +1 -1
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/utils/delay.mjs +1 -1
- package/dist/es/utils/transform.mjs +1 -1
- package/dist/es/utils/use-cycle.mjs +1 -1
- package/dist/es/utils/use-instant-transition.mjs +4 -4
- package/dist/es/value/use-spring.mjs +2 -3
- package/dist/es/value/use-will-change/get-will-change-name.mjs +1 -2
- package/dist/framer-motion.dev.js +3881 -3419
- package/dist/framer-motion.js +1 -1
- package/dist/m.d.ts +3 -50
- package/dist/mini.js +1 -1
- package/dist/size-rollup-animate.js +1 -1
- package/dist/size-rollup-dom-animation-assets.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max-assets.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-rollup-scroll.js +1 -1
- package/dist/size-rollup-waapi-animate.js +1 -1
- package/dist/types/client.d.ts +4 -3
- package/dist/types/index.d.ts +56 -351
- package/dist/{types.d-B50aGbjN.d.ts → types.d-B1Voffvi.d.ts} +3 -138
- package/package.json +9 -9
- package/dist/es/animation/animators/AcceleratedAnimation.mjs +0 -319
- package/dist/es/animation/animators/BaseAnimation.mjs +0 -120
- package/dist/es/animation/animators/MainThreadAnimation.mjs +0 -394
- package/dist/es/animation/animators/drivers/driver-frameloop.mjs +0 -16
- package/dist/es/animation/animators/utils/accelerated-values.mjs +0 -14
- package/dist/es/animation/animators/utils/can-animate.mjs +0 -42
- package/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +0 -5
- package/dist/es/animation/generators/inertia.mjs +0 -87
- package/dist/es/animation/generators/keyframes.mjs +0 -51
- package/dist/es/animation/generators/spring/defaults.mjs +0 -27
- package/dist/es/animation/generators/spring/find.mjs +0 -85
- package/dist/es/animation/generators/spring/index.mjs +0 -174
- package/dist/es/animation/generators/utils/velocity.mjs +0 -9
- package/dist/es/animation/utils/is-animatable.mjs +0 -30
- package/dist/es/animation/utils/is-none.mjs +0 -15
- package/dist/es/easing/anticipate.mjs +0 -5
- package/dist/es/easing/back.mjs +0 -9
- package/dist/es/easing/circ.mjs +0 -8
- package/dist/es/easing/cubic-bezier.mjs +0 -51
- package/dist/es/easing/ease.mjs +0 -7
- package/dist/es/easing/modifiers/mirror.mjs +0 -5
- package/dist/es/easing/modifiers/reverse.mjs +0 -5
- package/dist/es/easing/steps.mjs +0 -15
- package/dist/es/easing/utils/get-easing-for-segment.mjs +0 -8
- package/dist/es/easing/utils/is-easing-array.mjs +0 -5
- package/dist/es/easing/utils/map.mjs +0 -37
- package/dist/es/render/dom/DOMKeyframesResolver.mjs +0 -130
- package/dist/es/render/dom/scroll/observe.mjs +0 -18
- package/dist/es/render/dom/utils/css-variables-conversion.mjs +0 -42
- package/dist/es/render/dom/utils/is-css-variable.mjs +0 -15
- package/dist/es/render/dom/utils/unit-conversion.mjs +0 -36
- package/dist/es/render/dom/value-types/animatable-none.mjs +0 -15
- package/dist/es/render/dom/value-types/defaults.mjs +0 -30
- package/dist/es/render/dom/value-types/dimensions.mjs +0 -15
- package/dist/es/render/dom/value-types/find.mjs +0 -15
- package/dist/es/render/dom/value-types/get-as-type.mjs +0 -10
- package/dist/es/render/dom/value-types/number-browser.mjs +0 -41
- package/dist/es/render/dom/value-types/number.mjs +0 -18
- package/dist/es/render/dom/value-types/test.mjs +0 -6
- package/dist/es/render/dom/value-types/transform.mjs +0 -31
- package/dist/es/render/dom/value-types/type-auto.mjs +0 -9
- package/dist/es/render/dom/value-types/type-int.mjs +0 -8
- package/dist/es/render/html/utils/keys-position.mjs +0 -13
- package/dist/es/render/html/utils/keys-transform.mjs +0 -28
- package/dist/es/render/html/utils/make-none-animatable.mjs +0 -30
- package/dist/es/render/html/utils/parse-transform.mjs +0 -83
- package/dist/es/render/utils/KeyframesResolver.mjs +0 -163
- package/dist/es/utils/clamp.mjs +0 -9
- package/dist/es/utils/hsla-to-rgba.mjs +0 -42
- package/dist/es/utils/interpolate.mjs +0 -76
- package/dist/es/utils/is-numerical-string.mjs +0 -6
- package/dist/es/utils/is-zero-value-string.mjs +0 -6
- package/dist/es/utils/mix/color.mjs +0 -47
- package/dist/es/utils/mix/complex.mjs +0 -93
- package/dist/es/utils/mix/immediate.mjs +0 -5
- package/dist/es/utils/mix/index.mjs +0 -14
- package/dist/es/utils/mix/number.mjs +0 -26
- package/dist/es/utils/mix/visibility.mjs +0 -16
- package/dist/es/utils/offsets/default.mjs +0 -9
- package/dist/es/utils/offsets/fill.mjs +0 -12
- package/dist/es/utils/offsets/time.mjs +0 -5
- package/dist/es/utils/pipe.mjs +0 -11
- package/dist/es/utils/use-instant-transition-state.mjs +0 -5
- package/dist/es/utils/wrap.mjs +0 -6
- package/dist/es/value/types/color/hex.mjs +0 -40
- package/dist/es/value/types/color/hsla.mjs +0 -22
- package/dist/es/value/types/color/index.mjs +0 -27
- package/dist/es/value/types/color/rgba.mjs +0 -25
- package/dist/es/value/types/color/utils.mjs +0 -29
- package/dist/es/value/types/complex/filter.mjs +0 -30
- package/dist/es/value/types/complex/index.mjs +0 -91
- package/dist/es/value/types/numbers/index.mjs +0 -17
- package/dist/es/value/types/numbers/units.mjs +0 -17
- package/dist/es/value/types/utils/color-regex.mjs +0 -3
- package/dist/es/value/types/utils/float-regex.mjs +0 -3
- package/dist/es/value/types/utils/is-nullish.mjs +0 -5
- package/dist/es/value/types/utils/sanitize.mjs +0 -5
- package/dist/es/value/types/utils/single-color-regex.mjs +0 -3
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var create = require('./create-
|
|
7
|
+
var create = require('./create-C7kXmWbI.js');
|
|
8
8
|
var motionDom = require('motion-dom');
|
|
9
9
|
var motionUtils = require('motion-utils');
|
|
10
10
|
|
|
@@ -105,33 +105,36 @@ function PopChild({ children, isPresent, anchorX }) {
|
|
|
105
105
|
const PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, anchorX, }) => {
|
|
106
106
|
const presenceChildren = create.useConstant(newChildrenMap);
|
|
107
107
|
const id = React.useId();
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
108
|
+
let isReusedContext = true;
|
|
109
|
+
let context = React.useMemo(() => {
|
|
110
|
+
isReusedContext = false;
|
|
111
|
+
return {
|
|
112
|
+
id,
|
|
113
|
+
initial,
|
|
114
|
+
isPresent,
|
|
115
|
+
custom,
|
|
116
|
+
onExitComplete: (childId) => {
|
|
117
|
+
presenceChildren.set(childId, true);
|
|
118
|
+
for (const isComplete of presenceChildren.values()) {
|
|
119
|
+
if (!isComplete)
|
|
120
|
+
return; // can stop searching when any is incomplete
|
|
121
|
+
}
|
|
122
|
+
onExitComplete && onExitComplete();
|
|
123
|
+
},
|
|
124
|
+
register: (childId) => {
|
|
125
|
+
presenceChildren.set(childId, false);
|
|
126
|
+
return () => presenceChildren.delete(childId);
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}, [isPresent, presenceChildren, onExitComplete]);
|
|
127
130
|
/**
|
|
128
131
|
* If the presence of a child affects the layout of the components around it,
|
|
129
132
|
* we want to make a new context value to ensure they get re-rendered
|
|
130
133
|
* so they can detect that layout change.
|
|
131
134
|
*/
|
|
132
|
-
presenceAffectsLayout
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
if (presenceAffectsLayout && isReusedContext) {
|
|
136
|
+
context = { ...context };
|
|
137
|
+
}
|
|
135
138
|
React.useMemo(() => {
|
|
136
139
|
presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
|
|
137
140
|
}, [isPresent]);
|
|
@@ -550,7 +553,7 @@ function checkReorder(order, value, offset, velocity) {
|
|
|
550
553
|
return order;
|
|
551
554
|
const item = order[index];
|
|
552
555
|
const nextLayout = nextItem.layout;
|
|
553
|
-
const nextItemCenter =
|
|
556
|
+
const nextItemCenter = motionDom.mixNumber(nextLayout.min, nextLayout.max, 0.5);
|
|
554
557
|
if ((nextOffset === 1 && item.layout.max + offset > nextItemCenter) ||
|
|
555
558
|
(nextOffset === -1 && item.layout.min + offset < nextItemCenter)) {
|
|
556
559
|
return motionUtils.moveItem(order, index, index + nextOffset);
|
|
@@ -644,7 +647,7 @@ function transform(...args) {
|
|
|
644
647
|
const inputRange = args[1 + argOffset];
|
|
645
648
|
const outputRange = args[2 + argOffset];
|
|
646
649
|
const options = args[3 + argOffset];
|
|
647
|
-
const interpolator =
|
|
650
|
+
const interpolator = motionDom.interpolate(inputRange, outputRange, {
|
|
648
651
|
mixer: getMixer(outputRange[0]),
|
|
649
652
|
...options,
|
|
650
653
|
});
|
|
@@ -749,15 +752,6 @@ var namespace = /*#__PURE__*/Object.freeze({
|
|
|
749
752
|
Item: ReorderItem
|
|
750
753
|
});
|
|
751
754
|
|
|
752
|
-
const wrap = (min, max, v) => {
|
|
753
|
-
const rangeSize = max - min;
|
|
754
|
-
return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
function getEasingForSegment(easing, i) {
|
|
758
|
-
return create.isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
755
|
function isDOMKeyframes(keyframes) {
|
|
762
756
|
return typeof keyframes === "object" && !Array.isArray(keyframes);
|
|
763
757
|
}
|
|
@@ -820,8 +814,8 @@ function addKeyframes(sequence, keyframes, easing, offset, startTime, endTime) {
|
|
|
820
814
|
for (let i = 0; i < keyframes.length; i++) {
|
|
821
815
|
sequence.push({
|
|
822
816
|
value: keyframes[i],
|
|
823
|
-
at:
|
|
824
|
-
easing: getEasingForSegment(easing, i),
|
|
817
|
+
at: motionDom.mixNumber(startTime, endTime, offset[i]),
|
|
818
|
+
easing: motionUtils.getEasingForSegment(easing, i),
|
|
825
819
|
});
|
|
826
820
|
}
|
|
827
821
|
}
|
|
@@ -895,7 +889,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
895
889
|
let maxDuration = 0;
|
|
896
890
|
const resolveValueSequence = (valueKeyframes, valueTransition, valueSequence, elementIndex = 0, numSubjects = 0) => {
|
|
897
891
|
const valueKeyframesAsList = keyframesAsList(valueKeyframes);
|
|
898
|
-
const { delay = 0, times =
|
|
892
|
+
const { delay = 0, times = motionDom.defaultOffset(valueKeyframesAsList), type = "keyframes", repeat, repeatType, repeatDelay = 0, ...remainingTransition } = valueTransition;
|
|
899
893
|
let { ease = defaultTransition.ease || "easeOut", duration } = valueTransition;
|
|
900
894
|
/**
|
|
901
895
|
* Resolve stagger() if defined.
|
|
@@ -943,7 +937,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
943
937
|
* Fill out if offset if fewer offsets than keyframes
|
|
944
938
|
*/
|
|
945
939
|
const remainder = times.length - valueKeyframesAsList.length;
|
|
946
|
-
remainder > 0 &&
|
|
940
|
+
remainder > 0 && motionDom.fillOffset(times, remainder);
|
|
947
941
|
/**
|
|
948
942
|
* If only one value has been set, ie [1], push a null to the start of
|
|
949
943
|
* the keyframe array. This will let us mark a keyframe at this point
|
|
@@ -967,7 +961,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
967
961
|
times.push(originalTimes[keyframeIndex] + (repeatIndex + 1));
|
|
968
962
|
ease.push(keyframeIndex === 0
|
|
969
963
|
? "linear"
|
|
970
|
-
: getEasingForSegment(originalEase, keyframeIndex - 1));
|
|
964
|
+
: motionUtils.getEasingForSegment(originalEase, keyframeIndex - 1));
|
|
971
965
|
}
|
|
972
966
|
}
|
|
973
967
|
normalizeTimes(times, repeat);
|
|
@@ -1208,7 +1202,7 @@ function animateSubject(subject, keyframes, options, scope) {
|
|
|
1208
1202
|
|
|
1209
1203
|
function animateSequence(sequence, options, scope) {
|
|
1210
1204
|
const animations = [];
|
|
1211
|
-
const animationDefinitions = createAnimationsFromSequence(sequence, options, scope, { spring:
|
|
1205
|
+
const animationDefinitions = createAnimationsFromSequence(sequence, options, scope, { spring: motionDom.spring });
|
|
1212
1206
|
animationDefinitions.forEach(({ keyframes, transition }, subject) => {
|
|
1213
1207
|
animations.push(...animateSubject(subject, keyframes, transition));
|
|
1214
1208
|
});
|
|
@@ -1248,7 +1242,27 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
1248
1242
|
const elements = motionDom.resolveElements(elementOrSelector, scope);
|
|
1249
1243
|
const numElements = elements.length;
|
|
1250
1244
|
motionUtils.invariant(Boolean(numElements), "No valid element provided.");
|
|
1251
|
-
|
|
1245
|
+
/**
|
|
1246
|
+
* WAAPI doesn't support interrupting animations.
|
|
1247
|
+
*
|
|
1248
|
+
* Therefore, starting animations requires a three-step process:
|
|
1249
|
+
* 1. Stop existing animations (write styles to DOM)
|
|
1250
|
+
* 2. Resolve keyframes (read styles from DOM)
|
|
1251
|
+
* 3. Create new animations (write styles to DOM)
|
|
1252
|
+
*
|
|
1253
|
+
* The hybrid `animate()` function uses AsyncAnimation to resolve
|
|
1254
|
+
* keyframes before creating new animations, which removes style
|
|
1255
|
+
* thrashing. Here, we have much stricter filesize constraints.
|
|
1256
|
+
* Therefore we do this in a synchronous way that ensures that
|
|
1257
|
+
* at least within `animate()` calls there is no style thrashing.
|
|
1258
|
+
*
|
|
1259
|
+
* In the motion-native-animate-mini-interrupt benchmark this
|
|
1260
|
+
* was 80% faster than a single loop.
|
|
1261
|
+
*/
|
|
1262
|
+
const animationDefinitions = [];
|
|
1263
|
+
/**
|
|
1264
|
+
* Step 1: Build options and stop existing animations (write)
|
|
1265
|
+
*/
|
|
1252
1266
|
for (let i = 0; i < numElements; i++) {
|
|
1253
1267
|
const element = elements[i];
|
|
1254
1268
|
const elementTransition = { ...options };
|
|
@@ -1259,21 +1273,69 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
1259
1273
|
elementTransition.delay = elementTransition.delay(i, numElements);
|
|
1260
1274
|
}
|
|
1261
1275
|
for (const valueName in keyframes) {
|
|
1262
|
-
|
|
1276
|
+
let valueKeyframes = keyframes[valueName];
|
|
1277
|
+
if (!Array.isArray(valueKeyframes)) {
|
|
1278
|
+
valueKeyframes = [valueKeyframes];
|
|
1279
|
+
}
|
|
1263
1280
|
const valueOptions = {
|
|
1264
1281
|
...motionDom.getValueTransition(elementTransition, valueName),
|
|
1265
1282
|
};
|
|
1266
1283
|
valueOptions.duration && (valueOptions.duration = motionUtils.secondsToMilliseconds(valueOptions.duration));
|
|
1267
1284
|
valueOptions.delay && (valueOptions.delay = motionUtils.secondsToMilliseconds(valueOptions.delay));
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1285
|
+
/**
|
|
1286
|
+
* If there's an existing animation playing on this element then stop it
|
|
1287
|
+
* before creating a new one.
|
|
1288
|
+
*/
|
|
1289
|
+
const map = motionDom.getAnimationMap(element);
|
|
1290
|
+
const key = motionDom.animationMapKey(valueName, valueOptions.pseudoElement || "");
|
|
1291
|
+
const currentAnimation = map.get(key);
|
|
1292
|
+
currentAnimation && currentAnimation.stop();
|
|
1293
|
+
animationDefinitions.push({
|
|
1294
|
+
map,
|
|
1295
|
+
key,
|
|
1296
|
+
unresolvedKeyframes: valueKeyframes,
|
|
1297
|
+
options: {
|
|
1298
|
+
...valueOptions,
|
|
1299
|
+
element,
|
|
1300
|
+
name: valueName,
|
|
1301
|
+
allowFlatten: !elementTransition.type && !elementTransition.ease,
|
|
1302
|
+
},
|
|
1303
|
+
});
|
|
1275
1304
|
}
|
|
1276
1305
|
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Step 2: Resolve keyframes (read)
|
|
1308
|
+
*/
|
|
1309
|
+
for (let i = 0; i < animationDefinitions.length; i++) {
|
|
1310
|
+
const { unresolvedKeyframes, options: animationOptions } = animationDefinitions[i];
|
|
1311
|
+
const { element, name, pseudoElement } = animationOptions;
|
|
1312
|
+
if (!pseudoElement && unresolvedKeyframes[0] === null) {
|
|
1313
|
+
unresolvedKeyframes[0] = motionDom.getComputedStyle(element, name);
|
|
1314
|
+
}
|
|
1315
|
+
motionDom.fillWildcards(unresolvedKeyframes);
|
|
1316
|
+
motionDom.applyPxDefaults(unresolvedKeyframes, name);
|
|
1317
|
+
/**
|
|
1318
|
+
* If we only have one keyframe, explicitly read the initial keyframe
|
|
1319
|
+
* from the computed style. This is to ensure consistency with WAAPI behaviour
|
|
1320
|
+
* for restarting animations, for instance .play() after finish, when it
|
|
1321
|
+
* has one vs two keyframes.
|
|
1322
|
+
*/
|
|
1323
|
+
if (!pseudoElement && unresolvedKeyframes.length < 2) {
|
|
1324
|
+
unresolvedKeyframes.unshift(motionDom.getComputedStyle(element, name));
|
|
1325
|
+
}
|
|
1326
|
+
animationOptions.keyframes = unresolvedKeyframes;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Step 3: Create new animations (write)
|
|
1330
|
+
*/
|
|
1331
|
+
const animations = [];
|
|
1332
|
+
for (let i = 0; i < animationDefinitions.length; i++) {
|
|
1333
|
+
const { map, key, options: animationOptions } = animationDefinitions[i];
|
|
1334
|
+
const animation = new motionDom.NativeAnimation(animationOptions);
|
|
1335
|
+
map.set(key, animation);
|
|
1336
|
+
animation.finished.finally(() => map.delete(key));
|
|
1337
|
+
animations.push(animation);
|
|
1338
|
+
}
|
|
1277
1339
|
return animations;
|
|
1278
1340
|
}
|
|
1279
1341
|
|
|
@@ -1285,21 +1347,6 @@ const createScopedWaapiAnimate = (scope) => {
|
|
|
1285
1347
|
};
|
|
1286
1348
|
const animateMini = /*@__PURE__*/ createScopedWaapiAnimate();
|
|
1287
1349
|
|
|
1288
|
-
function observeTimeline(update, timeline) {
|
|
1289
|
-
let prevProgress;
|
|
1290
|
-
const onFrame = () => {
|
|
1291
|
-
const { currentTime } = timeline;
|
|
1292
|
-
const percentage = currentTime === null ? 0 : currentTime.value;
|
|
1293
|
-
const progress = percentage / 100;
|
|
1294
|
-
if (prevProgress !== progress) {
|
|
1295
|
-
update(progress);
|
|
1296
|
-
}
|
|
1297
|
-
prevProgress = progress;
|
|
1298
|
-
};
|
|
1299
|
-
motionDom.frame.update(onFrame, true);
|
|
1300
|
-
return () => motionDom.cancelFrame(onFrame);
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
1350
|
const resizeHandlers = new WeakMap();
|
|
1304
1351
|
let observer;
|
|
1305
1352
|
function getElementSize(target, borderBoxSize) {
|
|
@@ -1630,10 +1677,10 @@ function resolveOffsets(container, info, options) {
|
|
|
1630
1677
|
* to map scroll value into a progress.
|
|
1631
1678
|
*/
|
|
1632
1679
|
if (hasChanged) {
|
|
1633
|
-
info[axis].interpolate =
|
|
1680
|
+
info[axis].interpolate = motionDom.interpolate(info[axis].offset, motionDom.defaultOffset(offsetDefinition), { clamp: false });
|
|
1634
1681
|
info[axis].interpolatorOffsets = [...info[axis].offset];
|
|
1635
1682
|
}
|
|
1636
|
-
info[axis].progress =
|
|
1683
|
+
info[axis].progress = motionUtils.clamp(0, 1, info[axis].interpolate(info[axis].current));
|
|
1637
1684
|
}
|
|
1638
1685
|
|
|
1639
1686
|
function measure(container, target = container, info) {
|
|
@@ -1756,19 +1803,16 @@ function scrollInfo(onScroll, { container = document.documentElement, ...options
|
|
|
1756
1803
|
};
|
|
1757
1804
|
}
|
|
1758
1805
|
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
if (source)
|
|
1762
|
-
container = source;
|
|
1763
|
-
// ScrollTimeline records progress as a percentage CSSUnitValue
|
|
1806
|
+
const timelineCache = new Map();
|
|
1807
|
+
function scrollTimelineFallback(options) {
|
|
1764
1808
|
const currentTime = { value: 0 };
|
|
1765
1809
|
const cancel = scrollInfo((info) => {
|
|
1766
|
-
currentTime.value = info[axis].progress * 100;
|
|
1767
|
-
},
|
|
1810
|
+
currentTime.value = info[options.axis].progress * 100;
|
|
1811
|
+
}, options);
|
|
1768
1812
|
return { currentTime, cancel };
|
|
1769
1813
|
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1814
|
+
function getTimeline({ source, container, ...options }) {
|
|
1815
|
+
const { axis } = options;
|
|
1772
1816
|
// Support legacy source argument. Deprecate later.
|
|
1773
1817
|
if (source)
|
|
1774
1818
|
container = source;
|
|
@@ -1779,10 +1823,24 @@ function getTimeline({ source, container = document.documentElement, axis = "y",
|
|
|
1779
1823
|
if (!elementCache[axis]) {
|
|
1780
1824
|
elementCache[axis] = motionDom.supportsScrollTimeline()
|
|
1781
1825
|
? new ScrollTimeline({ source: container, axis })
|
|
1782
|
-
: scrollTimelineFallback({
|
|
1826
|
+
: scrollTimelineFallback({ container, ...options });
|
|
1783
1827
|
}
|
|
1784
1828
|
return elementCache[axis];
|
|
1785
1829
|
}
|
|
1830
|
+
|
|
1831
|
+
function attachToAnimation(animation, options) {
|
|
1832
|
+
const timeline = getTimeline(options);
|
|
1833
|
+
return animation.attachTimeline({
|
|
1834
|
+
timeline,
|
|
1835
|
+
observe: (valueAnimation) => {
|
|
1836
|
+
valueAnimation.pause();
|
|
1837
|
+
return motionDom.observeTimeline((progress) => {
|
|
1838
|
+
valueAnimation.time = valueAnimation.duration * progress;
|
|
1839
|
+
}, timeline);
|
|
1840
|
+
},
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1786
1844
|
/**
|
|
1787
1845
|
* If the onScroll function has two arguments, it's expecting
|
|
1788
1846
|
* more specific information about the scroll from scrollInfo.
|
|
@@ -1790,51 +1848,22 @@ function getTimeline({ source, container = document.documentElement, axis = "y",
|
|
|
1790
1848
|
function isOnScrollWithInfo(onScroll) {
|
|
1791
1849
|
return onScroll.length === 2;
|
|
1792
1850
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
* the future we can also offer ViewTimeline support.
|
|
1796
|
-
*/
|
|
1797
|
-
function needsElementTracking(options) {
|
|
1798
|
-
return options && (options.target || options.offset);
|
|
1799
|
-
}
|
|
1800
|
-
function scrollFunction(onScroll, options) {
|
|
1801
|
-
if (isOnScrollWithInfo(onScroll) || needsElementTracking(options)) {
|
|
1851
|
+
function attachToFunction(onScroll, options) {
|
|
1852
|
+
if (isOnScrollWithInfo(onScroll)) {
|
|
1802
1853
|
return scrollInfo((info) => {
|
|
1803
1854
|
onScroll(info[options.axis].progress, info);
|
|
1804
1855
|
}, options);
|
|
1805
1856
|
}
|
|
1806
1857
|
else {
|
|
1807
|
-
return observeTimeline(onScroll, getTimeline(options));
|
|
1858
|
+
return motionDom.observeTimeline(onScroll, getTimeline(options));
|
|
1808
1859
|
}
|
|
1809
1860
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
animation.pause();
|
|
1814
|
-
return scrollInfo((info) => {
|
|
1815
|
-
animation.time = animation.duration * info[options.axis].progress;
|
|
1816
|
-
}, options);
|
|
1817
|
-
}
|
|
1818
|
-
else {
|
|
1819
|
-
const timeline = getTimeline(options);
|
|
1820
|
-
if (animation.attachTimeline) {
|
|
1821
|
-
return animation.attachTimeline(timeline, (valueAnimation) => {
|
|
1822
|
-
valueAnimation.pause();
|
|
1823
|
-
return observeTimeline((progress) => {
|
|
1824
|
-
valueAnimation.time = valueAnimation.duration * progress;
|
|
1825
|
-
}, timeline);
|
|
1826
|
-
});
|
|
1827
|
-
}
|
|
1828
|
-
else {
|
|
1829
|
-
return motionUtils.noop;
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
function scroll(onScroll, { axis = "y", ...options } = {}) {
|
|
1834
|
-
const optionsWithDefaults = { axis, ...options };
|
|
1861
|
+
|
|
1862
|
+
function scroll(onScroll, { axis = "y", container = document.documentElement, ...options } = {}) {
|
|
1863
|
+
const optionsWithDefaults = { axis, container, ...options };
|
|
1835
1864
|
return typeof onScroll === "function"
|
|
1836
|
-
?
|
|
1837
|
-
:
|
|
1865
|
+
? attachToFunction(onScroll, optionsWithDefaults)
|
|
1866
|
+
: attachToAnimation(onScroll, optionsWithDefaults);
|
|
1838
1867
|
}
|
|
1839
1868
|
|
|
1840
1869
|
const thresholds = {
|
|
@@ -1877,18 +1906,6 @@ function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount =
|
|
|
1877
1906
|
return () => observer.disconnect();
|
|
1878
1907
|
}
|
|
1879
1908
|
|
|
1880
|
-
function steps(numSteps, direction = "end") {
|
|
1881
|
-
return (progress) => {
|
|
1882
|
-
progress =
|
|
1883
|
-
direction === "end"
|
|
1884
|
-
? Math.min(progress, 0.999)
|
|
1885
|
-
: Math.max(progress, 0.001);
|
|
1886
|
-
const expanded = progress * numSteps;
|
|
1887
|
-
const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
|
|
1888
|
-
return create.clamp(0, 1, rounded / numSteps);
|
|
1889
|
-
};
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
1909
|
function getOriginIndex(from, total) {
|
|
1893
1910
|
if (from === "first") {
|
|
1894
1911
|
return 0;
|
|
@@ -1905,7 +1922,7 @@ function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
|
|
|
1905
1922
|
let delay = duration * distance;
|
|
1906
1923
|
if (ease) {
|
|
1907
1924
|
const maxDelay = total * duration;
|
|
1908
|
-
const easingFunction =
|
|
1925
|
+
const easingFunction = motionUtils.easingDefinitionToFunction(ease);
|
|
1909
1926
|
delay = easingFunction(delay / maxDelay) * maxDelay;
|
|
1910
1927
|
}
|
|
1911
1928
|
return startDelay + delay;
|
|
@@ -2061,7 +2078,7 @@ function useSpring(source, config = {}) {
|
|
|
2061
2078
|
const latestSetter = React.useRef(motionUtils.noop);
|
|
2062
2079
|
const startAnimation = () => {
|
|
2063
2080
|
stopAnimation();
|
|
2064
|
-
activeSpringAnimation.current =
|
|
2081
|
+
activeSpringAnimation.current = new motionDom.JSAnimation({
|
|
2065
2082
|
keyframes: [asNumber(value.get()), asNumber(latestValue.current)],
|
|
2066
2083
|
velocity: value.getVelocity(),
|
|
2067
2084
|
type: "spring",
|
|
@@ -2153,10 +2170,10 @@ function useVelocity(value) {
|
|
|
2153
2170
|
}
|
|
2154
2171
|
|
|
2155
2172
|
function getWillChangeName(name) {
|
|
2156
|
-
if (
|
|
2173
|
+
if (motionDom.transformProps.has(name)) {
|
|
2157
2174
|
return "transform";
|
|
2158
2175
|
}
|
|
2159
|
-
else if (
|
|
2176
|
+
else if (motionDom.acceleratedValues.has(name)) {
|
|
2160
2177
|
return create.camelToDash(name);
|
|
2161
2178
|
}
|
|
2162
2179
|
}
|
|
@@ -2567,7 +2584,7 @@ function useCycle(...items) {
|
|
|
2567
2584
|
const runCycle = React.useCallback((next) => {
|
|
2568
2585
|
index.current =
|
|
2569
2586
|
typeof next !== "number"
|
|
2570
|
-
? wrap(0, items.length, index.current + 1)
|
|
2587
|
+
? motionUtils.wrap(0, items.length, index.current + 1)
|
|
2571
2588
|
: next;
|
|
2572
2589
|
setItem(items[index.current]);
|
|
2573
2590
|
},
|
|
@@ -2615,12 +2632,12 @@ function useInstantTransition() {
|
|
|
2615
2632
|
*/
|
|
2616
2633
|
if (forcedRenderCount !== unlockOnFrameRef.current)
|
|
2617
2634
|
return;
|
|
2618
|
-
|
|
2635
|
+
motionUtils.MotionGlobalConfig.instantAnimations = false;
|
|
2619
2636
|
}));
|
|
2620
2637
|
}, [forcedRenderCount]);
|
|
2621
2638
|
return (callback) => {
|
|
2622
2639
|
startInstantLayoutTransition(() => {
|
|
2623
|
-
|
|
2640
|
+
motionUtils.MotionGlobalConfig.instantAnimations = true;
|
|
2624
2641
|
forceUpdate();
|
|
2625
2642
|
callback();
|
|
2626
2643
|
unlockOnFrameRef.current = forcedRenderCount + 1;
|
|
@@ -2628,14 +2645,14 @@ function useInstantTransition() {
|
|
|
2628
2645
|
};
|
|
2629
2646
|
}
|
|
2630
2647
|
function disableInstantTransitions() {
|
|
2631
|
-
|
|
2648
|
+
motionUtils.MotionGlobalConfig.instantAnimations = false;
|
|
2632
2649
|
}
|
|
2633
2650
|
|
|
2634
2651
|
const appearAnimationStore = new Map();
|
|
2635
2652
|
const appearComplete = new Map();
|
|
2636
2653
|
|
|
2637
2654
|
const appearStoreId = (elementId, valueName) => {
|
|
2638
|
-
const key =
|
|
2655
|
+
const key = motionDom.transformProps.has(valueName) ? "transform" : valueName;
|
|
2639
2656
|
return `${elementId}: ${key}`;
|
|
2640
2657
|
};
|
|
2641
2658
|
|
|
@@ -2944,7 +2961,6 @@ function useInvertedScale(scale) {
|
|
|
2944
2961
|
return { scaleX, scaleY };
|
|
2945
2962
|
}
|
|
2946
2963
|
|
|
2947
|
-
exports.AcceleratedAnimation = create.AcceleratedAnimation;
|
|
2948
2964
|
exports.FlatTree = create.FlatTree;
|
|
2949
2965
|
exports.LayoutGroupContext = create.LayoutGroupContext;
|
|
2950
2966
|
exports.MotionConfigContext = create.MotionConfigContext;
|
|
@@ -2955,111 +2971,30 @@ exports.VisualElement = create.VisualElement;
|
|
|
2955
2971
|
exports.addPointerEvent = create.addPointerEvent;
|
|
2956
2972
|
exports.addPointerInfo = create.addPointerInfo;
|
|
2957
2973
|
exports.addScaleCorrector = create.addScaleCorrector;
|
|
2958
|
-
exports.animateValue = create.animateValue;
|
|
2959
2974
|
exports.animateVisualElement = create.animateVisualElement;
|
|
2960
2975
|
exports.animations = create.animations;
|
|
2961
|
-
exports.anticipate = create.anticipate;
|
|
2962
|
-
exports.backIn = create.backIn;
|
|
2963
|
-
exports.backInOut = create.backInOut;
|
|
2964
|
-
exports.backOut = create.backOut;
|
|
2965
2976
|
exports.buildTransform = create.buildTransform;
|
|
2966
2977
|
exports.calcLength = create.calcLength;
|
|
2967
|
-
exports.circIn = create.circIn;
|
|
2968
|
-
exports.circInOut = create.circInOut;
|
|
2969
|
-
exports.circOut = create.circOut;
|
|
2970
|
-
exports.clamp = create.clamp;
|
|
2971
|
-
exports.color = create.color;
|
|
2972
|
-
exports.complex = create.complex;
|
|
2973
2978
|
exports.createBox = create.createBox;
|
|
2974
2979
|
exports.createRendererMotionComponent = create.createRendererMotionComponent;
|
|
2975
|
-
exports.cubicBezier = create.cubicBezier;
|
|
2976
2980
|
exports.delay = create.delay;
|
|
2977
2981
|
exports.distance = create.distance;
|
|
2978
2982
|
exports.distance2D = create.distance2D;
|
|
2979
|
-
exports.easeIn = create.easeIn;
|
|
2980
|
-
exports.easeInOut = create.easeInOut;
|
|
2981
|
-
exports.easeOut = create.easeOut;
|
|
2982
2983
|
exports.filterProps = create.filterProps;
|
|
2983
|
-
exports.findSpring = create.findSpring;
|
|
2984
|
-
exports.inertia = create.inertia;
|
|
2985
|
-
exports.interpolate = create.interpolate;
|
|
2986
2984
|
exports.isBrowser = create.isBrowser;
|
|
2987
2985
|
exports.isMotionValue = create.isMotionValue;
|
|
2988
2986
|
exports.isValidMotionProp = create.isValidMotionProp;
|
|
2989
|
-
exports.keyframes = create.keyframes;
|
|
2990
2987
|
exports.makeUseVisualState = create.makeUseVisualState;
|
|
2991
|
-
exports.mirrorEasing = create.mirrorEasing;
|
|
2992
|
-
exports.mix = create.mix;
|
|
2993
2988
|
exports.optimizedAppearDataAttribute = create.optimizedAppearDataAttribute;
|
|
2994
|
-
exports.pipe = create.pipe;
|
|
2995
|
-
exports.px = create.px;
|
|
2996
2989
|
exports.resolveMotionValue = create.resolveMotionValue;
|
|
2997
|
-
exports.reverseEasing = create.reverseEasing;
|
|
2998
|
-
exports.spring = create.spring;
|
|
2999
2990
|
exports.useIsPresent = create.useIsPresent;
|
|
3000
2991
|
exports.useIsomorphicLayoutEffect = create.useIsomorphicLayoutEffect;
|
|
3001
2992
|
exports.usePresence = create.usePresence;
|
|
3002
2993
|
exports.visualElementStore = create.visualElementStore;
|
|
3003
|
-
Object.defineProperty(exports, "MotionValue", {
|
|
3004
|
-
enumerable: true,
|
|
3005
|
-
get: function () { return motionDom.MotionValue; }
|
|
3006
|
-
});
|
|
3007
|
-
Object.defineProperty(exports, "cancelFrame", {
|
|
3008
|
-
enumerable: true,
|
|
3009
|
-
get: function () { return motionDom.cancelFrame; }
|
|
3010
|
-
});
|
|
3011
|
-
Object.defineProperty(exports, "cancelSync", {
|
|
3012
|
-
enumerable: true,
|
|
3013
|
-
get: function () { return motionDom.cancelSync; }
|
|
3014
|
-
});
|
|
3015
|
-
Object.defineProperty(exports, "frame", {
|
|
3016
|
-
enumerable: true,
|
|
3017
|
-
get: function () { return motionDom.frame; }
|
|
3018
|
-
});
|
|
3019
|
-
Object.defineProperty(exports, "frameData", {
|
|
3020
|
-
enumerable: true,
|
|
3021
|
-
get: function () { return motionDom.frameData; }
|
|
3022
|
-
});
|
|
3023
|
-
Object.defineProperty(exports, "hover", {
|
|
3024
|
-
enumerable: true,
|
|
3025
|
-
get: function () { return motionDom.hover; }
|
|
3026
|
-
});
|
|
3027
|
-
Object.defineProperty(exports, "isDragActive", {
|
|
3028
|
-
enumerable: true,
|
|
3029
|
-
get: function () { return motionDom.isDragActive; }
|
|
3030
|
-
});
|
|
3031
|
-
Object.defineProperty(exports, "motionValue", {
|
|
3032
|
-
enumerable: true,
|
|
3033
|
-
get: function () { return motionDom.motionValue; }
|
|
3034
|
-
});
|
|
3035
|
-
Object.defineProperty(exports, "press", {
|
|
3036
|
-
enumerable: true,
|
|
3037
|
-
get: function () { return motionDom.press; }
|
|
3038
|
-
});
|
|
3039
|
-
Object.defineProperty(exports, "sync", {
|
|
3040
|
-
enumerable: true,
|
|
3041
|
-
get: function () { return motionDom.sync; }
|
|
3042
|
-
});
|
|
3043
|
-
Object.defineProperty(exports, "time", {
|
|
3044
|
-
enumerable: true,
|
|
3045
|
-
get: function () { return motionDom.time; }
|
|
3046
|
-
});
|
|
3047
2994
|
Object.defineProperty(exports, "MotionGlobalConfig", {
|
|
3048
2995
|
enumerable: true,
|
|
3049
2996
|
get: function () { return motionUtils.MotionGlobalConfig; }
|
|
3050
2997
|
});
|
|
3051
|
-
Object.defineProperty(exports, "invariant", {
|
|
3052
|
-
enumerable: true,
|
|
3053
|
-
get: function () { return motionUtils.invariant; }
|
|
3054
|
-
});
|
|
3055
|
-
Object.defineProperty(exports, "noop", {
|
|
3056
|
-
enumerable: true,
|
|
3057
|
-
get: function () { return motionUtils.noop; }
|
|
3058
|
-
});
|
|
3059
|
-
Object.defineProperty(exports, "progress", {
|
|
3060
|
-
enumerable: true,
|
|
3061
|
-
get: function () { return motionUtils.progress; }
|
|
3062
|
-
});
|
|
3063
2998
|
exports.AnimatePresence = AnimatePresence;
|
|
3064
2999
|
exports.AnimateSharedLayout = AnimateSharedLayout;
|
|
3065
3000
|
exports.DeprecatedLayoutGroupContext = DeprecatedLayoutGroupContext;
|
|
@@ -3085,7 +3020,6 @@ exports.scroll = scroll;
|
|
|
3085
3020
|
exports.scrollInfo = scrollInfo;
|
|
3086
3021
|
exports.stagger = stagger;
|
|
3087
3022
|
exports.startOptimizedAppearAnimation = startOptimizedAppearAnimation;
|
|
3088
|
-
exports.steps = steps;
|
|
3089
3023
|
exports.transform = transform;
|
|
3090
3024
|
exports.unwrapMotionComponent = unwrapMotionComponent;
|
|
3091
3025
|
exports.useAnimate = useAnimate;
|
|
@@ -3118,4 +3052,15 @@ exports.useUnmountEffect = useUnmountEffect;
|
|
|
3118
3052
|
exports.useVelocity = useVelocity;
|
|
3119
3053
|
exports.useViewportScroll = useViewportScroll;
|
|
3120
3054
|
exports.useWillChange = useWillChange;
|
|
3121
|
-
|
|
3055
|
+
Object.keys(motionDom).forEach(function (k) {
|
|
3056
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
3057
|
+
enumerable: true,
|
|
3058
|
+
get: function () { return motionDom[k]; }
|
|
3059
|
+
});
|
|
3060
|
+
});
|
|
3061
|
+
Object.keys(motionUtils).forEach(function (k) {
|
|
3062
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
3063
|
+
enumerable: true,
|
|
3064
|
+
get: function () { return motionUtils[k]; }
|
|
3065
|
+
});
|
|
3066
|
+
});
|