framer-motion 11.17.0 → 11.17.1
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 +66 -26
- package/dist/cjs/dom.js +5 -3
- package/dist/cjs/index.js +74 -34
- package/dist/cjs/m.js +184 -146
- package/dist/client.d.ts +90 -90
- package/dist/dom.js +1 -1
- package/dist/es/motion/utils/use-motion-ref.mjs +3 -1
- package/dist/es/motion/utils/use-visual-state.mjs +11 -5
- package/dist/es/render/VisualElement.mjs +3 -1
- package/dist/es/render/svg/config-motion.mjs +54 -23
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +74 -34
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +104 -95
- package/dist/m.d.ts +90 -90
- package/dist/three.d.ts +100 -91
- package/package.json +6 -6
package/dist/cjs/client.js
CHANGED
|
@@ -409,7 +409,7 @@ class MotionValue {
|
|
|
409
409
|
* This will be replaced by the build step with the latest version number.
|
|
410
410
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
411
411
|
*/
|
|
412
|
-
this.version = "11.17.
|
|
412
|
+
this.version = "11.17.1";
|
|
413
413
|
/**
|
|
414
414
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
415
415
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -5201,7 +5201,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5201
5201
|
* and warn against mismatches.
|
|
5202
5202
|
*/
|
|
5203
5203
|
if (process.env.NODE_ENV === "development") {
|
|
5204
|
-
warnOnce(nextValue.version === "11.17.
|
|
5204
|
+
warnOnce(nextValue.version === "11.17.1", `Attempting to mix Motion versions ${nextValue.version} with 11.17.1 may not work as expected.`);
|
|
5205
5205
|
}
|
|
5206
5206
|
}
|
|
5207
5207
|
else if (isMotionValue(prevValue)) {
|
|
@@ -5334,7 +5334,8 @@ class VisualElement {
|
|
|
5334
5334
|
frame.render(this.render, false, true);
|
|
5335
5335
|
}
|
|
5336
5336
|
};
|
|
5337
|
-
const { latestValues, renderState } = visualState;
|
|
5337
|
+
const { latestValues, renderState, onUpdate } = visualState;
|
|
5338
|
+
this.onUpdate = onUpdate;
|
|
5338
5339
|
this.latestValues = latestValues;
|
|
5339
5340
|
this.baseTarget = { ...latestValues };
|
|
5340
5341
|
this.initialValues = props.initial ? { ...latestValues } : {};
|
|
@@ -5534,6 +5535,7 @@ class VisualElement {
|
|
|
5534
5535
|
if (this.handleChildMotionValue) {
|
|
5535
5536
|
this.handleChildMotionValue();
|
|
5536
5537
|
}
|
|
5538
|
+
this.onUpdate && this.onUpdate(this);
|
|
5537
5539
|
}
|
|
5538
5540
|
getProps() {
|
|
5539
5541
|
return this.props;
|
|
@@ -8631,7 +8633,9 @@ const motionComponentSymbol = Symbol.for("motionComponentSymbol");
|
|
|
8631
8633
|
*/
|
|
8632
8634
|
function useMotionRef(visualState, visualElement, externalRef) {
|
|
8633
8635
|
return react.useCallback((instance) => {
|
|
8634
|
-
|
|
8636
|
+
if (instance) {
|
|
8637
|
+
visualState.onMount && visualState.onMount(instance);
|
|
8638
|
+
}
|
|
8635
8639
|
if (visualElement) {
|
|
8636
8640
|
if (instance) {
|
|
8637
8641
|
visualElement.mount(instance);
|
|
@@ -8940,13 +8944,19 @@ function useConstant(init) {
|
|
|
8940
8944
|
return ref.current;
|
|
8941
8945
|
}
|
|
8942
8946
|
|
|
8943
|
-
function makeState({ scrapeMotionValuesFromProps, createRenderState,
|
|
8947
|
+
function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
|
|
8944
8948
|
const state = {
|
|
8945
8949
|
latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
|
|
8946
8950
|
renderState: createRenderState(),
|
|
8947
8951
|
};
|
|
8948
|
-
if (
|
|
8949
|
-
|
|
8952
|
+
if (onUpdate) {
|
|
8953
|
+
/**
|
|
8954
|
+
* onMount works without the VisualElement because it could be
|
|
8955
|
+
* called before the VisualElement payload has been hydrated.
|
|
8956
|
+
* (e.g. if someone is using m components <m.circle />)
|
|
8957
|
+
*/
|
|
8958
|
+
state.onMount = (instance) => onUpdate({ props, current: instance, ...state });
|
|
8959
|
+
state.onUpdate = (visualElement) => onUpdate(visualElement);
|
|
8950
8960
|
}
|
|
8951
8961
|
return state;
|
|
8952
8962
|
}
|
|
@@ -9024,32 +9034,62 @@ const createSvgRenderState = () => ({
|
|
|
9024
9034
|
attrs: {},
|
|
9025
9035
|
});
|
|
9026
9036
|
|
|
9037
|
+
function updateSVGDimensions(instance, renderState) {
|
|
9038
|
+
try {
|
|
9039
|
+
renderState.dimensions =
|
|
9040
|
+
typeof instance.getBBox === "function"
|
|
9041
|
+
? instance.getBBox()
|
|
9042
|
+
: instance.getBoundingClientRect();
|
|
9043
|
+
}
|
|
9044
|
+
catch (e) {
|
|
9045
|
+
// Most likely trying to measure an unrendered element under Firefox
|
|
9046
|
+
renderState.dimensions = {
|
|
9047
|
+
x: 0,
|
|
9048
|
+
y: 0,
|
|
9049
|
+
width: 0,
|
|
9050
|
+
height: 0,
|
|
9051
|
+
};
|
|
9052
|
+
}
|
|
9053
|
+
}
|
|
9054
|
+
const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
|
|
9027
9055
|
const svgMotionConfig = {
|
|
9028
9056
|
useVisualState: makeUseVisualState({
|
|
9029
9057
|
scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
|
|
9030
9058
|
createRenderState: createSvgRenderState,
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9059
|
+
onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
|
|
9060
|
+
if (!current)
|
|
9061
|
+
return;
|
|
9062
|
+
let hasTransform = !!props.drag;
|
|
9063
|
+
if (!hasTransform) {
|
|
9064
|
+
for (const key in latestValues) {
|
|
9065
|
+
if (transformProps.has(key)) {
|
|
9066
|
+
hasTransform = true;
|
|
9067
|
+
break;
|
|
9068
|
+
}
|
|
9039
9069
|
}
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9070
|
+
}
|
|
9071
|
+
if (!hasTransform)
|
|
9072
|
+
return;
|
|
9073
|
+
let needsMeasure = !prevProps;
|
|
9074
|
+
if (prevProps) {
|
|
9075
|
+
/**
|
|
9076
|
+
* Check the layout props for changes, if any are found we need to
|
|
9077
|
+
* measure the element again.
|
|
9078
|
+
*/
|
|
9079
|
+
for (let i = 0; i < layoutProps.length; i++) {
|
|
9080
|
+
const key = layoutProps[i];
|
|
9081
|
+
if (props[key] !==
|
|
9082
|
+
prevProps[key]) {
|
|
9083
|
+
needsMeasure = true;
|
|
9084
|
+
}
|
|
9048
9085
|
}
|
|
9049
|
-
}
|
|
9086
|
+
}
|
|
9087
|
+
if (!needsMeasure)
|
|
9088
|
+
return;
|
|
9089
|
+
frame.read(() => updateSVGDimensions(current, renderState));
|
|
9050
9090
|
frame.render(() => {
|
|
9051
|
-
buildSVGAttrs(renderState, latestValues, isSVGTag(
|
|
9052
|
-
renderSVG(
|
|
9091
|
+
buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
|
|
9092
|
+
renderSVG(current, renderState);
|
|
9053
9093
|
});
|
|
9054
9094
|
},
|
|
9055
9095
|
}),
|
package/dist/cjs/dom.js
CHANGED
|
@@ -994,7 +994,7 @@ class MotionValue {
|
|
|
994
994
|
* This will be replaced by the build step with the latest version number.
|
|
995
995
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
996
996
|
*/
|
|
997
|
-
this.version = "11.17.
|
|
997
|
+
this.version = "11.17.1";
|
|
998
998
|
/**
|
|
999
999
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
1000
1000
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -3924,7 +3924,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
3924
3924
|
* and warn against mismatches.
|
|
3925
3925
|
*/
|
|
3926
3926
|
if (process.env.NODE_ENV === "development") {
|
|
3927
|
-
warnOnce(nextValue.version === "11.17.
|
|
3927
|
+
warnOnce(nextValue.version === "11.17.1", `Attempting to mix Motion versions ${nextValue.version} with 11.17.1 may not work as expected.`);
|
|
3928
3928
|
}
|
|
3929
3929
|
}
|
|
3930
3930
|
else if (isMotionValue(prevValue)) {
|
|
@@ -4057,7 +4057,8 @@ class VisualElement {
|
|
|
4057
4057
|
frame.render(this.render, false, true);
|
|
4058
4058
|
}
|
|
4059
4059
|
};
|
|
4060
|
-
const { latestValues, renderState } = visualState;
|
|
4060
|
+
const { latestValues, renderState, onUpdate } = visualState;
|
|
4061
|
+
this.onUpdate = onUpdate;
|
|
4061
4062
|
this.latestValues = latestValues;
|
|
4062
4063
|
this.baseTarget = { ...latestValues };
|
|
4063
4064
|
this.initialValues = props.initial ? { ...latestValues } : {};
|
|
@@ -4257,6 +4258,7 @@ class VisualElement {
|
|
|
4257
4258
|
if (this.handleChildMotionValue) {
|
|
4258
4259
|
this.handleChildMotionValue();
|
|
4259
4260
|
}
|
|
4261
|
+
this.onUpdate && this.onUpdate(this);
|
|
4260
4262
|
}
|
|
4261
4263
|
getProps() {
|
|
4262
4264
|
return this.props;
|
package/dist/cjs/index.js
CHANGED
|
@@ -445,7 +445,7 @@ class MotionValue {
|
|
|
445
445
|
* This will be replaced by the build step with the latest version number.
|
|
446
446
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
447
447
|
*/
|
|
448
|
-
this.version = "11.17.
|
|
448
|
+
this.version = "11.17.1";
|
|
449
449
|
/**
|
|
450
450
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
451
451
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -4255,6 +4255,14 @@ function filterProps(props, isDom, forwardMotionProps) {
|
|
|
4255
4255
|
*/
|
|
4256
4256
|
const PresenceContext = React.createContext(null);
|
|
4257
4257
|
|
|
4258
|
+
function isControllingVariants(props) {
|
|
4259
|
+
return (isAnimationControls(props.animate) ||
|
|
4260
|
+
variantProps.some((name) => isVariantLabel(props[name])));
|
|
4261
|
+
}
|
|
4262
|
+
function isVariantNode(props) {
|
|
4263
|
+
return Boolean(isControllingVariants(props) || props.variants);
|
|
4264
|
+
}
|
|
4265
|
+
|
|
4258
4266
|
/**
|
|
4259
4267
|
* Creates a constant value over the lifecycle of a component.
|
|
4260
4268
|
*
|
|
@@ -4282,21 +4290,19 @@ function resolveMotionValue(value) {
|
|
|
4282
4290
|
: unwrappedValue;
|
|
4283
4291
|
}
|
|
4284
4292
|
|
|
4285
|
-
function
|
|
4286
|
-
return (isAnimationControls(props.animate) ||
|
|
4287
|
-
variantProps.some((name) => isVariantLabel(props[name])));
|
|
4288
|
-
}
|
|
4289
|
-
function isVariantNode(props) {
|
|
4290
|
-
return Boolean(isControllingVariants(props) || props.variants);
|
|
4291
|
-
}
|
|
4292
|
-
|
|
4293
|
-
function makeState({ scrapeMotionValuesFromProps, createRenderState, onMount, }, props, context, presenceContext) {
|
|
4293
|
+
function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
|
|
4294
4294
|
const state = {
|
|
4295
4295
|
latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
|
|
4296
4296
|
renderState: createRenderState(),
|
|
4297
4297
|
};
|
|
4298
|
-
if (
|
|
4299
|
-
|
|
4298
|
+
if (onUpdate) {
|
|
4299
|
+
/**
|
|
4300
|
+
* onMount works without the VisualElement because it could be
|
|
4301
|
+
* called before the VisualElement payload has been hydrated.
|
|
4302
|
+
* (e.g. if someone is using m components <m.circle />)
|
|
4303
|
+
*/
|
|
4304
|
+
state.onMount = (instance) => onUpdate({ props, current: instance, ...state });
|
|
4305
|
+
state.onUpdate = (visualElement) => onUpdate(visualElement);
|
|
4300
4306
|
}
|
|
4301
4307
|
return state;
|
|
4302
4308
|
}
|
|
@@ -5209,7 +5215,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5209
5215
|
* and warn against mismatches.
|
|
5210
5216
|
*/
|
|
5211
5217
|
if (process.env.NODE_ENV === "development") {
|
|
5212
|
-
warnOnce(nextValue.version === "11.17.
|
|
5218
|
+
warnOnce(nextValue.version === "11.17.1", `Attempting to mix Motion versions ${nextValue.version} with 11.17.1 may not work as expected.`);
|
|
5213
5219
|
}
|
|
5214
5220
|
}
|
|
5215
5221
|
else if (isMotionValue(prevValue)) {
|
|
@@ -5342,7 +5348,8 @@ class VisualElement {
|
|
|
5342
5348
|
frame.render(this.render, false, true);
|
|
5343
5349
|
}
|
|
5344
5350
|
};
|
|
5345
|
-
const { latestValues, renderState } = visualState;
|
|
5351
|
+
const { latestValues, renderState, onUpdate } = visualState;
|
|
5352
|
+
this.onUpdate = onUpdate;
|
|
5346
5353
|
this.latestValues = latestValues;
|
|
5347
5354
|
this.baseTarget = { ...latestValues };
|
|
5348
5355
|
this.initialValues = props.initial ? { ...latestValues } : {};
|
|
@@ -5542,6 +5549,7 @@ class VisualElement {
|
|
|
5542
5549
|
if (this.handleChildMotionValue) {
|
|
5543
5550
|
this.handleChildMotionValue();
|
|
5544
5551
|
}
|
|
5552
|
+
this.onUpdate && this.onUpdate(this);
|
|
5545
5553
|
}
|
|
5546
5554
|
getProps() {
|
|
5547
5555
|
return this.props;
|
|
@@ -10729,7 +10737,9 @@ const motionComponentSymbol = Symbol.for("motionComponentSymbol");
|
|
|
10729
10737
|
*/
|
|
10730
10738
|
function useMotionRef(visualState, visualElement, externalRef) {
|
|
10731
10739
|
return React.useCallback((instance) => {
|
|
10732
|
-
|
|
10740
|
+
if (instance) {
|
|
10741
|
+
visualState.onMount && visualState.onMount(instance);
|
|
10742
|
+
}
|
|
10733
10743
|
if (visualElement) {
|
|
10734
10744
|
if (instance) {
|
|
10735
10745
|
visualElement.mount(instance);
|
|
@@ -11033,32 +11043,62 @@ const createSvgRenderState = () => ({
|
|
|
11033
11043
|
attrs: {},
|
|
11034
11044
|
});
|
|
11035
11045
|
|
|
11046
|
+
function updateSVGDimensions(instance, renderState) {
|
|
11047
|
+
try {
|
|
11048
|
+
renderState.dimensions =
|
|
11049
|
+
typeof instance.getBBox === "function"
|
|
11050
|
+
? instance.getBBox()
|
|
11051
|
+
: instance.getBoundingClientRect();
|
|
11052
|
+
}
|
|
11053
|
+
catch (e) {
|
|
11054
|
+
// Most likely trying to measure an unrendered element under Firefox
|
|
11055
|
+
renderState.dimensions = {
|
|
11056
|
+
x: 0,
|
|
11057
|
+
y: 0,
|
|
11058
|
+
width: 0,
|
|
11059
|
+
height: 0,
|
|
11060
|
+
};
|
|
11061
|
+
}
|
|
11062
|
+
}
|
|
11063
|
+
const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
|
|
11036
11064
|
const svgMotionConfig = {
|
|
11037
11065
|
useVisualState: makeUseVisualState({
|
|
11038
11066
|
scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
|
|
11039
11067
|
createRenderState: createSvgRenderState,
|
|
11040
|
-
|
|
11041
|
-
|
|
11042
|
-
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11047
|
-
|
|
11068
|
+
onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
|
|
11069
|
+
if (!current)
|
|
11070
|
+
return;
|
|
11071
|
+
let hasTransform = !!props.drag;
|
|
11072
|
+
if (!hasTransform) {
|
|
11073
|
+
for (const key in latestValues) {
|
|
11074
|
+
if (transformProps.has(key)) {
|
|
11075
|
+
hasTransform = true;
|
|
11076
|
+
break;
|
|
11077
|
+
}
|
|
11048
11078
|
}
|
|
11049
|
-
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11079
|
+
}
|
|
11080
|
+
if (!hasTransform)
|
|
11081
|
+
return;
|
|
11082
|
+
let needsMeasure = !prevProps;
|
|
11083
|
+
if (prevProps) {
|
|
11084
|
+
/**
|
|
11085
|
+
* Check the layout props for changes, if any are found we need to
|
|
11086
|
+
* measure the element again.
|
|
11087
|
+
*/
|
|
11088
|
+
for (let i = 0; i < layoutProps.length; i++) {
|
|
11089
|
+
const key = layoutProps[i];
|
|
11090
|
+
if (props[key] !==
|
|
11091
|
+
prevProps[key]) {
|
|
11092
|
+
needsMeasure = true;
|
|
11093
|
+
}
|
|
11057
11094
|
}
|
|
11058
|
-
}
|
|
11095
|
+
}
|
|
11096
|
+
if (!needsMeasure)
|
|
11097
|
+
return;
|
|
11098
|
+
frame.read(() => updateSVGDimensions(current, renderState));
|
|
11059
11099
|
frame.render(() => {
|
|
11060
|
-
buildSVGAttrs(renderState, latestValues, isSVGTag(
|
|
11061
|
-
renderSVG(
|
|
11100
|
+
buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
|
|
11101
|
+
renderSVG(current, renderState);
|
|
11062
11102
|
});
|
|
11063
11103
|
},
|
|
11064
11104
|
}),
|