motion 12.6.3-alpha.0 → 12.6.4-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/dist/cjs/debug.js +18 -14
- package/dist/cjs/index.js +414 -359
- package/dist/cjs/mini.js +339 -352
- package/dist/cjs/react-client.js +180 -188
- package/dist/cjs/react-m.js +24 -24
- 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/interpolate.mjs +2 -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/framer-motion/dist/es/value/use-will-change/add-will-change.mjs +0 -7
- package/dist/es/motion/lib/index.mjs +1 -0
- package/dist/es/motion/lib/react.mjs +1 -1
- 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/es/motion-utils/dist/es/global-config.mjs +1 -4
- package/dist/motion.dev.js +414 -359
- 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
package/dist/cjs/react-client.js
CHANGED
|
@@ -13,7 +13,7 @@ function isAnimationControls(v) {
|
|
|
13
13
|
|
|
14
14
|
function getValueState(visualElement) {
|
|
15
15
|
const state = [{}, {}];
|
|
16
|
-
visualElement
|
|
16
|
+
visualElement?.values.forEach((value, key) => {
|
|
17
17
|
state[0][key] = value.get();
|
|
18
18
|
state[1][key] = value.getVelocity();
|
|
19
19
|
});
|
|
@@ -61,11 +61,8 @@ function removeItem(arr, item) {
|
|
|
61
61
|
arr.splice(index, 1);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let warning = noop;
|
|
68
|
-
let invariant = noop;
|
|
64
|
+
let warning = () => { };
|
|
65
|
+
let invariant = () => { };
|
|
69
66
|
if (process.env.NODE_ENV !== "production") {
|
|
70
67
|
warning = (check, message) => {
|
|
71
68
|
if (!check && typeof console !== "undefined") {
|
|
@@ -79,10 +76,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
79
76
|
};
|
|
80
77
|
}
|
|
81
78
|
|
|
82
|
-
const MotionGlobalConfig = {
|
|
83
|
-
skipAnimations: false,
|
|
84
|
-
useManualTiming: false,
|
|
85
|
-
};
|
|
79
|
+
const MotionGlobalConfig = {};
|
|
86
80
|
|
|
87
81
|
/*#__NO_SIDE_EFFECTS__*/
|
|
88
82
|
function memo(callback) {
|
|
@@ -94,6 +88,9 @@ function memo(callback) {
|
|
|
94
88
|
};
|
|
95
89
|
}
|
|
96
90
|
|
|
91
|
+
/*#__NO_SIDE_EFFECTS__*/
|
|
92
|
+
const noop = (any) => any;
|
|
93
|
+
|
|
97
94
|
/*
|
|
98
95
|
Progress within given range
|
|
99
96
|
|
|
@@ -182,15 +179,14 @@ function warnOnce(condition, message, element) {
|
|
|
182
179
|
|
|
183
180
|
const supportsScrollTimeline = /* @__PURE__ */ memo(() => window.ScrollTimeline !== undefined);
|
|
184
181
|
|
|
185
|
-
class
|
|
182
|
+
class GroupAnimation {
|
|
186
183
|
constructor(animations) {
|
|
187
184
|
// Bound to accomodate common `return animation.stop` pattern
|
|
188
185
|
this.stop = () => this.runAll("stop");
|
|
189
186
|
this.animations = animations.filter(Boolean);
|
|
190
187
|
}
|
|
191
188
|
get finished() {
|
|
192
|
-
|
|
193
|
-
return Promise.all(this.animations.map((animation) => "finished" in animation ? animation.finished : animation));
|
|
189
|
+
return Promise.all(this.animations.map((animation) => animation.finished));
|
|
194
190
|
}
|
|
195
191
|
/**
|
|
196
192
|
* TODO: Filter out cancelled or stopped animations before returning
|
|
@@ -261,48 +257,16 @@ class BaseGroupPlaybackControls {
|
|
|
261
257
|
}
|
|
262
258
|
}
|
|
263
259
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
*/
|
|
268
|
-
class GroupPlaybackControls extends BaseGroupPlaybackControls {
|
|
269
|
-
then(onResolve, onReject) {
|
|
270
|
-
return Promise.all(this.animations).then(onResolve).catch(onReject);
|
|
260
|
+
class GroupAnimationWithThen extends GroupAnimation {
|
|
261
|
+
then(onResolve, _onReject) {
|
|
262
|
+
return this.finished.finally(onResolve).then(() => { });
|
|
271
263
|
}
|
|
272
264
|
}
|
|
273
265
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
transition
|
|
279
|
-
: undefined;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Implement a practical max duration for keyframe generation
|
|
284
|
-
* to prevent infinite loops
|
|
285
|
-
*/
|
|
286
|
-
const maxGeneratorDuration = 20000;
|
|
287
|
-
function calcGeneratorDuration(generator) {
|
|
288
|
-
let duration = 0;
|
|
289
|
-
const timeStep = 50;
|
|
290
|
-
let state = generator.next(duration);
|
|
291
|
-
while (!state.done && duration < maxGeneratorDuration) {
|
|
292
|
-
duration += timeStep;
|
|
293
|
-
state = generator.next(duration);
|
|
294
|
-
}
|
|
295
|
-
return duration >= maxGeneratorDuration ? Infinity : duration;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function isGenerator(type) {
|
|
299
|
-
return typeof type === "function";
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function attachTimeline(animation, timeline) {
|
|
303
|
-
animation.timeline = timeline;
|
|
304
|
-
animation.onfinish = null;
|
|
305
|
-
}
|
|
266
|
+
const statsBuffer = {
|
|
267
|
+
value: null,
|
|
268
|
+
addProjectionMetrics: null,
|
|
269
|
+
};
|
|
306
270
|
|
|
307
271
|
const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
|
|
308
272
|
|
|
@@ -310,13 +274,11 @@ const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0]
|
|
|
310
274
|
* Add the ability for test suites to manually set support flags
|
|
311
275
|
* to better test more environments.
|
|
312
276
|
*/
|
|
313
|
-
const supportsFlags = {
|
|
314
|
-
linearEasing: undefined,
|
|
315
|
-
};
|
|
277
|
+
const supportsFlags = {};
|
|
316
278
|
|
|
317
279
|
function memoSupports(callback, supportsFlag) {
|
|
318
280
|
const memoized = memo(callback);
|
|
319
|
-
return () =>
|
|
281
|
+
return () => supportsFlags[supportsFlag] ?? memoized();
|
|
320
282
|
}
|
|
321
283
|
|
|
322
284
|
const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
|
|
@@ -337,20 +299,13 @@ resolution = 10 // as milliseconds
|
|
|
337
299
|
let points = "";
|
|
338
300
|
const numPoints = Math.max(Math.round(duration / resolution), 2);
|
|
339
301
|
for (let i = 0; i < numPoints; i++) {
|
|
340
|
-
points += easing(
|
|
302
|
+
points += easing(i / (numPoints - 1)) + ", ";
|
|
341
303
|
}
|
|
342
304
|
return `linear(${points.substring(0, points.length - 2)})`;
|
|
343
305
|
};
|
|
344
306
|
|
|
345
|
-
function isWaapiSupportedEasing(easing) {
|
|
346
|
-
return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
|
|
347
|
-
!easing ||
|
|
348
|
-
(typeof easing === "string" &&
|
|
349
|
-
(easing in supportedWaapiEasing || supportsLinearEasing())) ||
|
|
350
|
-
isBezierDefinition(easing) ||
|
|
351
|
-
(Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
|
|
352
|
-
}
|
|
353
307
|
const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
|
|
308
|
+
|
|
354
309
|
const supportedWaapiEasing = {
|
|
355
310
|
linear: "linear",
|
|
356
311
|
ease: "ease",
|
|
@@ -362,6 +317,7 @@ const supportedWaapiEasing = {
|
|
|
362
317
|
backIn: /*@__PURE__*/ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
|
|
363
318
|
backOut: /*@__PURE__*/ cubicBezierAsString([0.33, 1.53, 0.69, 0.99]),
|
|
364
319
|
};
|
|
320
|
+
|
|
365
321
|
function mapEasingToNativeEasing(easing, duration) {
|
|
366
322
|
if (!easing) {
|
|
367
323
|
return undefined;
|
|
@@ -381,6 +337,85 @@ function mapEasingToNativeEasing(easing, duration) {
|
|
|
381
337
|
}
|
|
382
338
|
}
|
|
383
339
|
|
|
340
|
+
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}, pseudoElement = undefined) {
|
|
341
|
+
const keyframeOptions = {
|
|
342
|
+
[valueName]: keyframes,
|
|
343
|
+
};
|
|
344
|
+
if (times)
|
|
345
|
+
keyframeOptions.offset = times;
|
|
346
|
+
const easing = mapEasingToNativeEasing(ease, duration);
|
|
347
|
+
/**
|
|
348
|
+
* If this is an easing array, apply to keyframes, not animation as a whole
|
|
349
|
+
*/
|
|
350
|
+
if (Array.isArray(easing))
|
|
351
|
+
keyframeOptions.easing = easing;
|
|
352
|
+
const animation = element.animate(keyframeOptions, {
|
|
353
|
+
delay,
|
|
354
|
+
duration,
|
|
355
|
+
easing: !Array.isArray(easing) ? easing : "linear",
|
|
356
|
+
fill: "both",
|
|
357
|
+
iterations: repeat + 1,
|
|
358
|
+
direction: repeatType === "reverse" ? "alternate" : "normal",
|
|
359
|
+
pseudoElement,
|
|
360
|
+
});
|
|
361
|
+
return animation;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function isGenerator(type) {
|
|
365
|
+
return typeof type === "function" && "applyToOptions" in type;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function getValueTransition(transition, key) {
|
|
369
|
+
return (transition?.[key] ??
|
|
370
|
+
transition?.["default"] ??
|
|
371
|
+
transition);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Implement a practical max duration for keyframe generation
|
|
376
|
+
* to prevent infinite loops
|
|
377
|
+
*/
|
|
378
|
+
const maxGeneratorDuration = 20000;
|
|
379
|
+
function calcGeneratorDuration(generator) {
|
|
380
|
+
let duration = 0;
|
|
381
|
+
const timeStep = 50;
|
|
382
|
+
let state = generator.next(duration);
|
|
383
|
+
while (!state.done && duration < maxGeneratorDuration) {
|
|
384
|
+
duration += timeStep;
|
|
385
|
+
state = generator.next(duration);
|
|
386
|
+
}
|
|
387
|
+
return duration >= maxGeneratorDuration ? Infinity : duration;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Create a progress => progress easing function from a generator.
|
|
392
|
+
*/
|
|
393
|
+
function createGeneratorEasing(options, scale = 100, createGenerator) {
|
|
394
|
+
const generator = createGenerator({ ...options, keyframes: [0, scale] });
|
|
395
|
+
const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
396
|
+
return {
|
|
397
|
+
type: "keyframes",
|
|
398
|
+
ease: (progress) => {
|
|
399
|
+
return generator.next(duration * progress).value / scale;
|
|
400
|
+
},
|
|
401
|
+
duration: millisecondsToSeconds(duration),
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function isWaapiSupportedEasing(easing) {
|
|
406
|
+
return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
|
|
407
|
+
!easing ||
|
|
408
|
+
(typeof easing === "string" &&
|
|
409
|
+
(easing in supportedWaapiEasing || supportsLinearEasing())) ||
|
|
410
|
+
isBezierDefinition(easing) ||
|
|
411
|
+
(Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function attachTimeline(animation, timeline) {
|
|
415
|
+
animation.timeline = timeline;
|
|
416
|
+
animation.onfinish = null;
|
|
417
|
+
}
|
|
418
|
+
|
|
384
419
|
const stepsOrder = [
|
|
385
420
|
"read", // Read
|
|
386
421
|
"resolveKeyframes", // Write/Read/Write/Read
|
|
@@ -390,11 +425,6 @@ const stepsOrder = [
|
|
|
390
425
|
"postRender", // Compute
|
|
391
426
|
];
|
|
392
427
|
|
|
393
|
-
const statsBuffer = {
|
|
394
|
-
value: null,
|
|
395
|
-
addProjectionMetrics: null,
|
|
396
|
-
};
|
|
397
|
-
|
|
398
428
|
function createRenderStep(runNextFrame, stepName) {
|
|
399
429
|
/**
|
|
400
430
|
* We create and reuse two queues, one to queue jobs for the current frame
|
|
@@ -500,9 +530,11 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
|
|
|
500
530
|
}, {});
|
|
501
531
|
const { read, resolveKeyframes, update, preRender, render, postRender } = steps;
|
|
502
532
|
const processBatch = () => {
|
|
503
|
-
const timestamp =
|
|
533
|
+
const timestamp = MotionGlobalConfig.useManualTiming
|
|
534
|
+
? state.timestamp
|
|
535
|
+
: performance.now();
|
|
504
536
|
runNextFrame = false;
|
|
505
|
-
{
|
|
537
|
+
if (!MotionGlobalConfig.useManualTiming) {
|
|
506
538
|
state.delta = useDefaultElapsed
|
|
507
539
|
? 1000 / 60
|
|
508
540
|
: Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);
|
|
@@ -612,21 +644,16 @@ function setDragLock(axis) {
|
|
|
612
644
|
}
|
|
613
645
|
|
|
614
646
|
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
615
|
-
var _a;
|
|
616
647
|
if (elementOrSelector instanceof EventTarget) {
|
|
617
648
|
return [elementOrSelector];
|
|
618
649
|
}
|
|
619
650
|
else if (typeof elementOrSelector === "string") {
|
|
620
651
|
let root = document;
|
|
621
652
|
if (scope) {
|
|
622
|
-
// TODO: Refactor to utils package
|
|
623
|
-
// invariant(
|
|
624
|
-
// Boolean(scope.current),
|
|
625
|
-
// "Scope provided, but no element detected."
|
|
626
|
-
// )
|
|
627
653
|
root = scope.current;
|
|
628
654
|
}
|
|
629
|
-
const elements =
|
|
655
|
+
const elements = selectorCache?.[elementOrSelector] ??
|
|
656
|
+
root.querySelectorAll(elementOrSelector);
|
|
630
657
|
return elements ? Array.from(elements) : [];
|
|
631
658
|
}
|
|
632
659
|
return Array.from(elementOrSelector);
|
|
@@ -825,7 +852,7 @@ function press(targetOrSelector, onPressStart, options = {}) {
|
|
|
825
852
|
if (target instanceof HTMLElement) {
|
|
826
853
|
target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions));
|
|
827
854
|
if (!isElementKeyboardAccessible(target) &&
|
|
828
|
-
target.
|
|
855
|
+
!target.hasAttribute("tabindex")) {
|
|
829
856
|
target.tabIndex = 0;
|
|
830
857
|
}
|
|
831
858
|
}
|
|
@@ -858,7 +885,7 @@ class MotionValue {
|
|
|
858
885
|
* This will be replaced by the build step with the latest version number.
|
|
859
886
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
860
887
|
*/
|
|
861
|
-
this.version = "12.6.
|
|
888
|
+
this.version = "12.6.4-alpha.0";
|
|
862
889
|
/**
|
|
863
890
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
864
891
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -1219,11 +1246,6 @@ function addValueToWillChange(visualElement, key) {
|
|
|
1219
1246
|
if (isWillChangeMotionValue(willChange)) {
|
|
1220
1247
|
return willChange.add(key);
|
|
1221
1248
|
}
|
|
1222
|
-
else if (!willChange && MotionGlobalConfig.WillChange) {
|
|
1223
|
-
const newWillChange = new MotionGlobalConfig.WillChange("auto");
|
|
1224
|
-
visualElement.addValue("willChange", newWillChange);
|
|
1225
|
-
newWillChange.add(key);
|
|
1226
|
-
}
|
|
1227
1249
|
}
|
|
1228
1250
|
|
|
1229
1251
|
/**
|
|
@@ -1491,11 +1513,10 @@ const color = {
|
|
|
1491
1513
|
const colorRegex = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
|
|
1492
1514
|
|
|
1493
1515
|
function test(v) {
|
|
1494
|
-
var _a, _b;
|
|
1495
1516
|
return (isNaN(v) &&
|
|
1496
1517
|
typeof v === "string" &&
|
|
1497
|
-
(
|
|
1498
|
-
(
|
|
1518
|
+
(v.match(floatRegex)?.length || 0) +
|
|
1519
|
+
(v.match(colorRegex)?.length || 0) >
|
|
1499
1520
|
0);
|
|
1500
1521
|
}
|
|
1501
1522
|
const NUMBER_TOKEN = "number";
|
|
@@ -1883,8 +1904,7 @@ function measureAllKeyframes() {
|
|
|
1883
1904
|
const restore = transformsToRestore.get(element);
|
|
1884
1905
|
if (restore) {
|
|
1885
1906
|
restore.forEach(([key, value]) => {
|
|
1886
|
-
|
|
1887
|
-
(_a = element.getValue(key)) === null || _a === void 0 ? void 0 : _a.set(value);
|
|
1907
|
+
element.getValue(key)?.set(value);
|
|
1888
1908
|
});
|
|
1889
1909
|
}
|
|
1890
1910
|
});
|
|
@@ -1971,7 +1991,7 @@ class KeyframeResolver {
|
|
|
1971
1991
|
* If the first keyframe is null, we need to find its value by sampling the element
|
|
1972
1992
|
*/
|
|
1973
1993
|
if (i === 0) {
|
|
1974
|
-
const currentValue = motionValue
|
|
1994
|
+
const currentValue = motionValue?.get();
|
|
1975
1995
|
const finalKeyframe = unresolvedKeyframes[unresolvedKeyframes.length - 1];
|
|
1976
1996
|
if (currentValue !== undefined) {
|
|
1977
1997
|
unresolvedKeyframes[0] = currentValue;
|
|
@@ -2052,7 +2072,7 @@ function parseCSSVariable(current) {
|
|
|
2052
2072
|
if (!match)
|
|
2053
2073
|
return [,];
|
|
2054
2074
|
const [, token1, token2, fallback] = match;
|
|
2055
|
-
return [`--${token1
|
|
2075
|
+
return [`--${token1 ?? token2}`, fallback];
|
|
2056
2076
|
}
|
|
2057
2077
|
const maxDepth = 4;
|
|
2058
2078
|
function getVariableValue(current, element, depth = 1) {
|
|
@@ -2191,7 +2211,6 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
2191
2211
|
}
|
|
2192
2212
|
}
|
|
2193
2213
|
measureEndState() {
|
|
2194
|
-
var _a;
|
|
2195
2214
|
const { element, name, unresolvedKeyframes } = this;
|
|
2196
2215
|
if (!element || !element.current)
|
|
2197
2216
|
return;
|
|
@@ -2204,7 +2223,7 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
2204
2223
|
this.finalKeyframe = finalKeyframe;
|
|
2205
2224
|
}
|
|
2206
2225
|
// If we removed transform values, reapply them before the next render
|
|
2207
|
-
if (
|
|
2226
|
+
if (this.removedTransforms?.length) {
|
|
2208
2227
|
this.removedTransforms.forEach(([unsetTransformName, unsetTransformValue]) => {
|
|
2209
2228
|
element
|
|
2210
2229
|
.getValue(unsetTransformName)
|
|
@@ -2585,13 +2604,12 @@ function mixObject(a, b) {
|
|
|
2585
2604
|
};
|
|
2586
2605
|
}
|
|
2587
2606
|
function matchOrder(origin, target) {
|
|
2588
|
-
var _a;
|
|
2589
2607
|
const orderedOrigin = [];
|
|
2590
2608
|
const pointers = { color: 0, var: 0, number: 0 };
|
|
2591
2609
|
for (let i = 0; i < target.values.length; i++) {
|
|
2592
2610
|
const type = target.types[i];
|
|
2593
2611
|
const originIndex = origin.indexes[type][pointers[type]];
|
|
2594
|
-
const originValue =
|
|
2612
|
+
const originValue = origin.values[originIndex] ?? 0;
|
|
2595
2613
|
orderedOrigin[i] = originValue;
|
|
2596
2614
|
pointers[type]++;
|
|
2597
2615
|
}
|
|
@@ -2895,9 +2913,17 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
|
|
|
2895
2913
|
const easing = generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
|
|
2896
2914
|
return calculatedDuration + "ms " + easing;
|
|
2897
2915
|
},
|
|
2916
|
+
toTransition: () => { },
|
|
2898
2917
|
};
|
|
2899
2918
|
return generator;
|
|
2900
2919
|
}
|
|
2920
|
+
spring.applyToOptions = (options) => {
|
|
2921
|
+
const generatorOptions = createGeneratorEasing(options, 100, spring);
|
|
2922
|
+
options.ease = supportsLinearEasing() ? generatorOptions.ease : "easeOut";
|
|
2923
|
+
options.duration = secondsToMilliseconds(generatorOptions.duration);
|
|
2924
|
+
options.type = "keyframes";
|
|
2925
|
+
return options;
|
|
2926
|
+
};
|
|
2901
2927
|
|
|
2902
2928
|
function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed, }) {
|
|
2903
2929
|
const origin = keyframes[0];
|
|
@@ -3020,7 +3046,7 @@ const easingDefinitionToFunction = (definition) => {
|
|
|
3020
3046
|
|
|
3021
3047
|
function createMixers(output, ease, customMixer) {
|
|
3022
3048
|
const mixers = [];
|
|
3023
|
-
const mixerFactory = customMixer || mix;
|
|
3049
|
+
const mixerFactory = customMixer || MotionGlobalConfig.mix || mix;
|
|
3024
3050
|
const numMixers = output.length - 1;
|
|
3025
3051
|
for (let i = 0; i < numMixers; i++) {
|
|
3026
3052
|
let mixer = mixerFactory(output[i], output[i + 1]);
|
|
@@ -3219,7 +3245,7 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
3219
3245
|
onStop && onStop();
|
|
3220
3246
|
};
|
|
3221
3247
|
const { name, motionValue, element, keyframes } = this.options;
|
|
3222
|
-
const KeyframeResolver$1 =
|
|
3248
|
+
const KeyframeResolver$1 = element?.KeyframeResolver || KeyframeResolver;
|
|
3223
3249
|
const onResolved = (resolvedKeyframes, finalKeyframe) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe);
|
|
3224
3250
|
this.resolver = new KeyframeResolver$1(keyframes, onResolved, name, motionValue, element);
|
|
3225
3251
|
this.resolver.scheduleResolve();
|
|
@@ -3468,7 +3494,7 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
3468
3494
|
this.startTime = now - this.holdTime;
|
|
3469
3495
|
}
|
|
3470
3496
|
else if (!this.startTime) {
|
|
3471
|
-
this.startTime = startTime
|
|
3497
|
+
this.startTime = startTime ?? this.calcStartTime();
|
|
3472
3498
|
}
|
|
3473
3499
|
else if (this.state === "finished") {
|
|
3474
3500
|
this.startTime = now;
|
|
@@ -3486,13 +3512,12 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
3486
3512
|
this.driver.start();
|
|
3487
3513
|
}
|
|
3488
3514
|
pause() {
|
|
3489
|
-
var _a;
|
|
3490
3515
|
if (!this._resolved) {
|
|
3491
3516
|
this.pendingPlayState = "paused";
|
|
3492
3517
|
return;
|
|
3493
3518
|
}
|
|
3494
3519
|
this.state = "paused";
|
|
3495
|
-
this.holdTime =
|
|
3520
|
+
this.holdTime = this.currentTime ?? 0;
|
|
3496
3521
|
}
|
|
3497
3522
|
complete() {
|
|
3498
3523
|
if (this.state !== "running") {
|
|
@@ -3532,6 +3557,9 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
3532
3557
|
this.startTime = 0;
|
|
3533
3558
|
return this.tick(time, true);
|
|
3534
3559
|
}
|
|
3560
|
+
get finished() {
|
|
3561
|
+
return this.currentFinishedPromise;
|
|
3562
|
+
}
|
|
3535
3563
|
}
|
|
3536
3564
|
|
|
3537
3565
|
/**
|
|
@@ -3547,27 +3575,6 @@ const acceleratedValues = new Set([
|
|
|
3547
3575
|
// "background-color"
|
|
3548
3576
|
]);
|
|
3549
3577
|
|
|
3550
|
-
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
|
|
3551
|
-
const keyframeOptions = { [valueName]: keyframes };
|
|
3552
|
-
if (times)
|
|
3553
|
-
keyframeOptions.offset = times;
|
|
3554
|
-
const easing = mapEasingToNativeEasing(ease, duration);
|
|
3555
|
-
/**
|
|
3556
|
-
* If this is an easing array, apply to keyframes, not animation as a whole
|
|
3557
|
-
*/
|
|
3558
|
-
if (Array.isArray(easing))
|
|
3559
|
-
keyframeOptions.easing = easing;
|
|
3560
|
-
const animation = element.animate(keyframeOptions, {
|
|
3561
|
-
delay,
|
|
3562
|
-
duration,
|
|
3563
|
-
easing: !Array.isArray(easing) ? easing : "linear",
|
|
3564
|
-
fill: "both",
|
|
3565
|
-
iterations: repeat + 1,
|
|
3566
|
-
direction: repeatType === "reverse" ? "alternate" : "normal",
|
|
3567
|
-
});
|
|
3568
|
-
return animation;
|
|
3569
|
-
}
|
|
3570
|
-
|
|
3571
3578
|
const supportsWaapi = /*@__PURE__*/ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
|
|
3572
3579
|
|
|
3573
3580
|
/**
|
|
@@ -3678,7 +3685,7 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
3678
3685
|
const animation = startWaapiAnimation(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
|
|
3679
3686
|
// Override the browser calculated startTime with one synchronised to other JS
|
|
3680
3687
|
// and WAAPI animations starting this event loop.
|
|
3681
|
-
animation.startTime = startTime
|
|
3688
|
+
animation.startTime = startTime ?? this.calcStartTime();
|
|
3682
3689
|
if (this.pendingTimeline) {
|
|
3683
3690
|
attachTimeline(animation, this.pendingTimeline);
|
|
3684
3691
|
this.pendingTimeline = undefined;
|
|
@@ -3737,6 +3744,9 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
3737
3744
|
const { animation } = resolved;
|
|
3738
3745
|
return animation.playbackRate;
|
|
3739
3746
|
}
|
|
3747
|
+
get finished() {
|
|
3748
|
+
return this.resolved.animation.finished;
|
|
3749
|
+
}
|
|
3740
3750
|
set speed(newSpeed) {
|
|
3741
3751
|
const { resolved } = this;
|
|
3742
3752
|
if (!resolved)
|
|
@@ -3983,6 +3993,11 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
3983
3993
|
shouldSkip = true;
|
|
3984
3994
|
}
|
|
3985
3995
|
}
|
|
3996
|
+
if (MotionGlobalConfig.skipAnimations) {
|
|
3997
|
+
shouldSkip = true;
|
|
3998
|
+
options.duration = 0;
|
|
3999
|
+
options.delay = 0;
|
|
4000
|
+
}
|
|
3986
4001
|
/**
|
|
3987
4002
|
* If the transition type or easing has been explicitly set by the user
|
|
3988
4003
|
* then we don't want to allow flattening the animation.
|
|
@@ -4002,7 +4017,7 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
4002
4017
|
});
|
|
4003
4018
|
// We still want to return some animation controls here rather
|
|
4004
4019
|
// than returning undefined
|
|
4005
|
-
return new
|
|
4020
|
+
return new GroupAnimationWithThen([]);
|
|
4006
4021
|
}
|
|
4007
4022
|
}
|
|
4008
4023
|
/**
|
|
@@ -4030,7 +4045,6 @@ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
|
|
|
4030
4045
|
return shouldBlock;
|
|
4031
4046
|
}
|
|
4032
4047
|
function animateTarget(visualElement, targetAndTransition, { delay = 0, transitionOverride, type } = {}) {
|
|
4033
|
-
var _a;
|
|
4034
4048
|
let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = targetAndTransition;
|
|
4035
4049
|
if (transitionOverride)
|
|
4036
4050
|
transition = transitionOverride;
|
|
@@ -4039,7 +4053,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
|
|
|
4039
4053
|
visualElement.animationState &&
|
|
4040
4054
|
visualElement.animationState.getState()[type];
|
|
4041
4055
|
for (const key in target) {
|
|
4042
|
-
const value = visualElement.getValue(key,
|
|
4056
|
+
const value = visualElement.getValue(key, visualElement.latestValues[key] ?? null);
|
|
4043
4057
|
const valueTarget = target[key];
|
|
4044
4058
|
if (valueTarget === undefined ||
|
|
4045
4059
|
(animationTypeState &&
|
|
@@ -4085,9 +4099,8 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
|
|
|
4085
4099
|
}
|
|
4086
4100
|
|
|
4087
4101
|
function animateVariant(visualElement, variant, options = {}) {
|
|
4088
|
-
var _a;
|
|
4089
4102
|
const resolved = resolveVariant(visualElement, variant, options.type === "exit"
|
|
4090
|
-
?
|
|
4103
|
+
? visualElement.presenceContext?.custom
|
|
4091
4104
|
: undefined);
|
|
4092
4105
|
let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
|
|
4093
4106
|
if (options.transitionOverride) {
|
|
@@ -4236,9 +4249,8 @@ function createAnimationState(visualElement) {
|
|
|
4236
4249
|
* each active animation type into an object of resolved values for it.
|
|
4237
4250
|
*/
|
|
4238
4251
|
const buildResolvedTypeValues = (type) => (acc, definition) => {
|
|
4239
|
-
var _a;
|
|
4240
4252
|
const resolved = resolveVariant(visualElement, definition, type === "exit"
|
|
4241
|
-
?
|
|
4253
|
+
? visualElement.presenceContext?.custom
|
|
4242
4254
|
: undefined);
|
|
4243
4255
|
if (resolved) {
|
|
4244
4256
|
const { transition, transitionEnd, ...target } = resolved;
|
|
@@ -4486,7 +4498,7 @@ function createAnimationState(visualElement) {
|
|
|
4486
4498
|
if (motionValue)
|
|
4487
4499
|
motionValue.liveStyle = true;
|
|
4488
4500
|
// @ts-expect-error - @mattgperry to figure if we should do something here
|
|
4489
|
-
fallbackAnimation[key] = fallbackTarget
|
|
4501
|
+
fallbackAnimation[key] = fallbackTarget ?? null;
|
|
4490
4502
|
});
|
|
4491
4503
|
animations.push({ animation: fallbackAnimation });
|
|
4492
4504
|
}
|
|
@@ -4503,12 +4515,11 @@ function createAnimationState(visualElement) {
|
|
|
4503
4515
|
* Change whether a certain animation type is active.
|
|
4504
4516
|
*/
|
|
4505
4517
|
function setActive(type, isActive) {
|
|
4506
|
-
var _a;
|
|
4507
4518
|
// If the active state hasn't changed, we can safely do nothing here
|
|
4508
4519
|
if (state[type].isActive === isActive)
|
|
4509
4520
|
return Promise.resolve();
|
|
4510
4521
|
// Propagate active change to children
|
|
4511
|
-
|
|
4522
|
+
visualElement.variantChildren?.forEach((child) => child.animationState?.setActive(type, isActive));
|
|
4512
4523
|
state[type].isActive = isActive;
|
|
4513
4524
|
const animations = animateChanges(type);
|
|
4514
4525
|
for (const key in state) {
|
|
@@ -4594,9 +4605,8 @@ class AnimationFeature extends Feature {
|
|
|
4594
4605
|
}
|
|
4595
4606
|
}
|
|
4596
4607
|
unmount() {
|
|
4597
|
-
var _a;
|
|
4598
4608
|
this.node.animationState.reset();
|
|
4599
|
-
|
|
4609
|
+
this.unmountControls?.();
|
|
4600
4610
|
}
|
|
4601
4611
|
}
|
|
4602
4612
|
|
|
@@ -5323,11 +5333,8 @@ class VisualElementDragControls {
|
|
|
5323
5333
|
onDrag && onDrag(event, info);
|
|
5324
5334
|
};
|
|
5325
5335
|
const onSessionEnd = (event, info) => this.stop(event, info);
|
|
5326
|
-
const resumeAnimation = () => eachAxis((axis) =>
|
|
5327
|
-
|
|
5328
|
-
return this.getAnimationState(axis) === "paused" &&
|
|
5329
|
-
((_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.play());
|
|
5330
|
-
});
|
|
5336
|
+
const resumeAnimation = () => eachAxis((axis) => this.getAnimationState(axis) === "paused" &&
|
|
5337
|
+
this.getAxisMotionValue(axis).animation?.play());
|
|
5331
5338
|
const { dragSnapToOrigin } = this.getProps();
|
|
5332
5339
|
this.panSession = new PanSession(originEvent, {
|
|
5333
5340
|
onSessionStart,
|
|
@@ -5382,12 +5389,11 @@ class VisualElementDragControls {
|
|
|
5382
5389
|
axisValue.set(next);
|
|
5383
5390
|
}
|
|
5384
5391
|
resolveConstraints() {
|
|
5385
|
-
var _a;
|
|
5386
5392
|
const { dragConstraints, dragElastic } = this.getProps();
|
|
5387
5393
|
const layout = this.visualElement.projection &&
|
|
5388
5394
|
!this.visualElement.projection.layout
|
|
5389
5395
|
? this.visualElement.projection.measure(false)
|
|
5390
|
-
:
|
|
5396
|
+
: this.visualElement.projection?.layout;
|
|
5391
5397
|
const prevConstraints = this.constraints;
|
|
5392
5398
|
if (dragConstraints && isRefObject(dragConstraints)) {
|
|
5393
5399
|
if (!this.constraints) {
|
|
@@ -5490,11 +5496,10 @@ class VisualElementDragControls {
|
|
|
5490
5496
|
eachAxis((axis) => this.getAxisMotionValue(axis).stop());
|
|
5491
5497
|
}
|
|
5492
5498
|
pauseAnimation() {
|
|
5493
|
-
eachAxis((axis) =>
|
|
5499
|
+
eachAxis((axis) => this.getAxisMotionValue(axis).animation?.pause());
|
|
5494
5500
|
}
|
|
5495
5501
|
getAnimationState(axis) {
|
|
5496
|
-
|
|
5497
|
-
return (_a = this.getAxisMotionValue(axis).animation) === null || _a === void 0 ? void 0 : _a.state;
|
|
5502
|
+
return this.getAxisMotionValue(axis).animation?.state;
|
|
5498
5503
|
}
|
|
5499
5504
|
/**
|
|
5500
5505
|
* Drag works differently depending on which props are provided.
|
|
@@ -6376,7 +6381,7 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
|
|
|
6376
6381
|
*/
|
|
6377
6382
|
const xTranslate = delta.x.translate / treeScale.x;
|
|
6378
6383
|
const yTranslate = delta.y.translate / treeScale.y;
|
|
6379
|
-
const zTranslate =
|
|
6384
|
+
const zTranslate = latestTransform?.z || 0;
|
|
6380
6385
|
if (xTranslate || yTranslate || zTranslate) {
|
|
6381
6386
|
transform = `translate3d(${xTranslate}px, ${yTranslate}px, ${zTranslate}px) `;
|
|
6382
6387
|
}
|
|
@@ -6452,7 +6457,7 @@ function cancelTreeOptimisedTransformAnimations(projectionNode) {
|
|
|
6452
6457
|
}
|
|
6453
6458
|
function createProjectionNode$1({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
|
|
6454
6459
|
return class ProjectionNode {
|
|
6455
|
-
constructor(latestValues = {}, parent = defaultParent
|
|
6460
|
+
constructor(latestValues = {}, parent = defaultParent?.()) {
|
|
6456
6461
|
/**
|
|
6457
6462
|
* A unique ID generated for every projection node.
|
|
6458
6463
|
*/
|
|
@@ -6970,12 +6975,11 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
6970
6975
|
};
|
|
6971
6976
|
}
|
|
6972
6977
|
measurePageBox() {
|
|
6973
|
-
var _a;
|
|
6974
6978
|
const { visualElement } = this.options;
|
|
6975
6979
|
if (!visualElement)
|
|
6976
6980
|
return createBox();
|
|
6977
6981
|
const box = visualElement.measureViewportBox();
|
|
6978
|
-
const wasInScrollRoot =
|
|
6982
|
+
const wasInScrollRoot = this.scroll?.wasRoot || this.path.some(checkNodeWasScrollRoot);
|
|
6979
6983
|
if (!wasInScrollRoot) {
|
|
6980
6984
|
// Remove viewport scroll to give page-relative coordinates
|
|
6981
6985
|
const { scroll } = this.root;
|
|
@@ -6987,10 +6991,9 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
6987
6991
|
return box;
|
|
6988
6992
|
}
|
|
6989
6993
|
removeElementScroll(box) {
|
|
6990
|
-
var _a;
|
|
6991
6994
|
const boxWithoutScroll = createBox();
|
|
6992
6995
|
copyBoxInto(boxWithoutScroll, box);
|
|
6993
|
-
if (
|
|
6996
|
+
if (this.scroll?.wasRoot) {
|
|
6994
6997
|
return boxWithoutScroll;
|
|
6995
6998
|
}
|
|
6996
6999
|
/**
|
|
@@ -7093,7 +7096,6 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7093
7096
|
}
|
|
7094
7097
|
}
|
|
7095
7098
|
resolveTargetDelta(forceRecalculation = false) {
|
|
7096
|
-
var _a;
|
|
7097
7099
|
/**
|
|
7098
7100
|
* Once the dirty status of nodes has been spread through the tree, we also
|
|
7099
7101
|
* need to check if we have a shared node of a different depth that has itself
|
|
@@ -7111,7 +7113,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7111
7113
|
const canSkip = !(forceRecalculation ||
|
|
7112
7114
|
(isShared && this.isSharedProjectionDirty) ||
|
|
7113
7115
|
this.isProjectionDirty ||
|
|
7114
|
-
|
|
7116
|
+
this.parent?.isProjectionDirty ||
|
|
7115
7117
|
this.attemptToResolveRelativeTarget ||
|
|
7116
7118
|
this.root.updateBlockedByResize);
|
|
7117
7119
|
if (canSkip)
|
|
@@ -7230,7 +7232,6 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7230
7232
|
this.layout);
|
|
7231
7233
|
}
|
|
7232
7234
|
calcProjection() {
|
|
7233
|
-
var _a;
|
|
7234
7235
|
const lead = this.getLead();
|
|
7235
7236
|
const isShared = Boolean(this.resumingFrom) || this !== lead;
|
|
7236
7237
|
let canSkip = true;
|
|
@@ -7238,7 +7239,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7238
7239
|
* If this is a normal layout animation and neither this node nor its nearest projecting
|
|
7239
7240
|
* is dirty then we can't skip.
|
|
7240
7241
|
*/
|
|
7241
|
-
if (this.isProjectionDirty ||
|
|
7242
|
+
if (this.isProjectionDirty || this.parent?.isProjectionDirty) {
|
|
7242
7243
|
canSkip = false;
|
|
7243
7244
|
}
|
|
7244
7245
|
/**
|
|
@@ -7344,8 +7345,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7344
7345
|
// TODO: Schedule render
|
|
7345
7346
|
}
|
|
7346
7347
|
scheduleRender(notifyAll = true) {
|
|
7347
|
-
|
|
7348
|
-
(_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.scheduleRender();
|
|
7348
|
+
this.options.visualElement?.scheduleRender();
|
|
7349
7349
|
if (notifyAll) {
|
|
7350
7350
|
const stack = this.getStack();
|
|
7351
7351
|
stack && stack.scheduleRender();
|
|
@@ -7529,14 +7529,12 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7529
7529
|
return stack ? stack.lead === this : true;
|
|
7530
7530
|
}
|
|
7531
7531
|
getLead() {
|
|
7532
|
-
var _a;
|
|
7533
7532
|
const { layoutId } = this.options;
|
|
7534
|
-
return layoutId ?
|
|
7533
|
+
return layoutId ? this.getStack()?.lead || this : this;
|
|
7535
7534
|
}
|
|
7536
7535
|
getPrevLead() {
|
|
7537
|
-
var _a;
|
|
7538
7536
|
const { layoutId } = this.options;
|
|
7539
|
-
return layoutId ?
|
|
7537
|
+
return layoutId ? this.getStack()?.prevLead : undefined;
|
|
7540
7538
|
}
|
|
7541
7539
|
getStack() {
|
|
7542
7540
|
const { layoutId } = this.options;
|
|
@@ -7610,7 +7608,6 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7610
7608
|
visualElement.scheduleRender();
|
|
7611
7609
|
}
|
|
7612
7610
|
getProjectionStyles(styleProp) {
|
|
7613
|
-
var _a, _b;
|
|
7614
7611
|
if (!this.instance || this.isSVG)
|
|
7615
7612
|
return undefined;
|
|
7616
7613
|
if (!this.isVisible) {
|
|
@@ -7624,7 +7621,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7624
7621
|
this.needsReset = false;
|
|
7625
7622
|
styles.opacity = "";
|
|
7626
7623
|
styles.pointerEvents =
|
|
7627
|
-
resolveMotionValue(styleProp
|
|
7624
|
+
resolveMotionValue(styleProp?.pointerEvents) || "";
|
|
7628
7625
|
styles.transform = transformTemplate
|
|
7629
7626
|
? transformTemplate(this.latestValues, "")
|
|
7630
7627
|
: "none";
|
|
@@ -7639,7 +7636,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7639
7636
|
? this.latestValues.opacity
|
|
7640
7637
|
: 1;
|
|
7641
7638
|
emptyStyles.pointerEvents =
|
|
7642
|
-
resolveMotionValue(styleProp
|
|
7639
|
+
resolveMotionValue(styleProp?.pointerEvents) || "";
|
|
7643
7640
|
}
|
|
7644
7641
|
if (this.hasProjected && !hasTransform(this.latestValues)) {
|
|
7645
7642
|
emptyStyles.transform = transformTemplate
|
|
@@ -7664,7 +7661,9 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7664
7661
|
*/
|
|
7665
7662
|
styles.opacity =
|
|
7666
7663
|
lead === this
|
|
7667
|
-
?
|
|
7664
|
+
? valuesToRender.opacity ??
|
|
7665
|
+
this.latestValues.opacity ??
|
|
7666
|
+
1
|
|
7668
7667
|
: this.preserveOpacity
|
|
7669
7668
|
? this.latestValues.opacity
|
|
7670
7669
|
: valuesToRender.opacityExit;
|
|
@@ -7725,7 +7724,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7725
7724
|
if (this.options.layoutId) {
|
|
7726
7725
|
styles.pointerEvents =
|
|
7727
7726
|
lead === this
|
|
7728
|
-
? resolveMotionValue(styleProp
|
|
7727
|
+
? resolveMotionValue(styleProp?.pointerEvents) || ""
|
|
7729
7728
|
: "none";
|
|
7730
7729
|
}
|
|
7731
7730
|
return styles;
|
|
@@ -7735,7 +7734,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
7735
7734
|
}
|
|
7736
7735
|
// Only run on root
|
|
7737
7736
|
resetTree() {
|
|
7738
|
-
this.root.nodes.forEach((node) =>
|
|
7737
|
+
this.root.nodes.forEach((node) => node.currentAnimation?.stop());
|
|
7739
7738
|
this.root.nodes.forEach(clearMeasurements);
|
|
7740
7739
|
this.root.sharedNodes.clear();
|
|
7741
7740
|
}
|
|
@@ -7745,8 +7744,7 @@ function updateLayout(node) {
|
|
|
7745
7744
|
node.updateLayout();
|
|
7746
7745
|
}
|
|
7747
7746
|
function notifyLayoutUpdate(node) {
|
|
7748
|
-
|
|
7749
|
-
const snapshot = ((_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) || node.snapshot;
|
|
7747
|
+
const snapshot = node.resumeFrom?.snapshot || node.snapshot;
|
|
7750
7748
|
if (node.isLead() &&
|
|
7751
7749
|
node.layout &&
|
|
7752
7750
|
snapshot &&
|
|
@@ -7946,8 +7944,7 @@ function shouldAnimatePositionOnly(animationType, snapshot, layout) {
|
|
|
7946
7944
|
!isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
|
|
7947
7945
|
}
|
|
7948
7946
|
function checkNodeWasScrollRoot(node) {
|
|
7949
|
-
|
|
7950
|
-
return node !== node.root && ((_a = node.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot);
|
|
7947
|
+
return node !== node.root && node.scroll?.wasRoot;
|
|
7951
7948
|
}
|
|
7952
7949
|
|
|
7953
7950
|
const DocumentProjectionNode = createProjectionNode$1({
|
|
@@ -8337,7 +8334,6 @@ function useMotionRef(visualState, visualElement, externalRef) {
|
|
|
8337
8334
|
const useIsomorphicLayoutEffect = isBrowser ? react.useLayoutEffect : react.useEffect;
|
|
8338
8335
|
|
|
8339
8336
|
function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
|
|
8340
|
-
var _a, _b;
|
|
8341
8337
|
const { visualElement: parent } = react.useContext(MotionContext);
|
|
8342
8338
|
const lazyContext = react.useContext(LazyContext);
|
|
8343
8339
|
const presenceContext = react.useContext(PresenceContext);
|
|
@@ -8387,8 +8383,8 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
8387
8383
|
*/
|
|
8388
8384
|
const optimisedAppearId = props[optimizedAppearDataAttribute];
|
|
8389
8385
|
const wantsHandoff = react.useRef(Boolean(optimisedAppearId) &&
|
|
8390
|
-
!
|
|
8391
|
-
|
|
8386
|
+
!window.MotionHandoffIsComplete?.(optimisedAppearId) &&
|
|
8387
|
+
window.MotionHasOptimisedAnimation?.(optimisedAppearId));
|
|
8392
8388
|
useIsomorphicLayoutEffect(() => {
|
|
8393
8389
|
if (!visualElement)
|
|
8394
8390
|
return;
|
|
@@ -8419,8 +8415,7 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
|
|
|
8419
8415
|
if (wantsHandoff.current) {
|
|
8420
8416
|
// This ensures all future calls to animateChanges() in this component will run in useEffect
|
|
8421
8417
|
queueMicrotask(() => {
|
|
8422
|
-
|
|
8423
|
-
(_a = window.MotionHandoffMarkAsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId);
|
|
8418
|
+
window.MotionHandoffMarkAsComplete?.(optimisedAppearId);
|
|
8424
8419
|
});
|
|
8425
8420
|
wantsHandoff.current = false;
|
|
8426
8421
|
}
|
|
@@ -8468,7 +8463,6 @@ function getClosestProjectingNode(visualElement) {
|
|
|
8468
8463
|
* component "offline", or outside the React render cycle.
|
|
8469
8464
|
*/
|
|
8470
8465
|
function createRendererMotionComponent({ preloadedFeatures, createVisualElement, useRender, useVisualState, Component, }) {
|
|
8471
|
-
var _a, _b;
|
|
8472
8466
|
preloadedFeatures && loadFeatures(preloadedFeatures);
|
|
8473
8467
|
function MotionComponent(props, externalRef) {
|
|
8474
8468
|
/**
|
|
@@ -8504,7 +8498,7 @@ function createRendererMotionComponent({ preloadedFeatures, createVisualElement,
|
|
|
8504
8498
|
}
|
|
8505
8499
|
MotionComponent.displayName = `motion.${typeof Component === "string"
|
|
8506
8500
|
? Component
|
|
8507
|
-
: `create(${
|
|
8501
|
+
: `create(${Component.displayName ?? Component.name ?? ""})`}`;
|
|
8508
8502
|
const ForwardRefMotionComponent = react.forwardRef(MotionComponent);
|
|
8509
8503
|
ForwardRefMotionComponent[motionComponentSymbol] = Component;
|
|
8510
8504
|
return ForwardRefMotionComponent;
|
|
@@ -8536,7 +8530,7 @@ function getProjectionFunctionality(props) {
|
|
|
8536
8530
|
return {};
|
|
8537
8531
|
const combined = { ...drag, ...layout };
|
|
8538
8532
|
return {
|
|
8539
|
-
MeasureLayout:
|
|
8533
|
+
MeasureLayout: drag?.isEnabled(props) || layout?.isEnabled(props)
|
|
8540
8534
|
? combined.MeasureLayout
|
|
8541
8535
|
: undefined,
|
|
8542
8536
|
ProjectionNode: combined.ProjectionNode,
|
|
@@ -8815,7 +8809,7 @@ try {
|
|
|
8815
8809
|
*/
|
|
8816
8810
|
loadExternalIsValidProp(require("@emotion/is-prop-valid").default);
|
|
8817
8811
|
}
|
|
8818
|
-
catch
|
|
8812
|
+
catch {
|
|
8819
8813
|
// We don't need to actually do anything here - the fallback is the existing `isPropValid`.
|
|
8820
8814
|
}
|
|
8821
8815
|
function filterProps(props, isDom, forwardMotionProps) {
|
|
@@ -9136,7 +9130,6 @@ function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
|
|
|
9136
9130
|
}
|
|
9137
9131
|
|
|
9138
9132
|
function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
|
|
9139
|
-
var _a;
|
|
9140
9133
|
const { style } = props;
|
|
9141
9134
|
const newValues = {};
|
|
9142
9135
|
for (const key in style) {
|
|
@@ -9144,7 +9137,7 @@ function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
|
|
|
9144
9137
|
(prevProps.style &&
|
|
9145
9138
|
isMotionValue(prevProps.style[key])) ||
|
|
9146
9139
|
isForcedMotionValue(key, props) ||
|
|
9147
|
-
|
|
9140
|
+
visualElement?.getValue(key)?.liveStyle !== undefined) {
|
|
9148
9141
|
newValues[key] = style[key];
|
|
9149
9142
|
}
|
|
9150
9143
|
}
|
|
@@ -9341,7 +9334,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
9341
9334
|
* and warn against mismatches.
|
|
9342
9335
|
*/
|
|
9343
9336
|
if (process.env.NODE_ENV === "development") {
|
|
9344
|
-
warnOnce(nextValue.version === "12.6.
|
|
9337
|
+
warnOnce(nextValue.version === "12.6.4-alpha.0", `Attempting to mix Motion versions ${nextValue.version} with 12.6.4-alpha.0 may not work as expected.`);
|
|
9345
9338
|
}
|
|
9346
9339
|
}
|
|
9347
9340
|
else if (isMotionValue(prevValue)) {
|
|
@@ -9765,10 +9758,10 @@ class VisualElement {
|
|
|
9765
9758
|
* directly from the instance (which might have performance implications).
|
|
9766
9759
|
*/
|
|
9767
9760
|
readValue(key, target) {
|
|
9768
|
-
var _a;
|
|
9769
9761
|
let value = this.latestValues[key] !== undefined || !this.current
|
|
9770
9762
|
? this.latestValues[key]
|
|
9771
|
-
:
|
|
9763
|
+
: this.getBaseTargetFromProps(this.props, key) ??
|
|
9764
|
+
this.readValueFromInstance(this.current, key, this.options);
|
|
9772
9765
|
if (value !== undefined && value !== null) {
|
|
9773
9766
|
if (typeof value === "string" &&
|
|
9774
9767
|
(isNumericalString(value) || isZeroValueString(value))) {
|
|
@@ -9794,11 +9787,10 @@ class VisualElement {
|
|
|
9794
9787
|
* props.
|
|
9795
9788
|
*/
|
|
9796
9789
|
getBaseTarget(key) {
|
|
9797
|
-
var _a;
|
|
9798
9790
|
const { initial } = this.props;
|
|
9799
9791
|
let valueFromInitial;
|
|
9800
9792
|
if (typeof initial === "string" || typeof initial === "object") {
|
|
9801
|
-
const variant = resolveVariantFromProps(this.props, initial,
|
|
9793
|
+
const variant = resolveVariantFromProps(this.props, initial, this.presenceContext?.custom);
|
|
9802
9794
|
if (variant) {
|
|
9803
9795
|
valueFromInitial = variant[key];
|
|
9804
9796
|
}
|