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/debug.js +12 -12
- package/dist/cjs/index.js +402 -347
- package/dist/cjs/mini.js +339 -352
- package/dist/cjs/react-client.js +169 -176
- package/dist/cjs/react-m.js +18 -22
- package/dist/cjs/react-mini.js +275 -336
- package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +7 -4
- package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +8 -6
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +10 -8
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-sequence.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +11 -1
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +3 -3
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-variant.mjs +1 -2
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/handoff.mjs +2 -4
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +4 -6
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +3 -3
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +1 -2
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +2 -2
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -10
- package/dist/es/framer-motion/dist/es/motion/features/animation/index.mjs +1 -2
- package/dist/es/framer-motion/dist/es/motion/index.mjs +2 -3
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +3 -5
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +19 -27
- package/dist/es/framer-motion/dist/es/projection/styles/transform.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +3 -4
- package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +1 -2
- package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +5 -6
- package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +1 -2
- package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/dom/utils/filter-props.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +1 -2
- package/dist/es/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +2 -3
- package/dist/es/framer-motion/dist/es/render/utils/animation-state.mjs +3 -5
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/utils/resolve-variants.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +1 -2
- package/dist/es/framer-motion/dist/es/value/types/complex/index.mjs +2 -3
- package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +2 -2
- package/dist/es/motion-dom/dist/es/animation/{controls/BaseGroup.mjs → GroupAnimation.mjs} +4 -5
- package/dist/es/motion-dom/dist/es/animation/GroupAnimationWithThen.mjs +9 -0
- package/dist/es/motion-dom/dist/es/animation/NativeAnimation.mjs +161 -0
- package/dist/es/motion-dom/dist/es/animation/generators/utils/is-generator.mjs +1 -1
- package/dist/es/motion-dom/dist/es/animation/keyframes/get-final.mjs +12 -0
- package/dist/es/motion-dom/dist/es/animation/keyframes/hydrate.mjs +26 -0
- package/dist/es/motion-dom/dist/es/animation/utils/get-value-transition.mjs +3 -5
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/cubic-bezier.mjs +3 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/is-supported.mjs +14 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/map-easing.mjs +26 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/supported.mjs +15 -0
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/index.mjs → motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs} +8 -6
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs → motion-dom/dist/es/animation/waapi/supports/partial-keyframes.mjs} +2 -2
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/apply-generator.mjs +14 -0
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/linear.mjs +1 -4
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/px-values.mjs +39 -0
- package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +1 -1
- package/dist/es/motion-dom/dist/es/render/dom/style.mjs +15 -0
- package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +2 -7
- package/dist/es/motion-dom/dist/es/utils/supports/flags.mjs +1 -3
- package/dist/es/motion-dom/dist/es/utils/supports/memo.mjs +1 -1
- package/dist/es/motion-dom/dist/es/value/index.mjs +1 -1
- package/dist/es/motion-utils/dist/es/errors.mjs +2 -4
- package/dist/motion.dev.js +402 -347
- package/dist/motion.js +1 -1
- package/package.json +3 -3
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +0 -116
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/style.mjs +0 -8
- package/dist/es/motion-dom/dist/es/animation/controls/Group.mjs +0 -13
- package/dist/es/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +0 -85
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/easing.mjs +0 -44
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GroupPlaybackControls } from '../../../../../motion-dom/dist/es/animation/controls/Group.mjs';
|
|
2
1
|
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { GroupAnimationWithThen } from '../../../../../motion-dom/dist/es/animation/GroupAnimationWithThen.mjs';
|
|
3
3
|
import { animateSequence } from './sequence.mjs';
|
|
4
4
|
import { animateSubject } from './subject.mjs';
|
|
5
5
|
|
|
@@ -22,7 +22,7 @@ function createScopedAnimate(scope) {
|
|
|
22
22
|
else {
|
|
23
23
|
animations = animateSubject(subjectOrSequence, optionsOrKeyframes, options, scope);
|
|
24
24
|
}
|
|
25
|
-
const animation = new
|
|
25
|
+
const animation = new GroupAnimationWithThen(animations);
|
|
26
26
|
if (scope) {
|
|
27
27
|
scope.animations.push(animation);
|
|
28
28
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
2
|
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
3
3
|
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
4
|
+
import { startWaapiAnimation } from '../../../../../motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs';
|
|
4
5
|
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
5
|
-
import {
|
|
6
|
-
import { isWaapiSupportedEasing } from '../../../../../motion-dom/dist/es/animation/waapi/utils/easing.mjs';
|
|
6
|
+
import { isWaapiSupportedEasing } from '../../../../../motion-dom/dist/es/animation/waapi/easing/is-supported.mjs';
|
|
7
7
|
import { supportsLinearEasing } from '../../../../../motion-dom/dist/es/utils/supports/linear-easing.mjs';
|
|
8
|
+
import { attachTimeline } from '../../../../../motion-dom/dist/es/animation/waapi/utils/attach-timeline.mjs';
|
|
8
9
|
import { anticipate } from '../../easing/anticipate.mjs';
|
|
9
10
|
import { backInOut } from '../../easing/back.mjs';
|
|
10
11
|
import { circInOut } from '../../easing/circ.mjs';
|
|
@@ -12,7 +13,6 @@ import { DOMKeyframesResolver } from '../../render/dom/DOMKeyframesResolver.mjs'
|
|
|
12
13
|
import { BaseAnimation } from './BaseAnimation.mjs';
|
|
13
14
|
import { MainThreadAnimation } from './MainThreadAnimation.mjs';
|
|
14
15
|
import { acceleratedValues } from './utils/accelerated-values.mjs';
|
|
15
|
-
import { startWaapiAnimation } from './waapi/index.mjs';
|
|
16
16
|
import { getFinalKeyframe } from './waapi/utils/get-final-keyframe.mjs';
|
|
17
17
|
import { supportsWaapi } from './waapi/utils/supports-waapi.mjs';
|
|
18
18
|
|
|
@@ -124,7 +124,7 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
124
124
|
const animation = startWaapiAnimation(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
|
|
125
125
|
// Override the browser calculated startTime with one synchronised to other JS
|
|
126
126
|
// and WAAPI animations starting this event loop.
|
|
127
|
-
animation.startTime = startTime
|
|
127
|
+
animation.startTime = startTime ?? this.calcStartTime();
|
|
128
128
|
if (this.pendingTimeline) {
|
|
129
129
|
attachTimeline(animation, this.pendingTimeline);
|
|
130
130
|
this.pendingTimeline = undefined;
|
|
@@ -183,6 +183,9 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
183
183
|
const { animation } = resolved;
|
|
184
184
|
return animation.playbackRate;
|
|
185
185
|
}
|
|
186
|
+
get finished() {
|
|
187
|
+
return this.resolved.animation.finished;
|
|
188
|
+
}
|
|
186
189
|
set speed(newSpeed) {
|
|
187
190
|
const { resolved } = this;
|
|
188
191
|
if (!resolved)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
2
|
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
-
import { calcGeneratorDuration } from '../../../../../motion-dom/dist/es/animation/generators/utils/calc-duration.mjs';
|
|
4
|
-
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
5
3
|
import { activeAnimations } from '../../../../../motion-dom/dist/es/stats/animation-count.mjs';
|
|
4
|
+
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
5
|
+
import { calcGeneratorDuration } from '../../../../../motion-dom/dist/es/animation/generators/utils/calc-duration.mjs';
|
|
6
6
|
import { KeyframeResolver } from '../../render/utils/KeyframesResolver.mjs';
|
|
7
7
|
import { clamp } from '../../utils/clamp.mjs';
|
|
8
8
|
import { mix } from '../../utils/mix/index.mjs';
|
|
@@ -71,7 +71,7 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
71
71
|
onStop && onStop();
|
|
72
72
|
};
|
|
73
73
|
const { name, motionValue, element, keyframes } = this.options;
|
|
74
|
-
const KeyframeResolver$1 =
|
|
74
|
+
const KeyframeResolver$1 = element?.KeyframeResolver || KeyframeResolver;
|
|
75
75
|
const onResolved = (resolvedKeyframes, finalKeyframe) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe);
|
|
76
76
|
this.resolver = new KeyframeResolver$1(keyframes, onResolved, name, motionValue, element);
|
|
77
77
|
this.resolver.scheduleResolve();
|
|
@@ -321,7 +321,7 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
321
321
|
this.startTime = now - this.holdTime;
|
|
322
322
|
}
|
|
323
323
|
else if (!this.startTime) {
|
|
324
|
-
this.startTime = startTime
|
|
324
|
+
this.startTime = startTime ?? this.calcStartTime();
|
|
325
325
|
}
|
|
326
326
|
else if (this.state === "finished") {
|
|
327
327
|
this.startTime = now;
|
|
@@ -339,13 +339,12 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
339
339
|
this.driver.start();
|
|
340
340
|
}
|
|
341
341
|
pause() {
|
|
342
|
-
var _a;
|
|
343
342
|
if (!this._resolved) {
|
|
344
343
|
this.pendingPlayState = "paused";
|
|
345
344
|
return;
|
|
346
345
|
}
|
|
347
346
|
this.state = "paused";
|
|
348
|
-
this.holdTime =
|
|
347
|
+
this.holdTime = this.currentTime ?? 0;
|
|
349
348
|
}
|
|
350
349
|
complete() {
|
|
351
350
|
if (this.state !== "running") {
|
|
@@ -386,6 +385,9 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
386
385
|
this.startTime = 0;
|
|
387
386
|
return this.tick(time, true);
|
|
388
387
|
}
|
|
388
|
+
get finished() {
|
|
389
|
+
return this.currentFinishedPromise;
|
|
390
|
+
}
|
|
389
391
|
}
|
|
390
392
|
// Legacy interface
|
|
391
393
|
function animateValue(options) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { invariant } from '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
2
|
import { secondsToMilliseconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
+
import { NativeAnimation } from '../../../../../../motion-dom/dist/es/animation/NativeAnimation.mjs';
|
|
3
4
|
import { getValueTransition } from '../../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
4
5
|
import { resolveElements } from '../../../../../../motion-dom/dist/es/utils/resolve-elements.mjs';
|
|
5
|
-
import { NativeAnimation } from './NativeAnimation.mjs';
|
|
6
6
|
|
|
7
7
|
function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
8
8
|
const elements = resolveElements(elementOrSelector, scope);
|
|
@@ -23,13 +23,15 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
23
23
|
const valueOptions = {
|
|
24
24
|
...getValueTransition(elementTransition, valueName),
|
|
25
25
|
};
|
|
26
|
-
valueOptions.duration = valueOptions.duration
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));
|
|
27
|
+
valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));
|
|
28
|
+
animations.push(new NativeAnimation({
|
|
29
|
+
element,
|
|
30
|
+
name: valueName,
|
|
31
|
+
keyframes: valueKeyframes,
|
|
32
|
+
transition: valueOptions,
|
|
33
|
+
allowFlatten: !elementTransition.type && !elementTransition.ease,
|
|
34
|
+
}));
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
return animations;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GroupPlaybackControls } from '../../../../../../motion-dom/dist/es/animation/controls/Group.mjs';
|
|
2
1
|
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { GroupAnimationWithThen } from '../../../../../../motion-dom/dist/es/animation/GroupAnimationWithThen.mjs';
|
|
3
3
|
import { createAnimationsFromSequence } from '../../sequence/create.mjs';
|
|
4
4
|
import { animateElements } from './animate-elements.mjs';
|
|
5
5
|
|
|
@@ -8,7 +8,7 @@ function animateSequence(definition, options) {
|
|
|
8
8
|
createAnimationsFromSequence(definition, options).forEach(({ keyframes, transition }, element) => {
|
|
9
9
|
animations.push(...animateElements(element, keyframes, transition));
|
|
10
10
|
});
|
|
11
|
-
return new
|
|
11
|
+
return new GroupAnimationWithThen(animations);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export { animateSequence };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { GroupPlaybackControls } from '../../../../../../motion-dom/dist/es/animation/controls/Group.mjs';
|
|
2
1
|
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { GroupAnimationWithThen } from '../../../../../../motion-dom/dist/es/animation/GroupAnimationWithThen.mjs';
|
|
3
3
|
import { animateElements } from './animate-elements.mjs';
|
|
4
4
|
|
|
5
5
|
const createScopedWaapiAnimate = (scope) => {
|
|
6
6
|
function scopedAnimate(elementOrSelector, keyframes, options) {
|
|
7
|
-
return new
|
|
7
|
+
return new GroupAnimationWithThen(animateElements(elementOrSelector, keyframes, options, scope));
|
|
8
8
|
}
|
|
9
9
|
return scopedAnimate;
|
|
10
10
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
2
|
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { supportsLinearEasing } from '../../../../../../motion-dom/dist/es/utils/supports/linear-easing.mjs';
|
|
4
4
|
import { generateLinearEasing } from '../../../../../../motion-dom/dist/es/animation/waapi/utils/linear.mjs';
|
|
5
|
+
import { calcGeneratorDuration, maxGeneratorDuration } from '../../../../../../motion-dom/dist/es/animation/generators/utils/calc-duration.mjs';
|
|
6
|
+
import { createGeneratorEasing } from '../../../../../../motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs';
|
|
5
7
|
import { clamp } from '../../../utils/clamp.mjs';
|
|
6
8
|
import { calcGeneratorVelocity } from '../utils/velocity.mjs';
|
|
7
9
|
import { springDefaults } from './defaults.mjs';
|
|
@@ -161,8 +163,16 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
|
|
|
161
163
|
const easing = generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
|
|
162
164
|
return calculatedDuration + "ms " + easing;
|
|
163
165
|
},
|
|
166
|
+
toTransition: () => { },
|
|
164
167
|
};
|
|
165
168
|
return generator;
|
|
166
169
|
}
|
|
170
|
+
spring.applyToOptions = (options) => {
|
|
171
|
+
const generatorOptions = createGeneratorEasing(options, 100, spring);
|
|
172
|
+
options.ease = supportsLinearEasing() ? generatorOptions.ease : "easeOut";
|
|
173
|
+
options.duration = secondsToMilliseconds(generatorOptions.duration);
|
|
174
|
+
options.type = "keyframes";
|
|
175
|
+
return options;
|
|
176
|
+
};
|
|
167
177
|
|
|
168
178
|
export { spring };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { GroupPlaybackControls } from '../../../../../motion-dom/dist/es/animation/controls/Group.mjs';
|
|
2
|
-
import { getValueTransition } from '../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
3
1
|
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
4
2
|
import { MotionGlobalConfig } from '../../../../../motion-utils/dist/es/global-config.mjs';
|
|
5
3
|
import { secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
4
|
+
import { GroupAnimationWithThen } from '../../../../../motion-dom/dist/es/animation/GroupAnimationWithThen.mjs';
|
|
5
|
+
import { getValueTransition } from '../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
6
6
|
import { frame } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
|
|
7
7
|
import { instantAnimationState } from '../../utils/use-instant-transition-state.mjs';
|
|
8
8
|
import { AcceleratedAnimation } from '../animators/AcceleratedAnimation.mjs';
|
|
@@ -100,7 +100,7 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
100
100
|
});
|
|
101
101
|
// We still want to return some animation controls here rather
|
|
102
102
|
// than returning undefined
|
|
103
|
-
return new
|
|
103
|
+
return new GroupAnimationWithThen([]);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
@@ -19,7 +19,6 @@ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
|
|
|
19
19
|
return shouldBlock;
|
|
20
20
|
}
|
|
21
21
|
function animateTarget(visualElement, targetAndTransition, { delay = 0, transitionOverride, type } = {}) {
|
|
22
|
-
var _a;
|
|
23
22
|
let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = targetAndTransition;
|
|
24
23
|
if (transitionOverride)
|
|
25
24
|
transition = transitionOverride;
|
|
@@ -28,7 +27,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
|
|
|
28
27
|
visualElement.animationState &&
|
|
29
28
|
visualElement.animationState.getState()[type];
|
|
30
29
|
for (const key in target) {
|
|
31
|
-
const value = visualElement.getValue(key,
|
|
30
|
+
const value = visualElement.getValue(key, visualElement.latestValues[key] ?? null);
|
|
32
31
|
const valueTarget = target[key];
|
|
33
32
|
if (valueTarget === undefined ||
|
|
34
33
|
(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,6 +1,6 @@
|
|
|
1
1
|
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
2
|
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
3
|
-
import { startWaapiAnimation } from '
|
|
3
|
+
import { startWaapiAnimation } from '../../../../../motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs';
|
|
4
4
|
import { optimizedAppearDataId } from './data-id.mjs';
|
|
5
5
|
import { getOptimisedAppearId } from './get-appear-id.mjs';
|
|
6
6
|
import { handoffOptimizedAppearAnimation } from './handoff.mjs';
|
|
@@ -125,18 +125,16 @@ function startOptimizedAppearAnimation(element, name, keyframes, options, onRead
|
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
window.MotionCheckAppearSync = (visualElement, valueName, value) => {
|
|
128
|
-
var _a, _b;
|
|
129
128
|
const appearId = getOptimisedAppearId(visualElement);
|
|
130
129
|
if (!appearId)
|
|
131
130
|
return;
|
|
132
|
-
const valueIsOptimised =
|
|
133
|
-
const externalAnimationValue =
|
|
131
|
+
const valueIsOptimised = window.MotionHasOptimisedAnimation?.(appearId, valueName);
|
|
132
|
+
const externalAnimationValue = visualElement.props.values?.[valueName];
|
|
134
133
|
if (!valueIsOptimised || !externalAnimationValue)
|
|
135
134
|
return;
|
|
136
135
|
const removeSyncCheck = value.on("change", (latestValue) => {
|
|
137
|
-
var _a;
|
|
138
136
|
if (externalAnimationValue.get() !== latestValue) {
|
|
139
|
-
|
|
137
|
+
window.MotionCancelOptimisedAnimation?.(appearId, valueName);
|
|
140
138
|
removeSyncCheck();
|
|
141
139
|
}
|
|
142
140
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
2
|
import { progress } from '../../../../../motion-utils/dist/es/progress.mjs';
|
|
3
3
|
import { secondsToMilliseconds } from '../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
4
|
-
import { createGeneratorEasing } from '../../../../../motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs';
|
|
5
4
|
import { isGenerator } from '../../../../../motion-dom/dist/es/animation/generators/utils/is-generator.mjs';
|
|
5
|
+
import { createGeneratorEasing } from '../../../../../motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs';
|
|
6
6
|
import { getEasingForSegment } from '../../easing/utils/get-easing-for-segment.mjs';
|
|
7
7
|
import { defaultOffset } from '../../utils/offsets/default.mjs';
|
|
8
8
|
import { fillOffset } from '../../utils/offsets/fill.mjs';
|
|
@@ -72,7 +72,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
72
72
|
const numKeyframes = valueKeyframesAsList.length;
|
|
73
73
|
const createGenerator = isGenerator(type)
|
|
74
74
|
? type
|
|
75
|
-
: generators
|
|
75
|
+
: generators?.[type];
|
|
76
76
|
if (numKeyframes <= 2 && createGenerator) {
|
|
77
77
|
/**
|
|
78
78
|
* As we're creating an easing function from a spring,
|
|
@@ -94,7 +94,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
94
94
|
ease = springEasing.ease;
|
|
95
95
|
duration = springEasing.duration;
|
|
96
96
|
}
|
|
97
|
-
duration
|
|
97
|
+
duration ?? (duration = defaultDuration);
|
|
98
98
|
const startTime = currentTime + calculatedDelay;
|
|
99
99
|
/**
|
|
100
100
|
* 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
|
};
|
|
@@ -135,11 +135,8 @@ class VisualElementDragControls {
|
|
|
135
135
|
onDrag && onDrag(event, info);
|
|
136
136
|
};
|
|
137
137
|
const onSessionEnd = (event, info) => this.stop(event, info);
|
|
138
|
-
const resumeAnimation = () => eachAxis((axis) =>
|
|
139
|
-
|
|
140
|
-
return this.getAnimationState(axis) === "paused" &&
|
|
141
|
-
((_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.play());
|
|
142
|
-
});
|
|
138
|
+
const resumeAnimation = () => eachAxis((axis) => this.getAnimationState(axis) === "paused" &&
|
|
139
|
+
this.getAxisMotionValue(axis).animation?.play());
|
|
143
140
|
const { dragSnapToOrigin } = this.getProps();
|
|
144
141
|
this.panSession = new PanSession(originEvent, {
|
|
145
142
|
onSessionStart,
|
|
@@ -194,12 +191,11 @@ class VisualElementDragControls {
|
|
|
194
191
|
axisValue.set(next);
|
|
195
192
|
}
|
|
196
193
|
resolveConstraints() {
|
|
197
|
-
var _a;
|
|
198
194
|
const { dragConstraints, dragElastic } = this.getProps();
|
|
199
195
|
const layout = this.visualElement.projection &&
|
|
200
196
|
!this.visualElement.projection.layout
|
|
201
197
|
? this.visualElement.projection.measure(false)
|
|
202
|
-
:
|
|
198
|
+
: this.visualElement.projection?.layout;
|
|
203
199
|
const prevConstraints = this.constraints;
|
|
204
200
|
if (dragConstraints && isRefObject(dragConstraints)) {
|
|
205
201
|
if (!this.constraints) {
|
|
@@ -302,11 +298,10 @@ class VisualElementDragControls {
|
|
|
302
298
|
eachAxis((axis) => this.getAxisMotionValue(axis).stop());
|
|
303
299
|
}
|
|
304
300
|
pauseAnimation() {
|
|
305
|
-
eachAxis((axis) =>
|
|
301
|
+
eachAxis((axis) => this.getAxisMotionValue(axis).animation?.pause());
|
|
306
302
|
}
|
|
307
303
|
getAnimationState(axis) {
|
|
308
|
-
|
|
309
|
-
return (_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.state;
|
|
304
|
+
return this.getAxisMotionValue(axis).animation?.state;
|
|
310
305
|
}
|
|
311
306
|
/**
|
|
312
307
|
* Drag works differently depending on which props are provided.
|
|
@@ -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,
|
|
@@ -11,7 +11,6 @@ import { isRefObject } from '../../utils/is-ref-object.mjs';
|
|
|
11
11
|
import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';
|
|
12
12
|
|
|
13
13
|
function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
|
|
14
|
-
var _a, _b;
|
|
15
14
|
const { visualElement: parent } = useContext(MotionContext);
|
|
16
15
|
const lazyContext = useContext(LazyContext);
|
|
17
16
|
const presenceContext = useContext(PresenceContext);
|
|
@@ -61,8 +60,8 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
61
60
|
*/
|
|
62
61
|
const optimisedAppearId = props[optimizedAppearDataAttribute];
|
|
63
62
|
const wantsHandoff = useRef(Boolean(optimisedAppearId) &&
|
|
64
|
-
!
|
|
65
|
-
|
|
63
|
+
!window.MotionHandoffIsComplete?.(optimisedAppearId) &&
|
|
64
|
+
window.MotionHasOptimisedAnimation?.(optimisedAppearId));
|
|
66
65
|
useIsomorphicLayoutEffect(() => {
|
|
67
66
|
if (!visualElement)
|
|
68
67
|
return;
|
|
@@ -93,8 +92,7 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
93
92
|
if (wantsHandoff.current) {
|
|
94
93
|
// This ensures all future calls to animateChanges() in this component will run in useEffect
|
|
95
94
|
queueMicrotask(() => {
|
|
96
|
-
|
|
97
|
-
(_a = window.MotionHandoffMarkAsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId);
|
|
95
|
+
window.MotionHandoffMarkAsComplete?.(optimisedAppearId);
|
|
98
96
|
});
|
|
99
97
|
wantsHandoff.current = false;
|
|
100
98
|
}
|