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
package/dist/cjs/dom.js
CHANGED
|
@@ -279,9 +279,17 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
|
|
|
279
279
|
const easing = motionDom.generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
|
|
280
280
|
return calculatedDuration + "ms " + easing;
|
|
281
281
|
},
|
|
282
|
+
toTransition: () => { },
|
|
282
283
|
};
|
|
283
284
|
return generator;
|
|
284
285
|
}
|
|
286
|
+
spring.applyToOptions = (options) => {
|
|
287
|
+
const generatorOptions = motionDom.createGeneratorEasing(options, 100, spring);
|
|
288
|
+
options.ease = motionDom.supportsLinearEasing() ? generatorOptions.ease : "easeOut";
|
|
289
|
+
options.duration = motionUtils.secondsToMilliseconds(generatorOptions.duration);
|
|
290
|
+
options.type = "keyframes";
|
|
291
|
+
return options;
|
|
292
|
+
};
|
|
285
293
|
|
|
286
294
|
const wrap = (min, max, v) => {
|
|
287
295
|
const rangeSize = max - min;
|
|
@@ -365,7 +373,6 @@ function calculateRepeatDuration(duration, repeat, _repeatDelay) {
|
|
|
365
373
|
* calculate an absolute time for the next keyframes.
|
|
366
374
|
*/
|
|
367
375
|
function calcNextTime(current, next, prev, labels) {
|
|
368
|
-
var _a;
|
|
369
376
|
if (typeof next === "number") {
|
|
370
377
|
return next;
|
|
371
378
|
}
|
|
@@ -376,7 +383,7 @@ function calcNextTime(current, next, prev, labels) {
|
|
|
376
383
|
return prev;
|
|
377
384
|
}
|
|
378
385
|
else {
|
|
379
|
-
return
|
|
386
|
+
return labels.get(next) ?? current;
|
|
380
387
|
}
|
|
381
388
|
}
|
|
382
389
|
|
|
@@ -489,7 +496,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
489
496
|
const numKeyframes = valueKeyframesAsList.length;
|
|
490
497
|
const createGenerator = motionDom.isGenerator(type)
|
|
491
498
|
? type
|
|
492
|
-
: generators
|
|
499
|
+
: generators?.[type];
|
|
493
500
|
if (numKeyframes <= 2 && createGenerator) {
|
|
494
501
|
/**
|
|
495
502
|
* As we're creating an easing function from a spring,
|
|
@@ -511,7 +518,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
511
518
|
ease = springEasing.ease;
|
|
512
519
|
duration = springEasing.duration;
|
|
513
520
|
}
|
|
514
|
-
duration
|
|
521
|
+
duration ?? (duration = defaultDuration);
|
|
515
522
|
const startTime = currentTime + calculatedDelay;
|
|
516
523
|
/**
|
|
517
524
|
* If there's only one time offset of 0, fill in a second with length 1
|
|
@@ -720,7 +727,7 @@ const resolveFinalValueInKeyframes = (v) => {
|
|
|
720
727
|
|
|
721
728
|
function getValueState(visualElement) {
|
|
722
729
|
const state = [{}, {}];
|
|
723
|
-
visualElement
|
|
730
|
+
visualElement?.values.forEach((value, key) => {
|
|
724
731
|
state[0][key] = value.get();
|
|
725
732
|
state[1][key] = value.getVelocity();
|
|
726
733
|
});
|
|
@@ -1052,11 +1059,10 @@ const color = {
|
|
|
1052
1059
|
const colorRegex = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
|
|
1053
1060
|
|
|
1054
1061
|
function test(v) {
|
|
1055
|
-
var _a, _b;
|
|
1056
1062
|
return (isNaN(v) &&
|
|
1057
1063
|
typeof v === "string" &&
|
|
1058
|
-
(
|
|
1059
|
-
(
|
|
1064
|
+
(v.match(floatRegex)?.length || 0) +
|
|
1065
|
+
(v.match(colorRegex)?.length || 0) >
|
|
1060
1066
|
0);
|
|
1061
1067
|
}
|
|
1062
1068
|
const NUMBER_TOKEN = "number";
|
|
@@ -1444,8 +1450,7 @@ function measureAllKeyframes() {
|
|
|
1444
1450
|
const restore = transformsToRestore.get(element);
|
|
1445
1451
|
if (restore) {
|
|
1446
1452
|
restore.forEach(([key, value]) => {
|
|
1447
|
-
|
|
1448
|
-
(_a = element.getValue(key)) === null || _a === void 0 ? void 0 : _a.set(value);
|
|
1453
|
+
element.getValue(key)?.set(value);
|
|
1449
1454
|
});
|
|
1450
1455
|
}
|
|
1451
1456
|
});
|
|
@@ -1532,7 +1537,7 @@ class KeyframeResolver {
|
|
|
1532
1537
|
* If the first keyframe is null, we need to find its value by sampling the element
|
|
1533
1538
|
*/
|
|
1534
1539
|
if (i === 0) {
|
|
1535
|
-
const currentValue = motionValue
|
|
1540
|
+
const currentValue = motionValue?.get();
|
|
1536
1541
|
const finalKeyframe = unresolvedKeyframes[unresolvedKeyframes.length - 1];
|
|
1537
1542
|
if (currentValue !== undefined) {
|
|
1538
1543
|
unresolvedKeyframes[0] = currentValue;
|
|
@@ -1613,7 +1618,7 @@ function parseCSSVariable(current) {
|
|
|
1613
1618
|
if (!match)
|
|
1614
1619
|
return [,];
|
|
1615
1620
|
const [, token1, token2, fallback] = match;
|
|
1616
|
-
return [`--${token1
|
|
1621
|
+
return [`--${token1 ?? token2}`, fallback];
|
|
1617
1622
|
}
|
|
1618
1623
|
const maxDepth = 4;
|
|
1619
1624
|
function getVariableValue(current, element, depth = 1) {
|
|
@@ -1752,7 +1757,6 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
1752
1757
|
}
|
|
1753
1758
|
}
|
|
1754
1759
|
measureEndState() {
|
|
1755
|
-
var _a;
|
|
1756
1760
|
const { element, name, unresolvedKeyframes } = this;
|
|
1757
1761
|
if (!element || !element.current)
|
|
1758
1762
|
return;
|
|
@@ -1765,7 +1769,7 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
1765
1769
|
this.finalKeyframe = finalKeyframe;
|
|
1766
1770
|
}
|
|
1767
1771
|
// If we removed transform values, reapply them before the next render
|
|
1768
|
-
if (
|
|
1772
|
+
if (this.removedTransforms?.length) {
|
|
1769
1773
|
this.removedTransforms.forEach(([unsetTransformName, unsetTransformValue]) => {
|
|
1770
1774
|
element
|
|
1771
1775
|
.getValue(unsetTransformName)
|
|
@@ -2121,13 +2125,12 @@ function mixObject(a, b) {
|
|
|
2121
2125
|
};
|
|
2122
2126
|
}
|
|
2123
2127
|
function matchOrder(origin, target) {
|
|
2124
|
-
var _a;
|
|
2125
2128
|
const orderedOrigin = [];
|
|
2126
2129
|
const pointers = { color: 0, var: 0, number: 0 };
|
|
2127
2130
|
for (let i = 0; i < target.values.length; i++) {
|
|
2128
2131
|
const type = target.types[i];
|
|
2129
2132
|
const originIndex = origin.indexes[type][pointers[type]];
|
|
2130
|
-
const originValue =
|
|
2133
|
+
const originValue = origin.values[originIndex] ?? 0;
|
|
2131
2134
|
orderedOrigin[i] = originValue;
|
|
2132
2135
|
pointers[type]++;
|
|
2133
2136
|
}
|
|
@@ -2354,7 +2357,7 @@ function convertOffsetToTimes(offset, duration) {
|
|
|
2354
2357
|
return offset.map((o) => o * duration);
|
|
2355
2358
|
}
|
|
2356
2359
|
|
|
2357
|
-
function defaultEasing
|
|
2360
|
+
function defaultEasing(values, easing) {
|
|
2358
2361
|
return values.map(() => easing || easeInOut).splice(0, values.length - 1);
|
|
2359
2362
|
}
|
|
2360
2363
|
function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", }) {
|
|
@@ -2385,7 +2388,7 @@ function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "e
|
|
|
2385
2388
|
const mapTimeToKeyframe = interpolate(absoluteTimes, keyframeValues, {
|
|
2386
2389
|
ease: Array.isArray(easingFunctions)
|
|
2387
2390
|
? easingFunctions
|
|
2388
|
-
: defaultEasing
|
|
2391
|
+
: defaultEasing(keyframeValues, easingFunctions),
|
|
2389
2392
|
});
|
|
2390
2393
|
return {
|
|
2391
2394
|
calculatedDuration: duration,
|
|
@@ -2467,7 +2470,7 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
2467
2470
|
onStop && onStop();
|
|
2468
2471
|
};
|
|
2469
2472
|
const { name, motionValue, element, keyframes } = this.options;
|
|
2470
|
-
const KeyframeResolver$1 =
|
|
2473
|
+
const KeyframeResolver$1 = element?.KeyframeResolver || KeyframeResolver;
|
|
2471
2474
|
const onResolved = (resolvedKeyframes, finalKeyframe) => this.onKeyframesResolved(resolvedKeyframes, finalKeyframe);
|
|
2472
2475
|
this.resolver = new KeyframeResolver$1(keyframes, onResolved, name, motionValue, element);
|
|
2473
2476
|
this.resolver.scheduleResolve();
|
|
@@ -2717,7 +2720,7 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
2717
2720
|
this.startTime = now - this.holdTime;
|
|
2718
2721
|
}
|
|
2719
2722
|
else if (!this.startTime) {
|
|
2720
|
-
this.startTime = startTime
|
|
2723
|
+
this.startTime = startTime ?? this.calcStartTime();
|
|
2721
2724
|
}
|
|
2722
2725
|
else if (this.state === "finished") {
|
|
2723
2726
|
this.startTime = now;
|
|
@@ -2735,13 +2738,12 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
2735
2738
|
this.driver.start();
|
|
2736
2739
|
}
|
|
2737
2740
|
pause() {
|
|
2738
|
-
var _a;
|
|
2739
2741
|
if (!this._resolved) {
|
|
2740
2742
|
this.pendingPlayState = "paused";
|
|
2741
2743
|
return;
|
|
2742
2744
|
}
|
|
2743
2745
|
this.state = "paused";
|
|
2744
|
-
this.holdTime =
|
|
2746
|
+
this.holdTime = this.currentTime ?? 0;
|
|
2745
2747
|
}
|
|
2746
2748
|
complete() {
|
|
2747
2749
|
if (this.state !== "running") {
|
|
@@ -2782,6 +2784,9 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
2782
2784
|
this.startTime = 0;
|
|
2783
2785
|
return this.tick(time, true);
|
|
2784
2786
|
}
|
|
2787
|
+
get finished() {
|
|
2788
|
+
return this.currentFinishedPromise;
|
|
2789
|
+
}
|
|
2785
2790
|
}
|
|
2786
2791
|
|
|
2787
2792
|
/**
|
|
@@ -2797,35 +2802,6 @@ const acceleratedValues = new Set([
|
|
|
2797
2802
|
// "background-color"
|
|
2798
2803
|
]);
|
|
2799
2804
|
|
|
2800
|
-
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
|
|
2801
|
-
const keyframeOptions = { [valueName]: keyframes };
|
|
2802
|
-
if (times)
|
|
2803
|
-
keyframeOptions.offset = times;
|
|
2804
|
-
const easing = motionDom.mapEasingToNativeEasing(ease, duration);
|
|
2805
|
-
/**
|
|
2806
|
-
* If this is an easing array, apply to keyframes, not animation as a whole
|
|
2807
|
-
*/
|
|
2808
|
-
if (Array.isArray(easing))
|
|
2809
|
-
keyframeOptions.easing = easing;
|
|
2810
|
-
if (motionDom.statsBuffer.value) {
|
|
2811
|
-
motionDom.activeAnimations.waapi++;
|
|
2812
|
-
}
|
|
2813
|
-
const animation = element.animate(keyframeOptions, {
|
|
2814
|
-
delay,
|
|
2815
|
-
duration,
|
|
2816
|
-
easing: !Array.isArray(easing) ? easing : "linear",
|
|
2817
|
-
fill: "both",
|
|
2818
|
-
iterations: repeat + 1,
|
|
2819
|
-
direction: repeatType === "reverse" ? "alternate" : "normal",
|
|
2820
|
-
});
|
|
2821
|
-
if (motionDom.statsBuffer.value) {
|
|
2822
|
-
animation.finished.finally(() => {
|
|
2823
|
-
motionDom.activeAnimations.waapi--;
|
|
2824
|
-
});
|
|
2825
|
-
}
|
|
2826
|
-
return animation;
|
|
2827
|
-
}
|
|
2828
|
-
|
|
2829
2805
|
const supportsWaapi = /*@__PURE__*/ motionUtils.memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
|
|
2830
2806
|
|
|
2831
2807
|
/**
|
|
@@ -2933,10 +2909,10 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
2933
2909
|
ease = pregeneratedAnimation.ease;
|
|
2934
2910
|
type = "keyframes";
|
|
2935
2911
|
}
|
|
2936
|
-
const animation = startWaapiAnimation(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
|
|
2912
|
+
const animation = motionDom.startWaapiAnimation(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
|
|
2937
2913
|
// Override the browser calculated startTime with one synchronised to other JS
|
|
2938
2914
|
// and WAAPI animations starting this event loop.
|
|
2939
|
-
animation.startTime = startTime
|
|
2915
|
+
animation.startTime = startTime ?? this.calcStartTime();
|
|
2940
2916
|
if (this.pendingTimeline) {
|
|
2941
2917
|
motionDom.attachTimeline(animation, this.pendingTimeline);
|
|
2942
2918
|
this.pendingTimeline = undefined;
|
|
@@ -2995,6 +2971,9 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
2995
2971
|
const { animation } = resolved;
|
|
2996
2972
|
return animation.playbackRate;
|
|
2997
2973
|
}
|
|
2974
|
+
get finished() {
|
|
2975
|
+
return this.resolved.animation.finished;
|
|
2976
|
+
}
|
|
2998
2977
|
set speed(newSpeed) {
|
|
2999
2978
|
const { resolved } = this;
|
|
3000
2979
|
if (!resolved)
|
|
@@ -3265,7 +3244,7 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
3265
3244
|
});
|
|
3266
3245
|
// We still want to return some animation controls here rather
|
|
3267
3246
|
// than returning undefined
|
|
3268
|
-
return new motionDom.
|
|
3247
|
+
return new motionDom.GroupAnimationWithThen([]);
|
|
3269
3248
|
}
|
|
3270
3249
|
}
|
|
3271
3250
|
/**
|
|
@@ -3293,7 +3272,6 @@ function shouldBlockAnimation({ protectedKeys, needsAnimating }, key) {
|
|
|
3293
3272
|
return shouldBlock;
|
|
3294
3273
|
}
|
|
3295
3274
|
function animateTarget(visualElement, targetAndTransition, { delay = 0, transitionOverride, type } = {}) {
|
|
3296
|
-
var _a;
|
|
3297
3275
|
let { transition = visualElement.getDefaultTransition(), transitionEnd, ...target } = targetAndTransition;
|
|
3298
3276
|
if (transitionOverride)
|
|
3299
3277
|
transition = transitionOverride;
|
|
@@ -3302,7 +3280,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
|
|
|
3302
3280
|
visualElement.animationState &&
|
|
3303
3281
|
visualElement.animationState.getState()[type];
|
|
3304
3282
|
for (const key in target) {
|
|
3305
|
-
const value = visualElement.getValue(key,
|
|
3283
|
+
const value = visualElement.getValue(key, visualElement.latestValues[key] ?? null);
|
|
3306
3284
|
const valueTarget = target[key];
|
|
3307
3285
|
if (valueTarget === undefined ||
|
|
3308
3286
|
(animationTypeState &&
|
|
@@ -3461,7 +3439,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
3461
3439
|
* and warn against mismatches.
|
|
3462
3440
|
*/
|
|
3463
3441
|
if (process.env.NODE_ENV === "development") {
|
|
3464
|
-
motionUtils.warnOnce(nextValue.version === "12.6.
|
|
3442
|
+
motionUtils.warnOnce(nextValue.version === "12.6.3", `Attempting to mix Motion versions ${nextValue.version} with 12.6.3 may not work as expected.`);
|
|
3465
3443
|
}
|
|
3466
3444
|
}
|
|
3467
3445
|
else if (isMotionValue(prevValue)) {
|
|
@@ -3885,10 +3863,10 @@ class VisualElement {
|
|
|
3885
3863
|
* directly from the instance (which might have performance implications).
|
|
3886
3864
|
*/
|
|
3887
3865
|
readValue(key, target) {
|
|
3888
|
-
var _a;
|
|
3889
3866
|
let value = this.latestValues[key] !== undefined || !this.current
|
|
3890
3867
|
? this.latestValues[key]
|
|
3891
|
-
:
|
|
3868
|
+
: this.getBaseTargetFromProps(this.props, key) ??
|
|
3869
|
+
this.readValueFromInstance(this.current, key, this.options);
|
|
3892
3870
|
if (value !== undefined && value !== null) {
|
|
3893
3871
|
if (typeof value === "string" &&
|
|
3894
3872
|
(isNumericalString(value) || isZeroValueString(value))) {
|
|
@@ -3914,11 +3892,10 @@ class VisualElement {
|
|
|
3914
3892
|
* props.
|
|
3915
3893
|
*/
|
|
3916
3894
|
getBaseTarget(key) {
|
|
3917
|
-
var _a;
|
|
3918
3895
|
const { initial } = this.props;
|
|
3919
3896
|
let valueFromInitial;
|
|
3920
3897
|
if (typeof initial === "string" || typeof initial === "object") {
|
|
3921
|
-
const variant = resolveVariantFromProps(this.props, initial,
|
|
3898
|
+
const variant = resolveVariantFromProps(this.props, initial, this.presenceContext?.custom);
|
|
3922
3899
|
if (variant) {
|
|
3923
3900
|
valueFromInitial = variant[key];
|
|
3924
3901
|
}
|
|
@@ -4285,7 +4262,6 @@ function isForcedMotionValue(key, { layout, layoutId }) {
|
|
|
4285
4262
|
}
|
|
4286
4263
|
|
|
4287
4264
|
function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
|
|
4288
|
-
var _a;
|
|
4289
4265
|
const { style } = props;
|
|
4290
4266
|
const newValues = {};
|
|
4291
4267
|
for (const key in style) {
|
|
@@ -4293,7 +4269,7 @@ function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
|
|
|
4293
4269
|
(prevProps.style &&
|
|
4294
4270
|
isMotionValue(prevProps.style[key])) ||
|
|
4295
4271
|
isForcedMotionValue(key, props) ||
|
|
4296
|
-
|
|
4272
|
+
visualElement?.getValue(key)?.liveStyle !== undefined) {
|
|
4297
4273
|
newValues[key] = style[key];
|
|
4298
4274
|
}
|
|
4299
4275
|
}
|
|
@@ -4572,7 +4548,7 @@ function createScopedAnimate(scope) {
|
|
|
4572
4548
|
else {
|
|
4573
4549
|
animations = animateSubject(subjectOrSequence, optionsOrKeyframes, options, scope);
|
|
4574
4550
|
}
|
|
4575
|
-
const animation = new motionDom.
|
|
4551
|
+
const animation = new motionDom.GroupAnimationWithThen(animations);
|
|
4576
4552
|
if (scope) {
|
|
4577
4553
|
scope.animations.push(animation);
|
|
4578
4554
|
}
|
|
@@ -4582,125 +4558,6 @@ function createScopedAnimate(scope) {
|
|
|
4582
4558
|
}
|
|
4583
4559
|
const animate = createScopedAnimate();
|
|
4584
4560
|
|
|
4585
|
-
function setCSSVar(element, name, value) {
|
|
4586
|
-
element.style.setProperty(name, value);
|
|
4587
|
-
}
|
|
4588
|
-
function setStyle(element, name, value) {
|
|
4589
|
-
element.style[name] = value;
|
|
4590
|
-
}
|
|
4591
|
-
|
|
4592
|
-
const supportsPartialKeyframes = /*@__PURE__*/ motionUtils.memo(() => {
|
|
4593
|
-
try {
|
|
4594
|
-
document.createElement("div").animate({ opacity: [1] });
|
|
4595
|
-
}
|
|
4596
|
-
catch (e) {
|
|
4597
|
-
return false;
|
|
4598
|
-
}
|
|
4599
|
-
return true;
|
|
4600
|
-
});
|
|
4601
|
-
|
|
4602
|
-
const state = new WeakMap();
|
|
4603
|
-
function hydrateKeyframes(valueName, keyframes, read) {
|
|
4604
|
-
for (let i = 0; i < keyframes.length; i++) {
|
|
4605
|
-
if (keyframes[i] === null) {
|
|
4606
|
-
keyframes[i] = i === 0 ? read() : keyframes[i - 1];
|
|
4607
|
-
}
|
|
4608
|
-
if (typeof keyframes[i] === "number" &&
|
|
4609
|
-
browserNumberValueTypes[valueName]) {
|
|
4610
|
-
keyframes[i] = browserNumberValueTypes[valueName].transform(keyframes[i]);
|
|
4611
|
-
}
|
|
4612
|
-
}
|
|
4613
|
-
if (!supportsPartialKeyframes() && keyframes.length < 2) {
|
|
4614
|
-
keyframes.unshift(read());
|
|
4615
|
-
}
|
|
4616
|
-
}
|
|
4617
|
-
const defaultEasing = "easeOut";
|
|
4618
|
-
function getElementAnimationState(element) {
|
|
4619
|
-
const animationState = state.get(element) || new Map();
|
|
4620
|
-
state.set(element, animationState);
|
|
4621
|
-
return state.get(element);
|
|
4622
|
-
}
|
|
4623
|
-
class NativeAnimation extends motionDom.NativeAnimationControls {
|
|
4624
|
-
constructor(element, valueName, valueKeyframes, options) {
|
|
4625
|
-
const isCSSVar = valueName.startsWith("--");
|
|
4626
|
-
motionUtils.invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "framer-motion"?`);
|
|
4627
|
-
const existingAnimation = getElementAnimationState(element).get(valueName);
|
|
4628
|
-
existingAnimation && existingAnimation.stop();
|
|
4629
|
-
const readInitialKeyframe = () => {
|
|
4630
|
-
return valueName.startsWith("--")
|
|
4631
|
-
? element.style.getPropertyValue(valueName)
|
|
4632
|
-
: window.getComputedStyle(element)[valueName];
|
|
4633
|
-
};
|
|
4634
|
-
if (!Array.isArray(valueKeyframes)) {
|
|
4635
|
-
valueKeyframes = [valueKeyframes];
|
|
4636
|
-
}
|
|
4637
|
-
hydrateKeyframes(valueName, valueKeyframes, readInitialKeyframe);
|
|
4638
|
-
// TODO: Replace this with toString()?
|
|
4639
|
-
if (motionDom.isGenerator(options.type)) {
|
|
4640
|
-
const generatorOptions = motionDom.createGeneratorEasing(options, 100, options.type);
|
|
4641
|
-
options.ease = motionDom.supportsLinearEasing()
|
|
4642
|
-
? generatorOptions.ease
|
|
4643
|
-
: defaultEasing;
|
|
4644
|
-
options.duration = motionUtils.secondsToMilliseconds(generatorOptions.duration);
|
|
4645
|
-
options.type = "keyframes";
|
|
4646
|
-
}
|
|
4647
|
-
else {
|
|
4648
|
-
options.ease = options.ease || defaultEasing;
|
|
4649
|
-
}
|
|
4650
|
-
const onFinish = () => {
|
|
4651
|
-
this.setValue(element, valueName, getFinalKeyframe(valueKeyframes, options));
|
|
4652
|
-
this.cancel();
|
|
4653
|
-
this.resolveFinishedPromise();
|
|
4654
|
-
};
|
|
4655
|
-
const init = () => {
|
|
4656
|
-
this.setValue = isCSSVar ? setCSSVar : setStyle;
|
|
4657
|
-
this.options = options;
|
|
4658
|
-
this.updateFinishedPromise();
|
|
4659
|
-
this.removeAnimation = () => {
|
|
4660
|
-
const elementState = state.get(element);
|
|
4661
|
-
elementState && elementState.delete(valueName);
|
|
4662
|
-
};
|
|
4663
|
-
};
|
|
4664
|
-
if (!supportsWaapi()) {
|
|
4665
|
-
super();
|
|
4666
|
-
init();
|
|
4667
|
-
onFinish();
|
|
4668
|
-
}
|
|
4669
|
-
else {
|
|
4670
|
-
super(startWaapiAnimation(element, valueName, valueKeyframes, options));
|
|
4671
|
-
init();
|
|
4672
|
-
if (options.autoplay === false) {
|
|
4673
|
-
this.animation.pause();
|
|
4674
|
-
}
|
|
4675
|
-
this.animation.onfinish = onFinish;
|
|
4676
|
-
getElementAnimationState(element).set(valueName, this);
|
|
4677
|
-
}
|
|
4678
|
-
}
|
|
4679
|
-
/**
|
|
4680
|
-
* Allows the returned animation to be awaited or promise-chained. Currently
|
|
4681
|
-
* resolves when the animation finishes at all but in a future update could/should
|
|
4682
|
-
* reject if its cancels.
|
|
4683
|
-
*/
|
|
4684
|
-
then(resolve, reject) {
|
|
4685
|
-
return this.currentFinishedPromise.then(resolve, reject);
|
|
4686
|
-
}
|
|
4687
|
-
updateFinishedPromise() {
|
|
4688
|
-
this.currentFinishedPromise = new Promise((resolve) => {
|
|
4689
|
-
this.resolveFinishedPromise = resolve;
|
|
4690
|
-
});
|
|
4691
|
-
}
|
|
4692
|
-
play() {
|
|
4693
|
-
if (this.state === "finished") {
|
|
4694
|
-
this.updateFinishedPromise();
|
|
4695
|
-
}
|
|
4696
|
-
super.play();
|
|
4697
|
-
}
|
|
4698
|
-
cancel() {
|
|
4699
|
-
this.removeAnimation();
|
|
4700
|
-
super.cancel();
|
|
4701
|
-
}
|
|
4702
|
-
}
|
|
4703
|
-
|
|
4704
4561
|
function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
4705
4562
|
const elements = motionDom.resolveElements(elementOrSelector, scope);
|
|
4706
4563
|
const numElements = elements.length;
|
|
@@ -4720,13 +4577,15 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
4720
4577
|
const valueOptions = {
|
|
4721
4578
|
...motionDom.getValueTransition(elementTransition, valueName),
|
|
4722
4579
|
};
|
|
4723
|
-
valueOptions.duration = valueOptions.duration
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4580
|
+
valueOptions.duration && (valueOptions.duration = motionUtils.secondsToMilliseconds(valueOptions.duration));
|
|
4581
|
+
valueOptions.delay && (valueOptions.delay = motionUtils.secondsToMilliseconds(valueOptions.delay));
|
|
4582
|
+
animations.push(new motionDom.NativeAnimation({
|
|
4583
|
+
element,
|
|
4584
|
+
name: valueName,
|
|
4585
|
+
keyframes: valueKeyframes,
|
|
4586
|
+
transition: valueOptions,
|
|
4587
|
+
allowFlatten: !elementTransition.type && !elementTransition.ease,
|
|
4588
|
+
}));
|
|
4730
4589
|
}
|
|
4731
4590
|
}
|
|
4732
4591
|
return animations;
|
|
@@ -4734,7 +4593,7 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
4734
4593
|
|
|
4735
4594
|
const createScopedWaapiAnimate = (scope) => {
|
|
4736
4595
|
function scopedAnimate(elementOrSelector, keyframes, options) {
|
|
4737
|
-
return new motionDom.
|
|
4596
|
+
return new motionDom.GroupAnimationWithThen(animateElements(elementOrSelector, keyframes, options, scope));
|
|
4738
4597
|
}
|
|
4739
4598
|
return scopedAnimate;
|
|
4740
4599
|
};
|
|
@@ -4773,8 +4632,7 @@ function getElementSize(target, borderBoxSize) {
|
|
|
4773
4632
|
}
|
|
4774
4633
|
}
|
|
4775
4634
|
function notifyTarget({ target, contentRect, borderBoxSize, }) {
|
|
4776
|
-
|
|
4777
|
-
(_a = resizeHandlers.get(target)) === null || _a === void 0 ? void 0 : _a.forEach((handler) => {
|
|
4635
|
+
resizeHandlers.get(target)?.forEach((handler) => {
|
|
4778
4636
|
handler({
|
|
4779
4637
|
target,
|
|
4780
4638
|
contentSize: contentRect,
|
|
@@ -4803,14 +4661,14 @@ function resizeElement(target, handler) {
|
|
|
4803
4661
|
resizeHandlers.set(element, elementHandlers);
|
|
4804
4662
|
}
|
|
4805
4663
|
elementHandlers.add(handler);
|
|
4806
|
-
observer
|
|
4664
|
+
observer?.observe(element);
|
|
4807
4665
|
});
|
|
4808
4666
|
return () => {
|
|
4809
4667
|
elements.forEach((element) => {
|
|
4810
4668
|
const elementHandlers = resizeHandlers.get(element);
|
|
4811
|
-
elementHandlers
|
|
4812
|
-
if (!
|
|
4813
|
-
observer
|
|
4669
|
+
elementHandlers?.delete(handler);
|
|
4670
|
+
if (!elementHandlers?.size) {
|
|
4671
|
+
observer?.unobserve(element);
|
|
4814
4672
|
}
|
|
4815
4673
|
});
|
|
4816
4674
|
};
|
|
@@ -5189,7 +5047,6 @@ function scrollInfo(onScroll, { container = document.documentElement, ...options
|
|
|
5189
5047
|
const listener = scrollListeners.get(container);
|
|
5190
5048
|
motionDom.frame.read(listener, false, true);
|
|
5191
5049
|
return () => {
|
|
5192
|
-
var _a;
|
|
5193
5050
|
motionDom.cancelFrame(listener);
|
|
5194
5051
|
/**
|
|
5195
5052
|
* Check if we even have any handlers for this container.
|
|
@@ -5207,7 +5064,7 @@ function scrollInfo(onScroll, { container = document.documentElement, ...options
|
|
|
5207
5064
|
scrollListeners.delete(container);
|
|
5208
5065
|
if (scrollListener) {
|
|
5209
5066
|
getEventTarget(container).removeEventListener("scroll", scrollListener);
|
|
5210
|
-
|
|
5067
|
+
resizeListeners.get(container)?.();
|
|
5211
5068
|
window.removeEventListener("resize", scrollListener);
|
|
5212
5069
|
}
|
|
5213
5070
|
};
|