framer-motion 11.8.0 → 11.10.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/{client-entry.js → client.js} +97 -132
- package/dist/cjs/dom-mini.js +553 -0
- package/dist/cjs/{dom-entry.js → dom.js} +365 -154
- package/dist/cjs/index.js +407 -176
- package/dist/cjs/{m-entry.js → m.js} +27 -40
- package/dist/cjs/mini.js +585 -0
- package/dist/{client-entry.d.ts → client.d.ts} +1 -1
- package/dist/dom-mini.d.ts +453 -0
- package/dist/dom-mini.js +1 -0
- package/dist/{dom-entry.d.ts → dom.d.ts} +38 -33
- package/dist/dom.js +1 -1
- package/dist/es/animation/GroupPlaybackControls.mjs +6 -11
- package/dist/es/animation/animate.mjs +2 -1
- package/dist/es/animation/animators/AcceleratedAnimation.mjs +8 -8
- package/dist/es/animation/animators/waapi/NativeAnimation.mjs +169 -0
- package/dist/es/animation/animators/waapi/animate-elements.mjs +36 -0
- package/dist/es/animation/animators/waapi/animate-style.mjs +12 -0
- package/dist/es/animation/animators/waapi/easing.mjs +2 -13
- package/dist/es/animation/animators/waapi/index.mjs +2 -2
- package/dist/es/animation/animators/waapi/utils/attach-timeline.mjs +6 -0
- package/dist/es/animation/animators/waapi/utils/style.mjs +8 -0
- package/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs +15 -0
- package/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +13 -0
- package/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +5 -0
- package/dist/es/animation/hooks/use-animate-style.mjs +17 -0
- package/dist/es/animation/interfaces/motion-value.mjs +2 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +1 -1
- package/dist/es/animation/optimized-appear/start.mjs +3 -3
- package/dist/es/animation/sequence/create.mjs +6 -3
- package/dist/es/animation/utils/get-value-transition.mjs +7 -0
- package/dist/es/animation/utils/{transitions.mjs → is-transition-defined.mjs} +1 -6
- package/dist/es/dom-mini.mjs +1 -0
- package/dist/es/{dom-entry.mjs → dom.mjs} +5 -1
- package/dist/es/easing/utils/create-generator-easing.mjs +2 -3
- package/dist/es/index.mjs +5 -1
- package/dist/es/mini.mjs +1 -0
- package/dist/es/motion/utils/use-visual-state.mjs +6 -13
- package/dist/es/projection/node/create-projection-node.mjs +1 -1
- package/dist/es/render/dom/scroll/index.mjs +38 -31
- package/dist/es/render/dom/utils/is-css-variable.mjs +4 -2
- package/dist/es/render/dom/value-types/number-browser.mjs +41 -0
- package/dist/es/render/dom/value-types/number.mjs +7 -63
- package/dist/es/render/dom/value-types/transform.mjs +31 -0
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/utils/delay.mjs +5 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/es/value/types/color/hsla.mjs +1 -1
- package/dist/es/value/types/color/index.mjs +1 -2
- package/dist/es/value/types/color/rgba.mjs +1 -1
- package/dist/es/value/types/color/utils.mjs +7 -3
- package/dist/es/value/types/complex/filter.mjs +1 -1
- package/dist/es/value/types/complex/index.mjs +4 -2
- package/dist/es/value/types/numbers/units.mjs +1 -3
- package/dist/es/value/types/utils/color-regex.mjs +3 -0
- package/dist/es/value/types/utils/float-regex.mjs +3 -0
- package/dist/es/value/types/utils/is-nullish.mjs +5 -0
- package/dist/es/value/types/utils/sanitize.mjs +5 -0
- package/dist/es/value/types/utils/single-color-regex.mjs +3 -0
- package/dist/es/value/use-will-change/add-will-change.mjs +6 -14
- package/dist/framer-motion.dev.js +407 -176
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +37 -29
- package/dist/{m-entry.d.ts → m.d.ts} +1 -1
- package/dist/mini.d.ts +457 -0
- package/dist/mini.js +1 -0
- package/dist/{three-entry.d.ts → three.d.ts} +1 -1
- package/dom/package.json +3 -3
- package/package.json +35 -19
- package/dist/es/value/types/utils.mjs +0 -18
- /package/dist/es/{client-entry.mjs → client.mjs} +0 -0
- /package/dist/es/{m-entry.mjs → m.mjs} +0 -0
- /package/dist/es/{projection-entry.mjs → projection.mjs} +0 -0
|
@@ -159,14 +159,6 @@ const getDefaultTransition = (valueKey, { keyframes }) => {
|
|
|
159
159
|
return ease;
|
|
160
160
|
};
|
|
161
161
|
|
|
162
|
-
/**
|
|
163
|
-
* Decide whether a transition is defined on a given Transition.
|
|
164
|
-
* This filters out orchestration options and returns true
|
|
165
|
-
* if any options are left.
|
|
166
|
-
*/
|
|
167
|
-
function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
|
|
168
|
-
return !!Object.keys(transition).length;
|
|
169
|
-
}
|
|
170
162
|
function getValueTransition(transition, key) {
|
|
171
163
|
return (transition[key] ||
|
|
172
164
|
transition["default"] ||
|
|
@@ -444,8 +436,10 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
444
436
|
const isNumericalString = (v) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(v);
|
|
445
437
|
|
|
446
438
|
const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
|
|
447
|
-
const isCSSVariableName =
|
|
448
|
-
|
|
439
|
+
const isCSSVariableName =
|
|
440
|
+
/*@__PURE__*/ checkStringStartsWith("--");
|
|
441
|
+
const startsAsVariableToken =
|
|
442
|
+
/*@__PURE__*/ checkStringStartsWith("var(--");
|
|
449
443
|
const isCSSVariableToken = (value) => {
|
|
450
444
|
const startsWithToken = startsAsVariableToken(value);
|
|
451
445
|
if (!startsWithToken)
|
|
@@ -514,25 +508,8 @@ const scale = {
|
|
|
514
508
|
default: 1,
|
|
515
509
|
};
|
|
516
510
|
|
|
517
|
-
/**
|
|
518
|
-
* TODO: When we move from string as a source of truth to data models
|
|
519
|
-
* everything in this folder should probably be referred to as models vs types
|
|
520
|
-
*/
|
|
521
|
-
// If this number is a decimal, make it just five decimal places
|
|
522
|
-
// to avoid exponents
|
|
523
|
-
const sanitize = (v) => Math.round(v * 100000) / 100000;
|
|
524
|
-
const floatRegex = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
|
|
525
|
-
const colorRegex = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
|
|
526
|
-
const singleColorRegex = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu;
|
|
527
|
-
function isString(v) {
|
|
528
|
-
return typeof v === "string";
|
|
529
|
-
}
|
|
530
|
-
function isNullish(v) {
|
|
531
|
-
return v == null;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
511
|
const createUnitType = (unit) => ({
|
|
535
|
-
test: (v) =>
|
|
512
|
+
test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
|
|
536
513
|
parse: parseFloat,
|
|
537
514
|
transform: (v) => `${v}${unit}`,
|
|
538
515
|
});
|
|
@@ -789,18 +766,32 @@ class KeyframeResolver {
|
|
|
789
766
|
}
|
|
790
767
|
}
|
|
791
768
|
|
|
769
|
+
// If this number is a decimal, make it just five decimal places
|
|
770
|
+
// to avoid exponents
|
|
771
|
+
const sanitize = (v) => Math.round(v * 100000) / 100000;
|
|
772
|
+
|
|
773
|
+
const floatRegex = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu;
|
|
774
|
+
|
|
775
|
+
function isNullish(v) {
|
|
776
|
+
return v == null;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
const singleColorRegex = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu;
|
|
780
|
+
|
|
792
781
|
/**
|
|
793
782
|
* Returns true if the provided string is a color, ie rgba(0,0,0,0) or #000,
|
|
794
783
|
* but false if a number or multiple colors
|
|
795
784
|
*/
|
|
796
785
|
const isColorString = (type, testProp) => (v) => {
|
|
797
|
-
return Boolean((
|
|
786
|
+
return Boolean((typeof v === "string" &&
|
|
787
|
+
singleColorRegex.test(v) &&
|
|
788
|
+
v.startsWith(type)) ||
|
|
798
789
|
(testProp &&
|
|
799
790
|
!isNullish(v) &&
|
|
800
791
|
Object.prototype.hasOwnProperty.call(v, testProp)));
|
|
801
792
|
};
|
|
802
793
|
const splitColor = (aName, bName, cName) => (v) => {
|
|
803
|
-
if (
|
|
794
|
+
if (typeof v !== "string")
|
|
804
795
|
return v;
|
|
805
796
|
const [a, b, c, alpha] = v.match(floatRegex);
|
|
806
797
|
return {
|
|
@@ -896,7 +887,7 @@ const color = {
|
|
|
896
887
|
}
|
|
897
888
|
},
|
|
898
889
|
transform: (v) => {
|
|
899
|
-
return
|
|
890
|
+
return typeof v === "string"
|
|
900
891
|
? v
|
|
901
892
|
: v.hasOwnProperty("red")
|
|
902
893
|
? rgba.transform(v)
|
|
@@ -904,10 +895,12 @@ const color = {
|
|
|
904
895
|
},
|
|
905
896
|
};
|
|
906
897
|
|
|
898
|
+
const colorRegex = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;
|
|
899
|
+
|
|
907
900
|
function test(v) {
|
|
908
901
|
var _a, _b;
|
|
909
902
|
return (isNaN(v) &&
|
|
910
|
-
|
|
903
|
+
typeof v === "string" &&
|
|
911
904
|
(((_a = v.match(floatRegex)) === null || _a === void 0 ? void 0 : _a.length) || 0) +
|
|
912
905
|
(((_b = v.match(colorRegex)) === null || _b === void 0 ? void 0 : _b.length) || 0) >
|
|
913
906
|
0);
|
|
@@ -1016,12 +1009,7 @@ const filter = {
|
|
|
1016
1009
|
},
|
|
1017
1010
|
};
|
|
1018
1011
|
|
|
1019
|
-
const
|
|
1020
|
-
...number,
|
|
1021
|
-
transform: Math.round,
|
|
1022
|
-
};
|
|
1023
|
-
|
|
1024
|
-
const numberValueTypes = {
|
|
1012
|
+
const browserNumberValueTypes = {
|
|
1025
1013
|
// Border props
|
|
1026
1014
|
borderWidth: px,
|
|
1027
1015
|
borderTopWidth: px,
|
|
@@ -1039,7 +1027,6 @@ const numberValueTypes = {
|
|
|
1039
1027
|
maxWidth: px,
|
|
1040
1028
|
height: px,
|
|
1041
1029
|
maxHeight: px,
|
|
1042
|
-
size: px,
|
|
1043
1030
|
top: px,
|
|
1044
1031
|
right: px,
|
|
1045
1032
|
bottom: px,
|
|
@@ -1055,7 +1042,12 @@ const numberValueTypes = {
|
|
|
1055
1042
|
marginRight: px,
|
|
1056
1043
|
marginBottom: px,
|
|
1057
1044
|
marginLeft: px,
|
|
1058
|
-
//
|
|
1045
|
+
// Misc
|
|
1046
|
+
backgroundPositionX: px,
|
|
1047
|
+
backgroundPositionY: px,
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
const transformValueTypes = {
|
|
1059
1051
|
rotate: degrees,
|
|
1060
1052
|
rotateX: degrees,
|
|
1061
1053
|
rotateY: degrees,
|
|
@@ -1080,10 +1072,18 @@ const numberValueTypes = {
|
|
|
1080
1072
|
originX: progressPercentage,
|
|
1081
1073
|
originY: progressPercentage,
|
|
1082
1074
|
originZ: px,
|
|
1083
|
-
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
const int = {
|
|
1078
|
+
...number,
|
|
1079
|
+
transform: Math.round,
|
|
1080
|
+
};
|
|
1081
|
+
|
|
1082
|
+
const numberValueTypes = {
|
|
1083
|
+
...browserNumberValueTypes,
|
|
1084
|
+
...transformValueTypes,
|
|
1084
1085
|
zIndex: int,
|
|
1085
|
-
|
|
1086
|
-
backgroundPositionY: px,
|
|
1086
|
+
size: px,
|
|
1087
1087
|
// SVG
|
|
1088
1088
|
fillOpacity: alpha,
|
|
1089
1089
|
strokeOpacity: alpha,
|
|
@@ -1272,15 +1272,6 @@ class DOMKeyframesResolver extends KeyframeResolver {
|
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
1274
|
|
|
1275
|
-
function memo(callback) {
|
|
1276
|
-
let result;
|
|
1277
|
-
return () => {
|
|
1278
|
-
if (result === undefined)
|
|
1279
|
-
result = callback();
|
|
1280
|
-
return result;
|
|
1281
|
-
};
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
1275
|
function isGenerator(type) {
|
|
1285
1276
|
return typeof type === "function";
|
|
1286
1277
|
}
|
|
@@ -2616,6 +2607,15 @@ const generateLinearEasing = (easing, duration // as milliseconds
|
|
|
2616
2607
|
return `linear(${points.substring(0, points.length - 2)})`;
|
|
2617
2608
|
};
|
|
2618
2609
|
|
|
2610
|
+
function memo(callback) {
|
|
2611
|
+
let result;
|
|
2612
|
+
return () => {
|
|
2613
|
+
if (result === undefined)
|
|
2614
|
+
result = callback();
|
|
2615
|
+
return result;
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
2619
|
/**
|
|
2620
2620
|
* Add the ability for test suites to manually set support flags
|
|
2621
2621
|
* to better test more environments.
|
|
@@ -2640,6 +2640,7 @@ const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
|
|
|
2640
2640
|
}
|
|
2641
2641
|
return true;
|
|
2642
2642
|
}, "linearEasing");
|
|
2643
|
+
|
|
2643
2644
|
function isWaapiSupportedEasing(easing) {
|
|
2644
2645
|
return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
|
|
2645
2646
|
!easing ||
|
|
@@ -2679,7 +2680,7 @@ function mapEasingToNativeEasing(easing, duration) {
|
|
|
2679
2680
|
}
|
|
2680
2681
|
}
|
|
2681
2682
|
|
|
2682
|
-
function
|
|
2683
|
+
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease, times, } = {}) {
|
|
2683
2684
|
const keyframeOptions = { [valueName]: keyframes };
|
|
2684
2685
|
if (times)
|
|
2685
2686
|
keyframeOptions.offset = times;
|
|
@@ -2699,7 +2700,13 @@ function animateStyle(element, valueName, keyframes, { delay = 0, duration = 300
|
|
|
2699
2700
|
});
|
|
2700
2701
|
}
|
|
2701
2702
|
|
|
2703
|
+
function attachTimeline(animation, timeline) {
|
|
2704
|
+
animation.timeline = timeline;
|
|
2705
|
+
animation.onfinish = null;
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2702
2708
|
const supportsWaapi = /*@__PURE__*/ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
|
|
2709
|
+
|
|
2703
2710
|
/**
|
|
2704
2711
|
* 10ms is chosen here as it strikes a balance between smooth
|
|
2705
2712
|
* results (more than one keyframe per frame at 60fps) and
|
|
@@ -2806,12 +2813,12 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
2806
2813
|
ease = pregeneratedAnimation.ease;
|
|
2807
2814
|
type = "keyframes";
|
|
2808
2815
|
}
|
|
2809
|
-
const animation =
|
|
2816
|
+
const animation = startWaapiAnimation(motionValue.owner.current, name, keyframes, { ...this.options, duration, times, ease });
|
|
2810
2817
|
// Override the browser calculated startTime with one synchronised to other JS
|
|
2811
2818
|
// and WAAPI animations starting this event loop.
|
|
2812
2819
|
animation.startTime = startTime !== null && startTime !== void 0 ? startTime : this.calcStartTime();
|
|
2813
2820
|
if (this.pendingTimeline) {
|
|
2814
|
-
animation
|
|
2821
|
+
attachTimeline(animation, this.pendingTimeline);
|
|
2815
2822
|
this.pendingTimeline = undefined;
|
|
2816
2823
|
}
|
|
2817
2824
|
else {
|
|
@@ -2904,8 +2911,7 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
2904
2911
|
if (!resolved)
|
|
2905
2912
|
return noop;
|
|
2906
2913
|
const { animation } = resolved;
|
|
2907
|
-
animation
|
|
2908
|
-
animation.onfinish = null;
|
|
2914
|
+
attachTimeline(animation, timeline);
|
|
2909
2915
|
}
|
|
2910
2916
|
return noop;
|
|
2911
2917
|
}
|
|
@@ -3001,21 +3007,6 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
3001
3007
|
}
|
|
3002
3008
|
}
|
|
3003
3009
|
|
|
3004
|
-
function observeTimeline(update, timeline) {
|
|
3005
|
-
let prevProgress;
|
|
3006
|
-
const onFrame = () => {
|
|
3007
|
-
const { currentTime } = timeline;
|
|
3008
|
-
const percentage = currentTime === null ? 0 : currentTime.value;
|
|
3009
|
-
const progress = percentage / 100;
|
|
3010
|
-
if (prevProgress !== progress) {
|
|
3011
|
-
update(progress);
|
|
3012
|
-
}
|
|
3013
|
-
prevProgress = progress;
|
|
3014
|
-
};
|
|
3015
|
-
frame.update(onFrame, true);
|
|
3016
|
-
return () => cancelFrame(onFrame);
|
|
3017
|
-
}
|
|
3018
|
-
|
|
3019
3010
|
const supportsScrollTimeline = memo(() => window.ScrollTimeline !== undefined);
|
|
3020
3011
|
|
|
3021
3012
|
class GroupPlaybackControls {
|
|
@@ -3038,22 +3029,18 @@ class GroupPlaybackControls {
|
|
|
3038
3029
|
this.animations[i][propName] = newValue;
|
|
3039
3030
|
}
|
|
3040
3031
|
}
|
|
3041
|
-
attachTimeline(timeline) {
|
|
3042
|
-
const
|
|
3032
|
+
attachTimeline(timeline, fallback) {
|
|
3033
|
+
const subscriptions = this.animations.map((animation) => {
|
|
3043
3034
|
if (supportsScrollTimeline() && animation.attachTimeline) {
|
|
3044
|
-
animation.attachTimeline(timeline);
|
|
3035
|
+
return animation.attachTimeline(timeline);
|
|
3045
3036
|
}
|
|
3046
3037
|
else {
|
|
3047
|
-
animation
|
|
3048
|
-
return observeTimeline((progress) => {
|
|
3049
|
-
animation.time = animation.duration * progress;
|
|
3050
|
-
}, timeline);
|
|
3038
|
+
return fallback(animation);
|
|
3051
3039
|
}
|
|
3052
3040
|
});
|
|
3053
3041
|
return () => {
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
cancelTimeline();
|
|
3042
|
+
subscriptions.forEach((cancel, i) => {
|
|
3043
|
+
cancel && cancel();
|
|
3057
3044
|
this.animations[i].stop();
|
|
3058
3045
|
});
|
|
3059
3046
|
};
|
|
@@ -3097,6 +3084,15 @@ class GroupPlaybackControls {
|
|
|
3097
3084
|
}
|
|
3098
3085
|
}
|
|
3099
3086
|
|
|
3087
|
+
/**
|
|
3088
|
+
* Decide whether a transition is defined on a given Transition.
|
|
3089
|
+
* This filters out orchestration options and returns true
|
|
3090
|
+
* if any options are left.
|
|
3091
|
+
*/
|
|
3092
|
+
function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
|
|
3093
|
+
return !!Object.keys(transition).length;
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3100
3096
|
const animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
|
|
3101
3097
|
const valueTransition = getValueTransition(transition, name) || {};
|
|
3102
3098
|
/**
|
|
@@ -3283,7 +3279,7 @@ class MotionValue {
|
|
|
3283
3279
|
* This will be replaced by the build step with the latest version number.
|
|
3284
3280
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
3285
3281
|
*/
|
|
3286
|
-
this.version = "11.
|
|
3282
|
+
this.version = "11.10.0";
|
|
3287
3283
|
/**
|
|
3288
3284
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
3289
3285
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -3596,6 +3592,12 @@ function getOptimisedAppearId(visualElement) {
|
|
|
3596
3592
|
return visualElement.props[optimizedAppearDataAttribute];
|
|
3597
3593
|
}
|
|
3598
3594
|
|
|
3595
|
+
const isMotionValue = (value) => Boolean(value && value.getVelocity);
|
|
3596
|
+
|
|
3597
|
+
function isWillChangeMotionValue(value) {
|
|
3598
|
+
return Boolean(isMotionValue(value) && value.add);
|
|
3599
|
+
}
|
|
3600
|
+
|
|
3599
3601
|
function getWillChangeName(name) {
|
|
3600
3602
|
if (transformProps.has(name)) {
|
|
3601
3603
|
return "transform";
|
|
@@ -3605,49 +3607,18 @@ function getWillChangeName(name) {
|
|
|
3605
3607
|
}
|
|
3606
3608
|
}
|
|
3607
3609
|
|
|
3608
|
-
class WillChangeMotionValue extends MotionValue {
|
|
3609
|
-
constructor() {
|
|
3610
|
-
super(...arguments);
|
|
3611
|
-
this.values = [];
|
|
3612
|
-
}
|
|
3613
|
-
add(name) {
|
|
3614
|
-
const styleName = getWillChangeName(name);
|
|
3615
|
-
if (styleName) {
|
|
3616
|
-
addUniqueItem(this.values, styleName);
|
|
3617
|
-
this.update();
|
|
3618
|
-
}
|
|
3619
|
-
}
|
|
3620
|
-
update() {
|
|
3621
|
-
this.set(this.values.length ? this.values.join(", ") : "auto");
|
|
3622
|
-
}
|
|
3623
|
-
}
|
|
3624
|
-
|
|
3625
|
-
const isMotionValue = (value) => Boolean(value && value.getVelocity);
|
|
3626
|
-
|
|
3627
|
-
function isWillChangeMotionValue(value) {
|
|
3628
|
-
return Boolean(isMotionValue(value) && value.add);
|
|
3629
|
-
}
|
|
3630
|
-
|
|
3631
3610
|
function addValueToWillChange(visualElement, key) {
|
|
3632
3611
|
var _a;
|
|
3633
3612
|
if (!visualElement.applyWillChange)
|
|
3634
3613
|
return;
|
|
3635
|
-
|
|
3636
|
-
/**
|
|
3637
|
-
* If we haven't created a willChange MotionValue, and the we haven't been
|
|
3638
|
-
* manually provided one, create one.
|
|
3639
|
-
*/
|
|
3640
|
-
if (!willChange && !((_a = visualElement.props.style) === null || _a === void 0 ? void 0 : _a.willChange)) {
|
|
3641
|
-
willChange = new WillChangeMotionValue("auto");
|
|
3642
|
-
visualElement.addValue("willChange", willChange);
|
|
3643
|
-
}
|
|
3644
|
-
/**
|
|
3645
|
-
* It could be that a user has set willChange to a regular MotionValue,
|
|
3646
|
-
* in which case we can't add the value to it.
|
|
3647
|
-
*/
|
|
3614
|
+
const willChange = visualElement.getValue("willChange");
|
|
3648
3615
|
if (isWillChangeMotionValue(willChange)) {
|
|
3649
3616
|
return willChange.add(key);
|
|
3650
3617
|
}
|
|
3618
|
+
else if (!((_a = visualElement.props.style) === null || _a === void 0 ? void 0 : _a.willChange) &&
|
|
3619
|
+
getWillChangeName(key)) {
|
|
3620
|
+
visualElement.setStaticValue("willChange", "transform");
|
|
3621
|
+
}
|
|
3651
3622
|
}
|
|
3652
3623
|
|
|
3653
3624
|
/**
|
|
@@ -5906,7 +5877,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5906
5877
|
* and warn against mismatches.
|
|
5907
5878
|
*/
|
|
5908
5879
|
if (process.env.NODE_ENV === "development") {
|
|
5909
|
-
warnOnce(nextValue.version === "11.
|
|
5880
|
+
warnOnce(nextValue.version === "11.10.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.10.0 may not work as expected.`);
|
|
5910
5881
|
}
|
|
5911
5882
|
}
|
|
5912
5883
|
else if (isMotionValue(prevValue)) {
|
|
@@ -9350,12 +9321,6 @@ const makeUseVisualState = (config) => (props, isStatic) => {
|
|
|
9350
9321
|
const make = () => makeState(config, props, context, presenceContext, isStatic);
|
|
9351
9322
|
return isStatic ? make() : useConstant(make);
|
|
9352
9323
|
};
|
|
9353
|
-
function addWillChange(willChange, name) {
|
|
9354
|
-
const memberName = getWillChangeName(name);
|
|
9355
|
-
if (memberName) {
|
|
9356
|
-
addUniqueItem(willChange, memberName);
|
|
9357
|
-
}
|
|
9358
|
-
}
|
|
9359
9324
|
function forEachDefinition(props, definition, callback) {
|
|
9360
9325
|
const list = Array.isArray(definition) ? definition : [definition];
|
|
9361
9326
|
for (let i = 0; i < list.length; i++) {
|
|
@@ -9369,8 +9334,7 @@ function forEachDefinition(props, definition, callback) {
|
|
|
9369
9334
|
function makeLatestValues(props, context, presenceContext, shouldApplyWillChange, scrapeMotionValues) {
|
|
9370
9335
|
var _a;
|
|
9371
9336
|
const values = {};
|
|
9372
|
-
|
|
9373
|
-
const applyWillChange = shouldApplyWillChange && ((_a = props.style) === null || _a === void 0 ? void 0 : _a.willChange) === undefined;
|
|
9337
|
+
let applyWillChange = shouldApplyWillChange && ((_a = props.style) === null || _a === void 0 ? void 0 : _a.willChange) === undefined;
|
|
9374
9338
|
const motionValues = scrapeMotionValues(props, {});
|
|
9375
9339
|
for (const key in motionValues) {
|
|
9376
9340
|
values[key] = resolveMotionValue(motionValues[key]);
|
|
@@ -9422,13 +9386,14 @@ function makeLatestValues(props, context, presenceContext, shouldApplyWillChange
|
|
|
9422
9386
|
if (animate && initial !== false && !isAnimationControls(animate)) {
|
|
9423
9387
|
forEachDefinition(props, animate, (target) => {
|
|
9424
9388
|
for (const key in target) {
|
|
9425
|
-
|
|
9389
|
+
const willChangeName = getWillChangeName(key);
|
|
9390
|
+
if (willChangeName) {
|
|
9391
|
+
values.willChange = "transform";
|
|
9392
|
+
return;
|
|
9393
|
+
}
|
|
9426
9394
|
}
|
|
9427
9395
|
});
|
|
9428
9396
|
}
|
|
9429
|
-
if (willChange.length) {
|
|
9430
|
-
values.willChange = willChange.join(",");
|
|
9431
|
-
}
|
|
9432
9397
|
}
|
|
9433
9398
|
return values;
|
|
9434
9399
|
}
|