framer-motion 12.6.2 → 12.6.3
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/client.js +1 -1
- package/dist/cjs/{create-BLp_edji.js → create-B2InJs4e.js} +68 -115
- package/dist/cjs/dom-mini.js +14 -219
- package/dist/cjs/dom.js +56 -199
- package/dist/cjs/index.js +32 -156
- package/dist/cjs/m.js +8 -12
- package/dist/cjs/mini.js +10 -214
- package/dist/dom-mini.d.ts +3 -3
- package/dist/dom-mini.js +1 -1
- package/dist/dom.d.ts +17 -14
- package/dist/dom.js +1 -1
- package/dist/es/animation/animate/index.mjs +2 -2
- package/dist/es/animation/animators/AcceleratedAnimation.mjs +5 -3
- package/dist/es/animation/animators/MainThreadAnimation.mjs +6 -4
- package/dist/es/animation/animators/waapi/animate-elements.mjs +10 -9
- package/dist/es/animation/animators/waapi/animate-sequence.mjs +2 -2
- package/dist/es/animation/animators/waapi/animate-style.mjs +2 -2
- package/dist/es/animation/generators/spring/index.mjs +9 -1
- package/dist/es/animation/interfaces/motion-value.mjs +2 -2
- package/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
- package/dist/es/animation/interfaces/visual-element-variant.mjs +1 -2
- package/dist/es/animation/optimized-appear/handoff.mjs +2 -4
- package/dist/es/animation/optimized-appear/start.mjs +4 -6
- package/dist/es/animation/sequence/create.mjs +2 -2
- package/dist/es/animation/sequence/utils/calc-time.mjs +1 -2
- package/dist/es/components/AnimatePresence/index.mjs +2 -2
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -10
- package/dist/es/motion/features/animation/index.mjs +1 -2
- package/dist/es/motion/index.mjs +2 -3
- package/dist/es/motion/utils/use-visual-element.mjs +3 -5
- package/dist/es/projection/node/create-projection-node.mjs +17 -25
- package/dist/es/projection/styles/transform.mjs +1 -1
- package/dist/es/render/VisualElement.mjs +3 -4
- package/dist/es/render/dom/DOMKeyframesResolver.mjs +1 -2
- package/dist/es/render/dom/resize/handle-element.mjs +5 -6
- package/dist/es/render/dom/scroll/track.mjs +1 -2
- package/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
- package/dist/es/render/dom/utils/filter-props.mjs +1 -1
- package/dist/es/render/html/utils/scrape-motion-values.mjs +1 -2
- package/dist/es/render/utils/KeyframesResolver.mjs +2 -3
- package/dist/es/render/utils/animation-state.mjs +3 -5
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/render/utils/resolve-variants.mjs +1 -1
- package/dist/es/utils/mix/complex.mjs +1 -2
- package/dist/es/value/types/complex/index.mjs +2 -3
- package/dist/es/value/use-scroll.mjs +2 -2
- package/dist/framer-motion.dev.js +445 -414
- package/dist/framer-motion.js +1 -1
- package/dist/mini.d.ts +1 -1
- 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-m.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/index.d.ts +28 -31
- package/package.json +4 -4
- package/dist/es/animation/animators/waapi/NativeAnimation.mjs +0 -112
- package/dist/es/animation/animators/waapi/index.mjs +0 -32
- package/dist/es/animation/animators/waapi/utils/style.mjs +0 -8
- package/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +0 -13
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { resolveElements, getValueTransition } from 'motion-dom';
|
|
1
|
+
import { resolveElements, getValueTransition, NativeAnimation } from 'motion-dom';
|
|
2
2
|
import { invariant, secondsToMilliseconds } from 'motion-utils';
|
|
3
|
-
import { NativeAnimation } from './NativeAnimation.mjs';
|
|
4
3
|
|
|
5
4
|
function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
6
5
|
const elements = resolveElements(elementOrSelector, scope);
|
|
@@ -21,13 +20,15 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
21
20
|
const valueOptions = {
|
|
22
21
|
...getValueTransition(elementTransition, valueName),
|
|
23
22
|
};
|
|
24
|
-
valueOptions.duration = valueOptions.duration
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));
|
|
24
|
+
valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));
|
|
25
|
+
animations.push(new NativeAnimation({
|
|
26
|
+
element,
|
|
27
|
+
name: valueName,
|
|
28
|
+
keyframes: valueKeyframes,
|
|
29
|
+
transition: valueOptions,
|
|
30
|
+
allowFlatten: !elementTransition.type && !elementTransition.ease,
|
|
31
|
+
}));
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
return animations;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GroupAnimationWithThen } from 'motion-dom';
|
|
2
2
|
import { createAnimationsFromSequence } from '../../sequence/create.mjs';
|
|
3
3
|
import { animateElements } from './animate-elements.mjs';
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ function animateSequence(definition, options) {
|
|
|
7
7
|
createAnimationsFromSequence(definition, options).forEach(({ keyframes, transition }, element) => {
|
|
8
8
|
animations.push(...animateElements(element, keyframes, transition));
|
|
9
9
|
});
|
|
10
|
-
return new
|
|
10
|
+
return new GroupAnimationWithThen(animations);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export { animateSequence };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GroupAnimationWithThen } from 'motion-dom';
|
|
2
2
|
import { animateElements } from './animate-elements.mjs';
|
|
3
3
|
|
|
4
4
|
const createScopedWaapiAnimate = (scope) => {
|
|
5
5
|
function scopedAnimate(elementOrSelector, keyframes, options) {
|
|
6
|
-
return new
|
|
6
|
+
return new GroupAnimationWithThen(animateElements(elementOrSelector, keyframes, options, scope));
|
|
7
7
|
}
|
|
8
8
|
return scopedAnimate;
|
|
9
9
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { calcGeneratorDuration, maxGeneratorDuration, generateLinearEasing } from 'motion-dom';
|
|
1
|
+
import { createGeneratorEasing, supportsLinearEasing, calcGeneratorDuration, maxGeneratorDuration, generateLinearEasing } from 'motion-dom';
|
|
2
2
|
import { millisecondsToSeconds, secondsToMilliseconds } from 'motion-utils';
|
|
3
3
|
import { clamp } from '../../../utils/clamp.mjs';
|
|
4
4
|
import { calcGeneratorVelocity } from '../utils/velocity.mjs';
|
|
@@ -159,8 +159,16 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
|
|
|
159
159
|
const easing = generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
|
|
160
160
|
return calculatedDuration + "ms " + easing;
|
|
161
161
|
},
|
|
162
|
+
toTransition: () => { },
|
|
162
163
|
};
|
|
163
164
|
return generator;
|
|
164
165
|
}
|
|
166
|
+
spring.applyToOptions = (options) => {
|
|
167
|
+
const generatorOptions = createGeneratorEasing(options, 100, spring);
|
|
168
|
+
options.ease = supportsLinearEasing() ? generatorOptions.ease : "easeOut";
|
|
169
|
+
options.duration = secondsToMilliseconds(generatorOptions.duration);
|
|
170
|
+
options.type = "keyframes";
|
|
171
|
+
return options;
|
|
172
|
+
};
|
|
165
173
|
|
|
166
174
|
export { spring };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getValueTransition, frame,
|
|
1
|
+
import { getValueTransition, frame, GroupAnimationWithThen } from 'motion-dom';
|
|
2
2
|
import { secondsToMilliseconds, MotionGlobalConfig } from 'motion-utils';
|
|
3
3
|
import { instantAnimationState } from '../../utils/use-instant-transition-state.mjs';
|
|
4
4
|
import { AcceleratedAnimation } from '../animators/AcceleratedAnimation.mjs';
|
|
@@ -96,7 +96,7 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
96
96
|
});
|
|
97
97
|
// We still want to return some animation controls here rather
|
|
98
98
|
// than returning undefined
|
|
99
|
-
return new
|
|
99
|
+
return new GroupAnimationWithThen([]);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
@@ -17,7 +17,6 @@ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
|
|
|
17
17
|
return shouldBlock;
|
|
18
18
|
}
|
|
19
19
|
function animateTarget(visualElement, targetAndTransition, { delay = 0, transitionOverride, type } = {}) {
|
|
20
|
-
var _a;
|
|
21
20
|
let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = targetAndTransition;
|
|
22
21
|
if (transitionOverride)
|
|
23
22
|
transition = transitionOverride;
|
|
@@ -26,7 +25,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
|
|
|
26
25
|
visualElement.animationState &&
|
|
27
26
|
visualElement.animationState.getState()[type];
|
|
28
27
|
for (const key in target) {
|
|
29
|
-
const value = visualElement.getValue(key,
|
|
28
|
+
const value = visualElement.getValue(key, visualElement.latestValues[key] ?? null);
|
|
30
29
|
const valueTarget = target[key];
|
|
31
30
|
if (valueTarget === undefined ||
|
|
32
31
|
(animationTypeState &&
|
|
@@ -2,9 +2,8 @@ import { resolveVariant } from '../../render/utils/resolve-dynamic-variants.mjs'
|
|
|
2
2
|
import { animateTarget } from './visual-element-target.mjs';
|
|
3
3
|
|
|
4
4
|
function animateVariant(visualElement, variant, options = {}) {
|
|
5
|
-
var _a;
|
|
6
5
|
const resolved = resolveVariant(visualElement, variant, options.type === "exit"
|
|
7
|
-
?
|
|
6
|
+
? visualElement.presenceContext?.custom
|
|
8
7
|
: undefined);
|
|
9
8
|
let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
|
|
10
9
|
if (options.transitionOverride) {
|
|
@@ -2,7 +2,6 @@ import { appearAnimationStore } from './store.mjs';
|
|
|
2
2
|
import { appearStoreId } from './store-id.mjs';
|
|
3
3
|
|
|
4
4
|
function handoffOptimizedAppearAnimation(elementId, valueName, frame) {
|
|
5
|
-
var _a;
|
|
6
5
|
const storeId = appearStoreId(elementId, valueName);
|
|
7
6
|
const optimisedAnimation = appearAnimationStore.get(storeId);
|
|
8
7
|
if (!optimisedAnimation) {
|
|
@@ -10,8 +9,7 @@ function handoffOptimizedAppearAnimation(elementId, valueName, frame) {
|
|
|
10
9
|
}
|
|
11
10
|
const { animation, startTime } = optimisedAnimation;
|
|
12
11
|
function cancelAnimation() {
|
|
13
|
-
|
|
14
|
-
(_a = window.MotionCancelOptimisedAnimation) === null || _a === void 0 ? void 0 : _a.call(window, elementId, valueName, frame);
|
|
12
|
+
window.MotionCancelOptimisedAnimation?.(elementId, valueName, frame);
|
|
15
13
|
}
|
|
16
14
|
/**
|
|
17
15
|
* We can cancel the animation once it's finished now that we've synced
|
|
@@ -21,7 +19,7 @@ function handoffOptimizedAppearAnimation(elementId, valueName, frame) {
|
|
|
21
19
|
* older browsers.
|
|
22
20
|
*/
|
|
23
21
|
animation.onfinish = cancelAnimation;
|
|
24
|
-
if (startTime === null ||
|
|
22
|
+
if (startTime === null || window.MotionHandoffIsComplete?.(elementId)) {
|
|
25
23
|
/**
|
|
26
24
|
* If the startTime is null, this animation is the Paint Ready detection animation
|
|
27
25
|
* and we can cancel it immediately without handoff.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { startWaapiAnimation } from 'motion-dom';
|
|
1
2
|
import { noop } from 'motion-utils';
|
|
2
|
-
import { startWaapiAnimation } from '../animators/waapi/index.mjs';
|
|
3
3
|
import { optimizedAppearDataId } from './data-id.mjs';
|
|
4
4
|
import { getOptimisedAppearId } from './get-appear-id.mjs';
|
|
5
5
|
import { handoffOptimizedAppearAnimation } from './handoff.mjs';
|
|
@@ -124,18 +124,16 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
window.MotionCheckAppearSync = (visualElement, valueName, value) => {
|
|
127
|
-
var _a, _b;
|
|
128
127
|
const appearId = getOptimisedAppearId(visualElement);
|
|
129
128
|
if (!appearId)
|
|
130
129
|
return;
|
|
131
|
-
const valueIsOptimised =
|
|
132
|
-
const externalAnimationValue =
|
|
130
|
+
const valueIsOptimised = window.MotionHasOptimisedAnimation?.(appearId, valueName);
|
|
131
|
+
const externalAnimationValue = visualElement.props.values?.[valueName];
|
|
133
132
|
if (!valueIsOptimised || !externalAnimationValue)
|
|
134
133
|
return;
|
|
135
134
|
const removeSyncCheck = value.on("change", (latestValue) => {
|
|
136
|
-
var _a;
|
|
137
135
|
if (externalAnimationValue.get() !== latestValue) {
|
|
138
|
-
|
|
136
|
+
window.MotionCancelOptimisedAnimation?.(appearId, valueName);
|
|
139
137
|
removeSyncCheck();
|
|
140
138
|
}
|
|
141
139
|
});
|
|
@@ -69,7 +69,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
69
69
|
const numKeyframes = valueKeyframesAsList.length;
|
|
70
70
|
const createGenerator = isGenerator(type)
|
|
71
71
|
? type
|
|
72
|
-
: generators
|
|
72
|
+
: generators?.[type];
|
|
73
73
|
if (numKeyframes <= 2 && createGenerator) {
|
|
74
74
|
/**
|
|
75
75
|
* As we're creating an easing function from a spring,
|
|
@@ -91,7 +91,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
91
91
|
ease = springEasing.ease;
|
|
92
92
|
duration = springEasing.duration;
|
|
93
93
|
}
|
|
94
|
-
duration
|
|
94
|
+
duration ?? (duration = defaultDuration);
|
|
95
95
|
const startTime = currentTime + calculatedDelay;
|
|
96
96
|
/**
|
|
97
97
|
* If there's only one time offset of 0, fill in a second with length 1
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* calculate an absolute time for the next keyframes.
|
|
4
4
|
*/
|
|
5
5
|
function calcNextTime(current, next, prev, labels) {
|
|
6
|
-
var _a;
|
|
7
6
|
if (typeof next === "number") {
|
|
8
7
|
return next;
|
|
9
8
|
}
|
|
@@ -14,7 +13,7 @@ function calcNextTime(current, next, prev, labels) {
|
|
|
14
13
|
return prev;
|
|
15
14
|
}
|
|
16
15
|
else {
|
|
17
|
-
return
|
|
16
|
+
return labels.get(next) ?? current;
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -151,9 +151,9 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, pre
|
|
|
151
151
|
isEveryExitComplete = false;
|
|
152
152
|
});
|
|
153
153
|
if (isEveryExitComplete) {
|
|
154
|
-
forceRender
|
|
154
|
+
forceRender?.();
|
|
155
155
|
setRenderedChildren(pendingPresentChildren.current);
|
|
156
|
-
propagate &&
|
|
156
|
+
propagate && safeToRemove?.();
|
|
157
157
|
onExitComplete && onExitComplete();
|
|
158
158
|
}
|
|
159
159
|
};
|
|
@@ -134,11 +134,8 @@ class VisualElementDragControls {
|
|
|
134
134
|
onDrag && onDrag(event, info);
|
|
135
135
|
};
|
|
136
136
|
const onSessionEnd = (event, info) => this.stop(event, info);
|
|
137
|
-
const resumeAnimation = () => eachAxis((axis) =>
|
|
138
|
-
|
|
139
|
-
return this.getAnimationState(axis) === "paused" &&
|
|
140
|
-
((_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.play());
|
|
141
|
-
});
|
|
137
|
+
const resumeAnimation = () => eachAxis((axis) => this.getAnimationState(axis) === "paused" &&
|
|
138
|
+
this.getAxisMotionValue(axis).animation?.play());
|
|
142
139
|
const { dragSnapToOrigin } = this.getProps();
|
|
143
140
|
this.panSession = new PanSession(originEvent, {
|
|
144
141
|
onSessionStart,
|
|
@@ -193,12 +190,11 @@ class VisualElementDragControls {
|
|
|
193
190
|
axisValue.set(next);
|
|
194
191
|
}
|
|
195
192
|
resolveConstraints() {
|
|
196
|
-
var _a;
|
|
197
193
|
const { dragConstraints, dragElastic } = this.getProps();
|
|
198
194
|
const layout = this.visualElement.projection &&
|
|
199
195
|
!this.visualElement.projection.layout
|
|
200
196
|
? this.visualElement.projection.measure(false)
|
|
201
|
-
:
|
|
197
|
+
: this.visualElement.projection?.layout;
|
|
202
198
|
const prevConstraints = this.constraints;
|
|
203
199
|
if (dragConstraints && isRefObject(dragConstraints)) {
|
|
204
200
|
if (!this.constraints) {
|
|
@@ -301,11 +297,10 @@ class VisualElementDragControls {
|
|
|
301
297
|
eachAxis((axis) => this.getAxisMotionValue(axis).stop());
|
|
302
298
|
}
|
|
303
299
|
pauseAnimation() {
|
|
304
|
-
eachAxis((axis) =>
|
|
300
|
+
eachAxis((axis) => this.getAxisMotionValue(axis).animation?.pause());
|
|
305
301
|
}
|
|
306
302
|
getAnimationState(axis) {
|
|
307
|
-
|
|
308
|
-
return (_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.state;
|
|
303
|
+
return this.getAxisMotionValue(axis).animation?.state;
|
|
309
304
|
}
|
|
310
305
|
/**
|
|
311
306
|
* Drag works differently depending on which props are provided.
|
package/dist/es/motion/index.mjs
CHANGED
|
@@ -24,7 +24,6 @@ import { useVisualElement } from './utils/use-visual-element.mjs';
|
|
|
24
24
|
* component "offline", or outside the React render cycle.
|
|
25
25
|
*/
|
|
26
26
|
function createRendererMotionComponent({ preloadedFeatures, createVisualElement, useRender, useVisualState, Component, }) {
|
|
27
|
-
var _a, _b;
|
|
28
27
|
preloadedFeatures && loadFeatures(preloadedFeatures);
|
|
29
28
|
function MotionComponent(props, externalRef) {
|
|
30
29
|
/**
|
|
@@ -60,7 +59,7 @@ function createRendererMotionComponent({ preloadedFeatures, createVisualElement,
|
|
|
60
59
|
}
|
|
61
60
|
MotionComponent.displayName = `motion.${typeof Component === "string"
|
|
62
61
|
? Component
|
|
63
|
-
: `create(${
|
|
62
|
+
: `create(${Component.displayName ?? Component.name ?? ""})`}`;
|
|
64
63
|
const ForwardRefMotionComponent = forwardRef(MotionComponent);
|
|
65
64
|
ForwardRefMotionComponent[motionComponentSymbol] = Component;
|
|
66
65
|
return ForwardRefMotionComponent;
|
|
@@ -92,7 +91,7 @@ function getProjectionFunctionality(props) {
|
|
|
92
91
|
return {};
|
|
93
92
|
const combined = { ...drag, ...layout };
|
|
94
93
|
return {
|
|
95
|
-
MeasureLayout:
|
|
94
|
+
MeasureLayout: drag?.isEnabled(props) || layout?.isEnabled(props)
|
|
96
95
|
? combined.MeasureLayout
|
|
97
96
|
: undefined,
|
|
98
97
|
ProjectionNode: combined.ProjectionNode,
|
|
@@ -10,7 +10,6 @@ import { isRefObject } from '../../utils/is-ref-object.mjs';
|
|
|
10
10
|
import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';
|
|
11
11
|
|
|
12
12
|
function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
|
|
13
|
-
var _a, _b;
|
|
14
13
|
const { visualElement: parent } = useContext(MotionContext);
|
|
15
14
|
const lazyContext = useContext(LazyContext);
|
|
16
15
|
const presenceContext = useContext(PresenceContext);
|
|
@@ -60,8 +59,8 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
60
59
|
*/
|
|
61
60
|
const optimisedAppearId = props[optimizedAppearDataAttribute];
|
|
62
61
|
const wantsHandoff = useRef(Boolean(optimisedAppearId) &&
|
|
63
|
-
!
|
|
64
|
-
|
|
62
|
+
!window.MotionHandoffIsComplete?.(optimisedAppearId) &&
|
|
63
|
+
window.MotionHasOptimisedAnimation?.(optimisedAppearId));
|
|
65
64
|
useIsomorphicLayoutEffect(() => {
|
|
66
65
|
if (!visualElement)
|
|
67
66
|
return;
|
|
@@ -92,8 +91,7 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
92
91
|
if (wantsHandoff.current) {
|
|
93
92
|
// This ensures all future calls to animateChanges() in this component will run in useEffect
|
|
94
93
|
queueMicrotask(() => {
|
|
95
|
-
|
|
96
|
-
(_a = window.MotionHandoffMarkAsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId);
|
|
94
|
+
window.MotionHandoffMarkAsComplete?.(optimisedAppearId);
|
|
97
95
|
});
|
|
98
96
|
wantsHandoff.current = false;
|
|
99
97
|
}
|
|
@@ -65,7 +65,7 @@ function cancelTreeOptimisedTransformAnimations(projectionNode) {
|
|
|
65
65
|
}
|
|
66
66
|
function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
|
|
67
67
|
return class ProjectionNode {
|
|
68
|
-
constructor(latestValues = {}, parent = defaultParent
|
|
68
|
+
constructor(latestValues = {}, parent = defaultParent?.()) {
|
|
69
69
|
/**
|
|
70
70
|
* A unique ID generated for every projection node.
|
|
71
71
|
*/
|
|
@@ -596,12 +596,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
596
596
|
};
|
|
597
597
|
}
|
|
598
598
|
measurePageBox() {
|
|
599
|
-
var _a;
|
|
600
599
|
const { visualElement } = this.options;
|
|
601
600
|
if (!visualElement)
|
|
602
601
|
return createBox();
|
|
603
602
|
const box = visualElement.measureViewportBox();
|
|
604
|
-
const wasInScrollRoot =
|
|
603
|
+
const wasInScrollRoot = this.scroll?.wasRoot || this.path.some(checkNodeWasScrollRoot);
|
|
605
604
|
if (!wasInScrollRoot) {
|
|
606
605
|
// Remove viewport scroll to give page-relative coordinates
|
|
607
606
|
const { scroll } = this.root;
|
|
@@ -613,10 +612,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
613
612
|
return box;
|
|
614
613
|
}
|
|
615
614
|
removeElementScroll(box) {
|
|
616
|
-
var _a;
|
|
617
615
|
const boxWithoutScroll = createBox();
|
|
618
616
|
copyBoxInto(boxWithoutScroll, box);
|
|
619
|
-
if (
|
|
617
|
+
if (this.scroll?.wasRoot) {
|
|
620
618
|
return boxWithoutScroll;
|
|
621
619
|
}
|
|
622
620
|
/**
|
|
@@ -719,7 +717,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
719
717
|
}
|
|
720
718
|
}
|
|
721
719
|
resolveTargetDelta(forceRecalculation = false) {
|
|
722
|
-
var _a;
|
|
723
720
|
/**
|
|
724
721
|
* Once the dirty status of nodes has been spread through the tree, we also
|
|
725
722
|
* need to check if we have a shared node of a different depth that has itself
|
|
@@ -737,7 +734,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
737
734
|
const canSkip = !(forceRecalculation ||
|
|
738
735
|
(isShared && this.isSharedProjectionDirty) ||
|
|
739
736
|
this.isProjectionDirty ||
|
|
740
|
-
|
|
737
|
+
this.parent?.isProjectionDirty ||
|
|
741
738
|
this.attemptToResolveRelativeTarget ||
|
|
742
739
|
this.root.updateBlockedByResize);
|
|
743
740
|
if (canSkip)
|
|
@@ -862,7 +859,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
862
859
|
this.layout);
|
|
863
860
|
}
|
|
864
861
|
calcProjection() {
|
|
865
|
-
var _a;
|
|
866
862
|
const lead = this.getLead();
|
|
867
863
|
const isShared = Boolean(this.resumingFrom) || this !== lead;
|
|
868
864
|
let canSkip = true;
|
|
@@ -870,7 +866,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
870
866
|
* If this is a normal layout animation and neither this node nor its nearest projecting
|
|
871
867
|
* is dirty then we can't skip.
|
|
872
868
|
*/
|
|
873
|
-
if (this.isProjectionDirty ||
|
|
869
|
+
if (this.isProjectionDirty || this.parent?.isProjectionDirty) {
|
|
874
870
|
canSkip = false;
|
|
875
871
|
}
|
|
876
872
|
/**
|
|
@@ -982,8 +978,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
982
978
|
// TODO: Schedule render
|
|
983
979
|
}
|
|
984
980
|
scheduleRender(notifyAll = true) {
|
|
985
|
-
|
|
986
|
-
(_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.scheduleRender();
|
|
981
|
+
this.options.visualElement?.scheduleRender();
|
|
987
982
|
if (notifyAll) {
|
|
988
983
|
const stack = this.getStack();
|
|
989
984
|
stack && stack.scheduleRender();
|
|
@@ -1170,14 +1165,12 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1170
1165
|
return stack ? stack.lead === this : true;
|
|
1171
1166
|
}
|
|
1172
1167
|
getLead() {
|
|
1173
|
-
var _a;
|
|
1174
1168
|
const { layoutId } = this.options;
|
|
1175
|
-
return layoutId ?
|
|
1169
|
+
return layoutId ? this.getStack()?.lead || this : this;
|
|
1176
1170
|
}
|
|
1177
1171
|
getPrevLead() {
|
|
1178
|
-
var _a;
|
|
1179
1172
|
const { layoutId } = this.options;
|
|
1180
|
-
return layoutId ?
|
|
1173
|
+
return layoutId ? this.getStack()?.prevLead : undefined;
|
|
1181
1174
|
}
|
|
1182
1175
|
getStack() {
|
|
1183
1176
|
const { layoutId } = this.options;
|
|
@@ -1251,7 +1244,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1251
1244
|
visualElement.scheduleRender();
|
|
1252
1245
|
}
|
|
1253
1246
|
getProjectionStyles(styleProp) {
|
|
1254
|
-
var _a, _b;
|
|
1255
1247
|
if (!this.instance || this.isSVG)
|
|
1256
1248
|
return undefined;
|
|
1257
1249
|
if (!this.isVisible) {
|
|
@@ -1265,7 +1257,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1265
1257
|
this.needsReset = false;
|
|
1266
1258
|
styles.opacity = "";
|
|
1267
1259
|
styles.pointerEvents =
|
|
1268
|
-
resolveMotionValue(styleProp
|
|
1260
|
+
resolveMotionValue(styleProp?.pointerEvents) || "";
|
|
1269
1261
|
styles.transform = transformTemplate
|
|
1270
1262
|
? transformTemplate(this.latestValues, "")
|
|
1271
1263
|
: "none";
|
|
@@ -1280,7 +1272,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1280
1272
|
? this.latestValues.opacity
|
|
1281
1273
|
: 1;
|
|
1282
1274
|
emptyStyles.pointerEvents =
|
|
1283
|
-
resolveMotionValue(styleProp
|
|
1275
|
+
resolveMotionValue(styleProp?.pointerEvents) || "";
|
|
1284
1276
|
}
|
|
1285
1277
|
if (this.hasProjected && !hasTransform(this.latestValues)) {
|
|
1286
1278
|
emptyStyles.transform = transformTemplate
|
|
@@ -1305,7 +1297,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1305
1297
|
*/
|
|
1306
1298
|
styles.opacity =
|
|
1307
1299
|
lead === this
|
|
1308
|
-
?
|
|
1300
|
+
? valuesToRender.opacity ??
|
|
1301
|
+
this.latestValues.opacity ??
|
|
1302
|
+
1
|
|
1309
1303
|
: this.preserveOpacity
|
|
1310
1304
|
? this.latestValues.opacity
|
|
1311
1305
|
: valuesToRender.opacityExit;
|
|
@@ -1366,7 +1360,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1366
1360
|
if (this.options.layoutId) {
|
|
1367
1361
|
styles.pointerEvents =
|
|
1368
1362
|
lead === this
|
|
1369
|
-
? resolveMotionValue(styleProp
|
|
1363
|
+
? resolveMotionValue(styleProp?.pointerEvents) || ""
|
|
1370
1364
|
: "none";
|
|
1371
1365
|
}
|
|
1372
1366
|
return styles;
|
|
@@ -1376,7 +1370,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
1376
1370
|
}
|
|
1377
1371
|
// Only run on root
|
|
1378
1372
|
resetTree() {
|
|
1379
|
-
this.root.nodes.forEach((node) =>
|
|
1373
|
+
this.root.nodes.forEach((node) => node.currentAnimation?.stop());
|
|
1380
1374
|
this.root.nodes.forEach(clearMeasurements);
|
|
1381
1375
|
this.root.sharedNodes.clear();
|
|
1382
1376
|
}
|
|
@@ -1386,8 +1380,7 @@ function updateLayout(node) {
|
|
|
1386
1380
|
node.updateLayout();
|
|
1387
1381
|
}
|
|
1388
1382
|
function notifyLayoutUpdate(node) {
|
|
1389
|
-
|
|
1390
|
-
const snapshot = ((_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) || node.snapshot;
|
|
1383
|
+
const snapshot = node.resumeFrom?.snapshot || node.snapshot;
|
|
1391
1384
|
if (node.isLead() &&
|
|
1392
1385
|
node.layout &&
|
|
1393
1386
|
snapshot &&
|
|
@@ -1593,8 +1586,7 @@ function shouldAnimatePositionOnly(animationType, snapshot, layout) {
|
|
|
1593
1586
|
!isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
|
|
1594
1587
|
}
|
|
1595
1588
|
function checkNodeWasScrollRoot(node) {
|
|
1596
|
-
|
|
1597
|
-
return node !== node.root && ((_a = node.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot);
|
|
1589
|
+
return node !== node.root && node.scroll?.wasRoot;
|
|
1598
1590
|
}
|
|
1599
1591
|
|
|
1600
1592
|
export { cleanDirtyNodes, createProjectionNode, mixAxis, mixAxisDelta, mixBox, propagateDirtyNodes };
|
|
@@ -8,7 +8,7 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
|
|
|
8
8
|
*/
|
|
9
9
|
const xTranslate = delta.x.translate / treeScale.x;
|
|
10
10
|
const yTranslate = delta.y.translate / treeScale.y;
|
|
11
|
-
const zTranslate =
|
|
11
|
+
const zTranslate = latestTransform?.z || 0;
|
|
12
12
|
if (xTranslate || yTranslate || zTranslate) {
|
|
13
13
|
transform = `translate3d(${xTranslate}px, ${yTranslate}px, ${zTranslate}px) `;
|
|
14
14
|
}
|
|
@@ -402,10 +402,10 @@ class VisualElement {
|
|
|
402
402
|
* directly from the instance (which might have performance implications).
|
|
403
403
|
*/
|
|
404
404
|
readValue(key, target) {
|
|
405
|
-
var _a;
|
|
406
405
|
let value = this.latestValues[key] !== undefined || !this.current
|
|
407
406
|
? this.latestValues[key]
|
|
408
|
-
:
|
|
407
|
+
: this.getBaseTargetFromProps(this.props, key) ??
|
|
408
|
+
this.readValueFromInstance(this.current, key, this.options);
|
|
409
409
|
if (value !== undefined && value !== null) {
|
|
410
410
|
if (typeof value === "string" &&
|
|
411
411
|
(isNumericalString(value) || isZeroValueString(value))) {
|
|
@@ -431,11 +431,10 @@ class VisualElement {
|
|
|
431
431
|
* props.
|
|
432
432
|
*/
|
|
433
433
|
getBaseTarget(key) {
|
|
434
|
-
var _a;
|
|
435
434
|
const { initial } = this.props;
|
|
436
435
|
let valueFromInitial;
|
|
437
436
|
if (typeof initial === "string" || typeof initial === "object") {
|
|
438
|
-
const variant = resolveVariantFromProps(this.props, initial,
|
|
437
|
+
const variant = resolveVariantFromProps(this.props, initial, this.presenceContext?.custom);
|
|
439
438
|
if (variant) {
|
|
440
439
|
valueFromInitial = variant[key];
|
|
441
440
|
}
|
|
@@ -104,7 +104,6 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
measureEndState() {
|
|
107
|
-
var _a;
|
|
108
107
|
const { element, name, unresolvedKeyframes } = this;
|
|
109
108
|
if (!element || !element.current)
|
|
110
109
|
return;
|
|
@@ -117,7 +116,7 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
117
116
|
this.finalKeyframe = finalKeyframe;
|
|
118
117
|
}
|
|
119
118
|
// If we removed transform values, reapply them before the next render
|
|
120
|
-
if (
|
|
119
|
+
if (this.removedTransforms?.length) {
|
|
121
120
|
this.removedTransforms.forEach(([unsetTransformName, unsetTransformValue]) => {
|
|
122
121
|
element
|
|
123
122
|
.getValue(unsetTransformName)
|
|
@@ -18,8 +18,7 @@ function getElementSize(target, borderBoxSize) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function notifyTarget({ target, contentRect, borderBoxSize, }) {
|
|
21
|
-
|
|
22
|
-
(_a = resizeHandlers.get(target)) === null || _a === void 0 ? void 0 : _a.forEach((handler) => {
|
|
21
|
+
resizeHandlers.get(target)?.forEach((handler) => {
|
|
23
22
|
handler({
|
|
24
23
|
target,
|
|
25
24
|
contentSize: contentRect,
|
|
@@ -48,14 +47,14 @@ function resizeElement(target, handler) {
|
|
|
48
47
|
resizeHandlers.set(element, elementHandlers);
|
|
49
48
|
}
|
|
50
49
|
elementHandlers.add(handler);
|
|
51
|
-
observer
|
|
50
|
+
observer?.observe(element);
|
|
52
51
|
});
|
|
53
52
|
return () => {
|
|
54
53
|
elements.forEach((element) => {
|
|
55
54
|
const elementHandlers = resizeHandlers.get(element);
|
|
56
|
-
elementHandlers
|
|
57
|
-
if (!
|
|
58
|
-
observer
|
|
55
|
+
elementHandlers?.delete(handler);
|
|
56
|
+
if (!elementHandlers?.size) {
|
|
57
|
+
observer?.unobserve(element);
|
|
59
58
|
}
|
|
60
59
|
});
|
|
61
60
|
};
|
|
@@ -57,7 +57,6 @@ function scrollInfo(onScroll, { container = document.documentElement, ...options
|
|
|
57
57
|
const listener = scrollListeners.get(container);
|
|
58
58
|
frame.read(listener, false, true);
|
|
59
59
|
return () => {
|
|
60
|
-
var _a;
|
|
61
60
|
cancelFrame(listener);
|
|
62
61
|
/**
|
|
63
62
|
* Check if we even have any handlers for this container.
|
|
@@ -75,7 +74,7 @@ function scrollInfo(onScroll, { container = document.documentElement, ...options
|
|
|
75
74
|
scrollListeners.delete(container);
|
|
76
75
|
if (scrollListener) {
|
|
77
76
|
getEventTarget(container).removeEventListener("scroll", scrollListener);
|
|
78
|
-
|
|
77
|
+
resizeListeners.get(container)?.();
|
|
79
78
|
window.removeEventListener("resize", scrollListener);
|
|
80
79
|
}
|
|
81
80
|
};
|
|
@@ -19,7 +19,7 @@ function parseCSSVariable(current) {
|
|
|
19
19
|
if (!match)
|
|
20
20
|
return [,];
|
|
21
21
|
const [, token1, token2, fallback] = match;
|
|
22
|
-
return [`--${token1
|
|
22
|
+
return [`--${token1 ?? token2}`, fallback];
|
|
23
23
|
}
|
|
24
24
|
const maxDepth = 4;
|
|
25
25
|
function getVariableValue(current, element, depth = 1) {
|
|
@@ -28,7 +28,7 @@ try {
|
|
|
28
28
|
*/
|
|
29
29
|
loadExternalIsValidProp(require("@emotion/is-prop-valid").default);
|
|
30
30
|
}
|
|
31
|
-
catch
|
|
31
|
+
catch {
|
|
32
32
|
// We don't need to actually do anything here - the fallback is the existing `isPropValid`.
|
|
33
33
|
}
|
|
34
34
|
function filterProps(props, isDom, forwardMotionProps) {
|