framer-motion 10.12.9 → 10.12.10
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/dom-entry.js +1 -1
- package/dist/cjs/{index-legacy-560e8537.js → index-legacy-a8ebc221.js} +2 -2
- package/dist/cjs/index.js +30 -25
- package/dist/es/components/AnimatePresence/index.mjs +29 -24
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +31 -26
- package/dist/framer-motion.js +1 -1
- package/dist/projection.dev.js +2 -2
- package/package.json +2 -2
- package/dist/cjs/index-legacy-9f6d433e.js +0 -5492
package/dist/cjs/dom-entry.js
CHANGED
|
@@ -2645,7 +2645,7 @@ class MotionValue {
|
|
|
2645
2645
|
* This will be replaced by the build step with the latest version number.
|
|
2646
2646
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2647
2647
|
*/
|
|
2648
|
-
this.version = "10.12.
|
|
2648
|
+
this.version = "10.12.10";
|
|
2649
2649
|
/**
|
|
2650
2650
|
* Duration, in milliseconds, since last updating frame.
|
|
2651
2651
|
*
|
|
@@ -3817,7 +3817,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
3817
3817
|
* and warn against mismatches.
|
|
3818
3818
|
*/
|
|
3819
3819
|
if (process.env.NODE_ENV === "development") {
|
|
3820
|
-
warnOnce(nextValue.version === "10.12.
|
|
3820
|
+
warnOnce(nextValue.version === "10.12.10", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.10 may not work as expected.`);
|
|
3821
3821
|
}
|
|
3822
3822
|
}
|
|
3823
3823
|
else if (isMotionValue(prevValue)) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var indexLegacy = require('./index-legacy-
|
|
6
|
+
var indexLegacy = require('./index-legacy-a8ebc221.js');
|
|
7
7
|
|
|
8
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
9
|
|
|
@@ -4742,7 +4742,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
4742
4742
|
// Filter out any children that aren't ReactElements. We can only track ReactElements with a props.key
|
|
4743
4743
|
const filteredChildren = onlyElements(children);
|
|
4744
4744
|
let childrenToRender = filteredChildren;
|
|
4745
|
-
const
|
|
4745
|
+
const exitingChildren = React.useRef(new Map()).current;
|
|
4746
4746
|
// Keep a living record of the children we're actually rendering so we
|
|
4747
4747
|
// can diff to figure out which are entering and exiting
|
|
4748
4748
|
const presentChildren = React.useRef(childrenToRender);
|
|
@@ -4759,7 +4759,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
4759
4759
|
useUnmountEffect(() => {
|
|
4760
4760
|
isInitialRender.current = true;
|
|
4761
4761
|
allChildren.clear();
|
|
4762
|
-
|
|
4762
|
+
exitingChildren.clear();
|
|
4763
4763
|
});
|
|
4764
4764
|
if (isInitialRender.current) {
|
|
4765
4765
|
return (React__namespace.createElement(React__namespace.Fragment, null, childrenToRender.map((child) => (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, initial: initial ? undefined : false, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child)))));
|
|
@@ -4774,18 +4774,18 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
4774
4774
|
const numPresent = presentKeys.length;
|
|
4775
4775
|
for (let i = 0; i < numPresent; i++) {
|
|
4776
4776
|
const key = presentKeys[i];
|
|
4777
|
-
if (targetKeys.indexOf(key) === -1) {
|
|
4778
|
-
|
|
4777
|
+
if (targetKeys.indexOf(key) === -1 && !exitingChildren.has(key)) {
|
|
4778
|
+
exitingChildren.set(key, undefined);
|
|
4779
4779
|
}
|
|
4780
4780
|
}
|
|
4781
4781
|
// If we currently have exiting children, and we're deferring rendering incoming children
|
|
4782
4782
|
// until after all current children have exiting, empty the childrenToRender array
|
|
4783
|
-
if (mode === "wait" &&
|
|
4783
|
+
if (mode === "wait" && exitingChildren.size) {
|
|
4784
4784
|
childrenToRender = [];
|
|
4785
4785
|
}
|
|
4786
4786
|
// Loop through all currently exiting components and clone them to overwrite `animate`
|
|
4787
4787
|
// with any `exit` prop they might have defined.
|
|
4788
|
-
|
|
4788
|
+
exitingChildren.forEach((component, key) => {
|
|
4789
4789
|
// If this component is actually entering again, early return
|
|
4790
4790
|
if (targetKeys.indexOf(key) !== -1)
|
|
4791
4791
|
return;
|
|
@@ -4793,35 +4793,40 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
4793
4793
|
if (!child)
|
|
4794
4794
|
return;
|
|
4795
4795
|
const insertionIndex = presentKeys.indexOf(key);
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
if (
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4796
|
+
let exitingComponent = component;
|
|
4797
|
+
if (!exitingComponent) {
|
|
4798
|
+
const onExit = () => {
|
|
4799
|
+
allChildren.delete(key);
|
|
4800
|
+
exitingChildren.delete(key);
|
|
4801
|
+
// Remove this child from the present children
|
|
4802
|
+
const removeIndex = presentChildren.current.findIndex((presentChild) => presentChild.key === key);
|
|
4803
|
+
presentChildren.current.splice(removeIndex, 1);
|
|
4804
|
+
// Defer re-rendering until all exiting children have indeed left
|
|
4805
|
+
if (!exitingChildren.size) {
|
|
4806
|
+
presentChildren.current = filteredChildren;
|
|
4807
|
+
if (isMounted.current === false)
|
|
4808
|
+
return;
|
|
4809
|
+
forceRender();
|
|
4810
|
+
onExitComplete && onExitComplete();
|
|
4811
|
+
}
|
|
4812
|
+
};
|
|
4813
|
+
exitingComponent = (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: false, onExitComplete: onExit, custom: custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));
|
|
4814
|
+
exitingChildren.set(key, exitingComponent);
|
|
4815
|
+
}
|
|
4816
|
+
childrenToRender.splice(insertionIndex, 0, exitingComponent);
|
|
4812
4817
|
});
|
|
4813
4818
|
// Add `MotionContext` even to children that don't need it to ensure we're rendering
|
|
4814
4819
|
// the same tree between renders
|
|
4815
4820
|
childrenToRender = childrenToRender.map((child) => {
|
|
4816
4821
|
const key = child.key;
|
|
4817
|
-
return
|
|
4822
|
+
return exitingChildren.has(key) ? (child) : (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));
|
|
4818
4823
|
});
|
|
4819
4824
|
if (process.env.NODE_ENV !== "production" &&
|
|
4820
4825
|
mode === "wait" &&
|
|
4821
4826
|
childrenToRender.length > 1) {
|
|
4822
4827
|
console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
|
|
4823
4828
|
}
|
|
4824
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
4829
|
+
return (React__namespace.createElement(React__namespace.Fragment, null, exitingChildren.size
|
|
4825
4830
|
? childrenToRender
|
|
4826
4831
|
: childrenToRender.map((child) => React.cloneElement(child))));
|
|
4827
4832
|
};
|
|
@@ -66,7 +66,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
66
66
|
// Filter out any children that aren't ReactElements. We can only track ReactElements with a props.key
|
|
67
67
|
const filteredChildren = onlyElements(children);
|
|
68
68
|
let childrenToRender = filteredChildren;
|
|
69
|
-
const
|
|
69
|
+
const exitingChildren = useRef(new Map()).current;
|
|
70
70
|
// Keep a living record of the children we're actually rendering so we
|
|
71
71
|
// can diff to figure out which are entering and exiting
|
|
72
72
|
const presentChildren = useRef(childrenToRender);
|
|
@@ -83,7 +83,7 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
83
83
|
useUnmountEffect(() => {
|
|
84
84
|
isInitialRender.current = true;
|
|
85
85
|
allChildren.clear();
|
|
86
|
-
|
|
86
|
+
exitingChildren.clear();
|
|
87
87
|
});
|
|
88
88
|
if (isInitialRender.current) {
|
|
89
89
|
return (React.createElement(React.Fragment, null, childrenToRender.map((child) => (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, initial: initial ? undefined : false, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child)))));
|
|
@@ -98,18 +98,18 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
98
98
|
const numPresent = presentKeys.length;
|
|
99
99
|
for (let i = 0; i < numPresent; i++) {
|
|
100
100
|
const key = presentKeys[i];
|
|
101
|
-
if (targetKeys.indexOf(key) === -1) {
|
|
102
|
-
|
|
101
|
+
if (targetKeys.indexOf(key) === -1 && !exitingChildren.has(key)) {
|
|
102
|
+
exitingChildren.set(key, undefined);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
// If we currently have exiting children, and we're deferring rendering incoming children
|
|
106
106
|
// until after all current children have exiting, empty the childrenToRender array
|
|
107
|
-
if (mode === "wait" &&
|
|
107
|
+
if (mode === "wait" && exitingChildren.size) {
|
|
108
108
|
childrenToRender = [];
|
|
109
109
|
}
|
|
110
110
|
// Loop through all currently exiting components and clone them to overwrite `animate`
|
|
111
111
|
// with any `exit` prop they might have defined.
|
|
112
|
-
|
|
112
|
+
exitingChildren.forEach((component, key) => {
|
|
113
113
|
// If this component is actually entering again, early return
|
|
114
114
|
if (targetKeys.indexOf(key) !== -1)
|
|
115
115
|
return;
|
|
@@ -117,35 +117,40 @@ const AnimatePresence = ({ children, custom, initial = true, onExitComplete, exi
|
|
|
117
117
|
if (!child)
|
|
118
118
|
return;
|
|
119
119
|
const insertionIndex = presentKeys.indexOf(key);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
120
|
+
let exitingComponent = component;
|
|
121
|
+
if (!exitingComponent) {
|
|
122
|
+
const onExit = () => {
|
|
123
|
+
allChildren.delete(key);
|
|
124
|
+
exitingChildren.delete(key);
|
|
125
|
+
// Remove this child from the present children
|
|
126
|
+
const removeIndex = presentChildren.current.findIndex((presentChild) => presentChild.key === key);
|
|
127
|
+
presentChildren.current.splice(removeIndex, 1);
|
|
128
|
+
// Defer re-rendering until all exiting children have indeed left
|
|
129
|
+
if (!exitingChildren.size) {
|
|
130
|
+
presentChildren.current = filteredChildren;
|
|
131
|
+
if (isMounted.current === false)
|
|
132
|
+
return;
|
|
133
|
+
forceRender();
|
|
134
|
+
onExitComplete && onExitComplete();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
exitingComponent = (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: false, onExitComplete: onExit, custom: custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));
|
|
138
|
+
exitingChildren.set(key, exitingComponent);
|
|
139
|
+
}
|
|
140
|
+
childrenToRender.splice(insertionIndex, 0, exitingComponent);
|
|
136
141
|
});
|
|
137
142
|
// Add `MotionContext` even to children that don't need it to ensure we're rendering
|
|
138
143
|
// the same tree between renders
|
|
139
144
|
childrenToRender = childrenToRender.map((child) => {
|
|
140
145
|
const key = child.key;
|
|
141
|
-
return
|
|
146
|
+
return exitingChildren.has(key) ? (child) : (React.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));
|
|
142
147
|
});
|
|
143
148
|
if (process.env.NODE_ENV !== "production" &&
|
|
144
149
|
mode === "wait" &&
|
|
145
150
|
childrenToRender.length > 1) {
|
|
146
151
|
console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
|
|
147
152
|
}
|
|
148
|
-
return (React.createElement(React.Fragment, null,
|
|
153
|
+
return (React.createElement(React.Fragment, null, exitingChildren.size
|
|
149
154
|
? childrenToRender
|
|
150
155
|
: childrenToRender.map((child) => cloneElement(child))));
|
|
151
156
|
};
|
|
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
22
22
|
* and warn against mismatches.
|
|
23
23
|
*/
|
|
24
24
|
if (process.env.NODE_ENV === "development") {
|
|
25
|
-
warnOnce(nextValue.version === "10.12.
|
|
25
|
+
warnOnce(nextValue.version === "10.12.10", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.10 may not work as expected.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else if (isMotionValue(prevValue)) {
|
package/dist/es/value/index.mjs
CHANGED
|
@@ -26,7 +26,7 @@ class MotionValue {
|
|
|
26
26
|
* This will be replaced by the build step with the latest version number.
|
|
27
27
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
28
28
|
*/
|
|
29
|
-
this.version = "10.12.
|
|
29
|
+
this.version = "10.12.10";
|
|
30
30
|
/**
|
|
31
31
|
* Duration, in milliseconds, since last updating frame.
|
|
32
32
|
*
|
|
@@ -3774,7 +3774,7 @@
|
|
|
3774
3774
|
* This will be replaced by the build step with the latest version number.
|
|
3775
3775
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
3776
3776
|
*/
|
|
3777
|
-
this.version = "10.12.
|
|
3777
|
+
this.version = "10.12.10";
|
|
3778
3778
|
/**
|
|
3779
3779
|
* Duration, in milliseconds, since last updating frame.
|
|
3780
3780
|
*
|
|
@@ -6569,7 +6569,7 @@
|
|
|
6569
6569
|
* and warn against mismatches.
|
|
6570
6570
|
*/
|
|
6571
6571
|
{
|
|
6572
|
-
warnOnce(nextValue.version === "10.12.
|
|
6572
|
+
warnOnce(nextValue.version === "10.12.10", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.12.10 may not work as expected.`);
|
|
6573
6573
|
}
|
|
6574
6574
|
}
|
|
6575
6575
|
else if (isMotionValue(prevValue)) {
|
|
@@ -10121,7 +10121,7 @@
|
|
|
10121
10121
|
// Filter out any children that aren't ReactElements. We can only track ReactElements with a props.key
|
|
10122
10122
|
const filteredChildren = onlyElements(children);
|
|
10123
10123
|
let childrenToRender = filteredChildren;
|
|
10124
|
-
const
|
|
10124
|
+
const exitingChildren = React.useRef(new Map()).current;
|
|
10125
10125
|
// Keep a living record of the children we're actually rendering so we
|
|
10126
10126
|
// can diff to figure out which are entering and exiting
|
|
10127
10127
|
const presentChildren = React.useRef(childrenToRender);
|
|
@@ -10138,7 +10138,7 @@
|
|
|
10138
10138
|
useUnmountEffect(() => {
|
|
10139
10139
|
isInitialRender.current = true;
|
|
10140
10140
|
allChildren.clear();
|
|
10141
|
-
|
|
10141
|
+
exitingChildren.clear();
|
|
10142
10142
|
});
|
|
10143
10143
|
if (isInitialRender.current) {
|
|
10144
10144
|
return (React__namespace.createElement(React__namespace.Fragment, null, childrenToRender.map((child) => (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, initial: initial ? undefined : false, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child)))));
|
|
@@ -10153,18 +10153,18 @@
|
|
|
10153
10153
|
const numPresent = presentKeys.length;
|
|
10154
10154
|
for (let i = 0; i < numPresent; i++) {
|
|
10155
10155
|
const key = presentKeys[i];
|
|
10156
|
-
if (targetKeys.indexOf(key) === -1) {
|
|
10157
|
-
|
|
10156
|
+
if (targetKeys.indexOf(key) === -1 && !exitingChildren.has(key)) {
|
|
10157
|
+
exitingChildren.set(key, undefined);
|
|
10158
10158
|
}
|
|
10159
10159
|
}
|
|
10160
10160
|
// If we currently have exiting children, and we're deferring rendering incoming children
|
|
10161
10161
|
// until after all current children have exiting, empty the childrenToRender array
|
|
10162
|
-
if (mode === "wait" &&
|
|
10162
|
+
if (mode === "wait" && exitingChildren.size) {
|
|
10163
10163
|
childrenToRender = [];
|
|
10164
10164
|
}
|
|
10165
10165
|
// Loop through all currently exiting components and clone them to overwrite `animate`
|
|
10166
10166
|
// with any `exit` prop they might have defined.
|
|
10167
|
-
|
|
10167
|
+
exitingChildren.forEach((component, key) => {
|
|
10168
10168
|
// If this component is actually entering again, early return
|
|
10169
10169
|
if (targetKeys.indexOf(key) !== -1)
|
|
10170
10170
|
return;
|
|
@@ -10172,34 +10172,39 @@
|
|
|
10172
10172
|
if (!child)
|
|
10173
10173
|
return;
|
|
10174
10174
|
const insertionIndex = presentKeys.indexOf(key);
|
|
10175
|
-
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
if (
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10175
|
+
let exitingComponent = component;
|
|
10176
|
+
if (!exitingComponent) {
|
|
10177
|
+
const onExit = () => {
|
|
10178
|
+
allChildren.delete(key);
|
|
10179
|
+
exitingChildren.delete(key);
|
|
10180
|
+
// Remove this child from the present children
|
|
10181
|
+
const removeIndex = presentChildren.current.findIndex((presentChild) => presentChild.key === key);
|
|
10182
|
+
presentChildren.current.splice(removeIndex, 1);
|
|
10183
|
+
// Defer re-rendering until all exiting children have indeed left
|
|
10184
|
+
if (!exitingChildren.size) {
|
|
10185
|
+
presentChildren.current = filteredChildren;
|
|
10186
|
+
if (isMounted.current === false)
|
|
10187
|
+
return;
|
|
10188
|
+
forceRender();
|
|
10189
|
+
onExitComplete && onExitComplete();
|
|
10190
|
+
}
|
|
10191
|
+
};
|
|
10192
|
+
exitingComponent = (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: false, onExitComplete: onExit, custom: custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));
|
|
10193
|
+
exitingChildren.set(key, exitingComponent);
|
|
10194
|
+
}
|
|
10195
|
+
childrenToRender.splice(insertionIndex, 0, exitingComponent);
|
|
10191
10196
|
});
|
|
10192
10197
|
// Add `MotionContext` even to children that don't need it to ensure we're rendering
|
|
10193
10198
|
// the same tree between renders
|
|
10194
10199
|
childrenToRender = childrenToRender.map((child) => {
|
|
10195
10200
|
const key = child.key;
|
|
10196
|
-
return
|
|
10201
|
+
return exitingChildren.has(key) ? (child) : (React__namespace.createElement(PresenceChild, { key: getChildKey(child), isPresent: true, presenceAffectsLayout: presenceAffectsLayout, mode: mode }, child));
|
|
10197
10202
|
});
|
|
10198
10203
|
if (mode === "wait" &&
|
|
10199
10204
|
childrenToRender.length > 1) {
|
|
10200
10205
|
console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
|
|
10201
10206
|
}
|
|
10202
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
10207
|
+
return (React__namespace.createElement(React__namespace.Fragment, null, exitingChildren.size
|
|
10203
10208
|
? childrenToRender
|
|
10204
10209
|
: childrenToRender.map((child) => React.cloneElement(child))));
|
|
10205
10210
|
};
|