framer-motion 8.2.4 → 8.3.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/index.js +30 -4
- package/dist/es/render/VisualElement.mjs +4 -1
- package/dist/es/render/dom/use-render.mjs +13 -2
- package/dist/es/render/html/HTMLVisualElement.mjs +14 -0
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +30 -4
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +43 -38
- package/dist/projection.dev.js +19 -3
- 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.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/dist/size-webpack-m.js +1 -1
- package/dist/three-entry.d.ts +12 -12
- package/package.json +10 -10
package/dist/cjs/index.js
CHANGED
|
@@ -1057,10 +1057,20 @@ function createUseRender(forwardMotionProps = false) {
|
|
|
1057
1057
|
...visualProps,
|
|
1058
1058
|
ref,
|
|
1059
1059
|
};
|
|
1060
|
+
/**
|
|
1061
|
+
* If component has been handed a motion value as its child,
|
|
1062
|
+
* memoise its initial value and render that. Subsequent updates
|
|
1063
|
+
* will be handled by the onChange handler
|
|
1064
|
+
*/
|
|
1065
|
+
const { children } = props;
|
|
1066
|
+
const renderedChildren = React.useMemo(() => (isMotionValue(children) ? children.get() : children), [children]);
|
|
1060
1067
|
if (projectionId) {
|
|
1061
1068
|
elementProps["data-projection-id"] = projectionId;
|
|
1062
1069
|
}
|
|
1063
|
-
return React.createElement(Component,
|
|
1070
|
+
return React.createElement(Component, {
|
|
1071
|
+
...elementProps,
|
|
1072
|
+
children: renderedChildren,
|
|
1073
|
+
});
|
|
1064
1074
|
};
|
|
1065
1075
|
return useRender;
|
|
1066
1076
|
}
|
|
@@ -2062,7 +2072,7 @@ class MotionValue {
|
|
|
2062
2072
|
* This will be replaced by the build step with the latest version number.
|
|
2063
2073
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2064
2074
|
*/
|
|
2065
|
-
this.version = "8.
|
|
2075
|
+
this.version = "8.3.0";
|
|
2066
2076
|
/**
|
|
2067
2077
|
* Duration, in milliseconds, since last updating frame.
|
|
2068
2078
|
*
|
|
@@ -5918,7 +5928,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5918
5928
|
* and warn against mismatches.
|
|
5919
5929
|
*/
|
|
5920
5930
|
if (process.env.NODE_ENV === "development") {
|
|
5921
|
-
warnOnce(nextValue.version === "8.
|
|
5931
|
+
warnOnce(nextValue.version === "8.3.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.3.0 may not work as expected.`);
|
|
5922
5932
|
}
|
|
5923
5933
|
}
|
|
5924
5934
|
else if (isMotionValue(prevValue)) {
|
|
@@ -6147,7 +6157,7 @@ class VisualElement {
|
|
|
6147
6157
|
return 0;
|
|
6148
6158
|
return this.sortInstanceNodePosition(this.current, other.current);
|
|
6149
6159
|
}
|
|
6150
|
-
loadFeatures(renderedProps, isStrict, preloadedFeatures, projectionId, ProjectionNodeConstructor, initialLayoutGroupConfig) {
|
|
6160
|
+
loadFeatures({ children, ...renderedProps }, isStrict, preloadedFeatures, projectionId, ProjectionNodeConstructor, initialLayoutGroupConfig) {
|
|
6151
6161
|
const features = [];
|
|
6152
6162
|
/**
|
|
6153
6163
|
* If we're in development mode, check to make sure we're not rendering a motion component
|
|
@@ -6252,6 +6262,9 @@ class VisualElement {
|
|
|
6252
6262
|
}
|
|
6253
6263
|
}
|
|
6254
6264
|
this.prevMotionValues = updateMotionValuesFromProps(this, this.scrapeMotionValuesFromProps(props, prevProps), this.prevMotionValues);
|
|
6265
|
+
if (this.handleChildMotionValue) {
|
|
6266
|
+
this.handleChildMotionValue();
|
|
6267
|
+
}
|
|
6255
6268
|
}
|
|
6256
6269
|
getProps() {
|
|
6257
6270
|
return this.props;
|
|
@@ -6481,6 +6494,19 @@ class HTMLVisualElement extends DOMVisualElement {
|
|
|
6481
6494
|
scrapeMotionValuesFromProps(props, prevProps) {
|
|
6482
6495
|
return scrapeMotionValuesFromProps$1(props, prevProps);
|
|
6483
6496
|
}
|
|
6497
|
+
handleChildMotionValue() {
|
|
6498
|
+
if (this.childSubscription) {
|
|
6499
|
+
this.childSubscription();
|
|
6500
|
+
delete this.childSubscription;
|
|
6501
|
+
}
|
|
6502
|
+
const { children } = this.props;
|
|
6503
|
+
if (isMotionValue(children)) {
|
|
6504
|
+
this.childSubscription = children.on("change", (latest) => {
|
|
6505
|
+
if (this.current)
|
|
6506
|
+
this.current.textContent = `${latest}`;
|
|
6507
|
+
});
|
|
6508
|
+
}
|
|
6509
|
+
}
|
|
6484
6510
|
renderInstance(instance, renderState, styleProp, projection) {
|
|
6485
6511
|
renderHTML(instance, renderState, styleProp, projection);
|
|
6486
6512
|
}
|
|
@@ -209,7 +209,7 @@ class VisualElement {
|
|
|
209
209
|
return 0;
|
|
210
210
|
return this.sortInstanceNodePosition(this.current, other.current);
|
|
211
211
|
}
|
|
212
|
-
loadFeatures(renderedProps, isStrict, preloadedFeatures, projectionId, ProjectionNodeConstructor, initialLayoutGroupConfig) {
|
|
212
|
+
loadFeatures({ children, ...renderedProps }, isStrict, preloadedFeatures, projectionId, ProjectionNodeConstructor, initialLayoutGroupConfig) {
|
|
213
213
|
const features = [];
|
|
214
214
|
/**
|
|
215
215
|
* If we're in development mode, check to make sure we're not rendering a motion component
|
|
@@ -314,6 +314,9 @@ class VisualElement {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
this.prevMotionValues = updateMotionValuesFromProps(this, this.scrapeMotionValuesFromProps(props, prevProps), this.prevMotionValues);
|
|
317
|
+
if (this.handleChildMotionValue) {
|
|
318
|
+
this.handleChildMotionValue();
|
|
319
|
+
}
|
|
317
320
|
}
|
|
318
321
|
getProps() {
|
|
319
322
|
return this.props;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { createElement } from 'react';
|
|
1
|
+
import { useMemo, createElement } from 'react';
|
|
2
2
|
import { useHTMLProps } from '../html/use-props.mjs';
|
|
3
3
|
import { filterProps } from './utils/filter-props.mjs';
|
|
4
4
|
import { isSVGComponent } from './utils/is-svg-component.mjs';
|
|
5
5
|
import { useSVGProps } from '../svg/use-props.mjs';
|
|
6
|
+
import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
|
|
6
7
|
|
|
7
8
|
function createUseRender(forwardMotionProps = false) {
|
|
8
9
|
const useRender = (Component, props, projectionId, ref, { latestValues }, isStatic) => {
|
|
@@ -16,10 +17,20 @@ function createUseRender(forwardMotionProps = false) {
|
|
|
16
17
|
...visualProps,
|
|
17
18
|
ref,
|
|
18
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* If component has been handed a motion value as its child,
|
|
22
|
+
* memoise its initial value and render that. Subsequent updates
|
|
23
|
+
* will be handled by the onChange handler
|
|
24
|
+
*/
|
|
25
|
+
const { children } = props;
|
|
26
|
+
const renderedChildren = useMemo(() => (isMotionValue(children) ? children.get() : children), [children]);
|
|
19
27
|
if (projectionId) {
|
|
20
28
|
elementProps["data-projection-id"] = projectionId;
|
|
21
29
|
}
|
|
22
|
-
return createElement(Component,
|
|
30
|
+
return createElement(Component, {
|
|
31
|
+
...elementProps,
|
|
32
|
+
children: renderedChildren,
|
|
33
|
+
});
|
|
23
34
|
};
|
|
24
35
|
return useRender;
|
|
25
36
|
}
|
|
@@ -6,6 +6,7 @@ import { renderHTML } from './utils/render.mjs';
|
|
|
6
6
|
import { getDefaultValueType } from '../dom/value-types/defaults.mjs';
|
|
7
7
|
import { measureViewportBox } from '../../projection/utils/measure.mjs';
|
|
8
8
|
import { DOMVisualElement } from '../dom/DOMVisualElement.mjs';
|
|
9
|
+
import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
|
|
9
10
|
|
|
10
11
|
function getComputedStyle(element) {
|
|
11
12
|
return window.getComputedStyle(element);
|
|
@@ -33,6 +34,19 @@ class HTMLVisualElement extends DOMVisualElement {
|
|
|
33
34
|
scrapeMotionValuesFromProps(props, prevProps) {
|
|
34
35
|
return scrapeMotionValuesFromProps(props, prevProps);
|
|
35
36
|
}
|
|
37
|
+
handleChildMotionValue() {
|
|
38
|
+
if (this.childSubscription) {
|
|
39
|
+
this.childSubscription();
|
|
40
|
+
delete this.childSubscription;
|
|
41
|
+
}
|
|
42
|
+
const { children } = this.props;
|
|
43
|
+
if (isMotionValue(children)) {
|
|
44
|
+
this.childSubscription = children.on("change", (latest) => {
|
|
45
|
+
if (this.current)
|
|
46
|
+
this.current.textContent = `${latest}`;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
36
50
|
renderInstance(instance, renderState, styleProp, projection) {
|
|
37
51
|
renderHTML(instance, renderState, styleProp, projection);
|
|
38
52
|
}
|
|
@@ -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 === "8.
|
|
25
|
+
warnOnce(nextValue.version === "8.3.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.3.0 may not work as expected.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else if (isMotionValue(prevValue)) {
|
package/dist/es/value/index.mjs
CHANGED
|
@@ -25,7 +25,7 @@ class MotionValue {
|
|
|
25
25
|
* This will be replaced by the build step with the latest version number.
|
|
26
26
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
27
27
|
*/
|
|
28
|
-
this.version = "8.
|
|
28
|
+
this.version = "8.3.0";
|
|
29
29
|
/**
|
|
30
30
|
* Duration, in milliseconds, since last updating frame.
|
|
31
31
|
*
|
|
@@ -1055,10 +1055,20 @@
|
|
|
1055
1055
|
...visualProps,
|
|
1056
1056
|
ref,
|
|
1057
1057
|
};
|
|
1058
|
+
/**
|
|
1059
|
+
* If component has been handed a motion value as its child,
|
|
1060
|
+
* memoise its initial value and render that. Subsequent updates
|
|
1061
|
+
* will be handled by the onChange handler
|
|
1062
|
+
*/
|
|
1063
|
+
const { children } = props;
|
|
1064
|
+
const renderedChildren = React.useMemo(() => (isMotionValue(children) ? children.get() : children), [children]);
|
|
1058
1065
|
if (projectionId) {
|
|
1059
1066
|
elementProps["data-projection-id"] = projectionId;
|
|
1060
1067
|
}
|
|
1061
|
-
return React.createElement(Component,
|
|
1068
|
+
return React.createElement(Component, {
|
|
1069
|
+
...elementProps,
|
|
1070
|
+
children: renderedChildren,
|
|
1071
|
+
});
|
|
1062
1072
|
};
|
|
1063
1073
|
return useRender;
|
|
1064
1074
|
}
|
|
@@ -2060,7 +2070,7 @@
|
|
|
2060
2070
|
* This will be replaced by the build step with the latest version number.
|
|
2061
2071
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2062
2072
|
*/
|
|
2063
|
-
this.version = "8.
|
|
2073
|
+
this.version = "8.3.0";
|
|
2064
2074
|
/**
|
|
2065
2075
|
* Duration, in milliseconds, since last updating frame.
|
|
2066
2076
|
*
|
|
@@ -5931,7 +5941,7 @@
|
|
|
5931
5941
|
* and warn against mismatches.
|
|
5932
5942
|
*/
|
|
5933
5943
|
{
|
|
5934
|
-
warnOnce(nextValue.version === "8.
|
|
5944
|
+
warnOnce(nextValue.version === "8.3.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.3.0 may not work as expected.`);
|
|
5935
5945
|
}
|
|
5936
5946
|
}
|
|
5937
5947
|
else if (isMotionValue(prevValue)) {
|
|
@@ -6160,7 +6170,7 @@
|
|
|
6160
6170
|
return 0;
|
|
6161
6171
|
return this.sortInstanceNodePosition(this.current, other.current);
|
|
6162
6172
|
}
|
|
6163
|
-
loadFeatures(renderedProps, isStrict, preloadedFeatures, projectionId, ProjectionNodeConstructor, initialLayoutGroupConfig) {
|
|
6173
|
+
loadFeatures({ children, ...renderedProps }, isStrict, preloadedFeatures, projectionId, ProjectionNodeConstructor, initialLayoutGroupConfig) {
|
|
6164
6174
|
const features = [];
|
|
6165
6175
|
/**
|
|
6166
6176
|
* If we're in development mode, check to make sure we're not rendering a motion component
|
|
@@ -6264,6 +6274,9 @@
|
|
|
6264
6274
|
}
|
|
6265
6275
|
}
|
|
6266
6276
|
this.prevMotionValues = updateMotionValuesFromProps(this, this.scrapeMotionValuesFromProps(props, prevProps), this.prevMotionValues);
|
|
6277
|
+
if (this.handleChildMotionValue) {
|
|
6278
|
+
this.handleChildMotionValue();
|
|
6279
|
+
}
|
|
6267
6280
|
}
|
|
6268
6281
|
getProps() {
|
|
6269
6282
|
return this.props;
|
|
@@ -6493,6 +6506,19 @@
|
|
|
6493
6506
|
scrapeMotionValuesFromProps(props, prevProps) {
|
|
6494
6507
|
return scrapeMotionValuesFromProps$1(props, prevProps);
|
|
6495
6508
|
}
|
|
6509
|
+
handleChildMotionValue() {
|
|
6510
|
+
if (this.childSubscription) {
|
|
6511
|
+
this.childSubscription();
|
|
6512
|
+
delete this.childSubscription;
|
|
6513
|
+
}
|
|
6514
|
+
const { children } = this.props;
|
|
6515
|
+
if (isMotionValue(children)) {
|
|
6516
|
+
this.childSubscription = children.on("change", (latest) => {
|
|
6517
|
+
if (this.current)
|
|
6518
|
+
this.current.textContent = `${latest}`;
|
|
6519
|
+
});
|
|
6520
|
+
}
|
|
6521
|
+
}
|
|
6496
6522
|
renderInstance(instance, renderState, styleProp, projection) {
|
|
6497
6523
|
renderHTML(instance, renderState, styleProp, projection);
|
|
6498
6524
|
}
|