framer-motion 7.5.2 → 7.5.4
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 +38 -8
- package/dist/es/projection/node/create-projection-node.mjs +5 -3
- package/dist/es/projection/utils/has-transform.mjs +6 -4
- package/dist/es/render/index.mjs +28 -1
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +38 -8
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/projection.dev.js +63 -8
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.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/three-entry.d.ts +1 -0
- package/package.json +5 -5
package/dist/cjs/index.js
CHANGED
|
@@ -2245,7 +2245,7 @@ class MotionValue {
|
|
|
2245
2245
|
* This will be replaced by the build step with the latest version number.
|
|
2246
2246
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2247
2247
|
*/
|
|
2248
|
-
this.version = "7.5.
|
|
2248
|
+
this.version = "7.5.4";
|
|
2249
2249
|
/**
|
|
2250
2250
|
* Duration, in milliseconds, since last updating frame.
|
|
2251
2251
|
*
|
|
@@ -3533,14 +3533,16 @@ function hasScale({ scale, scaleX, scaleY }) {
|
|
|
3533
3533
|
}
|
|
3534
3534
|
function hasTransform(values) {
|
|
3535
3535
|
return (hasScale(values) ||
|
|
3536
|
-
|
|
3537
|
-
hasTranslate(values.y) ||
|
|
3536
|
+
has2DTranslate(values) ||
|
|
3538
3537
|
values.z ||
|
|
3539
3538
|
values.rotate ||
|
|
3540
3539
|
values.rotateX ||
|
|
3541
3540
|
values.rotateY);
|
|
3542
3541
|
}
|
|
3543
|
-
function
|
|
3542
|
+
function has2DTranslate(values) {
|
|
3543
|
+
return is2DTranslate(values.x) || is2DTranslate(values.y);
|
|
3544
|
+
}
|
|
3545
|
+
function is2DTranslate(value) {
|
|
3544
3546
|
return value && value !== "0%";
|
|
3545
3547
|
}
|
|
3546
3548
|
|
|
@@ -4221,7 +4223,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
4221
4223
|
* and warn against mismatches.
|
|
4222
4224
|
*/
|
|
4223
4225
|
if (process.env.NODE_ENV === "development") {
|
|
4224
|
-
warnOnce(nextValue.version === "7.5.
|
|
4226
|
+
warnOnce(nextValue.version === "7.5.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.5.4 may not work as expected.`);
|
|
4225
4227
|
}
|
|
4226
4228
|
}
|
|
4227
4229
|
else if (isMotionValue(prevValue)) {
|
|
@@ -4300,6 +4302,10 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
|
|
|
4300
4302
|
const baseTarget = {
|
|
4301
4303
|
...latestValues,
|
|
4302
4304
|
};
|
|
4305
|
+
/**
|
|
4306
|
+
* Create an object of the values we initially animated from (if initial prop present).
|
|
4307
|
+
*/
|
|
4308
|
+
const initialValues = props.initial ? { ...latestValues } : {};
|
|
4303
4309
|
// Internal methods ========================
|
|
4304
4310
|
/**
|
|
4305
4311
|
* On mount, this will be hydrated with a callback to disconnect
|
|
@@ -4646,12 +4652,34 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
|
|
|
4646
4652
|
* props.
|
|
4647
4653
|
*/
|
|
4648
4654
|
getBaseTarget(key) {
|
|
4655
|
+
var _a;
|
|
4656
|
+
const { initial } = props;
|
|
4657
|
+
const valueFromInitial = typeof initial === "string" || typeof initial === "object"
|
|
4658
|
+
? (_a = resolveVariantFromProps(props, initial)) === null || _a === void 0 ? void 0 : _a[key]
|
|
4659
|
+
: undefined;
|
|
4660
|
+
/**
|
|
4661
|
+
* If this value still exists in the current initial variant, read that.
|
|
4662
|
+
*/
|
|
4663
|
+
if (initial && valueFromInitial !== undefined) {
|
|
4664
|
+
return valueFromInitial;
|
|
4665
|
+
}
|
|
4666
|
+
/**
|
|
4667
|
+
* Alternatively, if this VisualElement config has defined a getBaseTarget
|
|
4668
|
+
* so we can read the value from an alternative source, try that.
|
|
4669
|
+
*/
|
|
4649
4670
|
if (getBaseTarget) {
|
|
4650
4671
|
const target = getBaseTarget(props, key);
|
|
4651
4672
|
if (target !== undefined && !isMotionValue(target))
|
|
4652
4673
|
return target;
|
|
4653
4674
|
}
|
|
4654
|
-
|
|
4675
|
+
/**
|
|
4676
|
+
* If the value was initially defined on initial, but it doesn't any more,
|
|
4677
|
+
* return undefined. Otherwise return the value as initially read from the DOM.
|
|
4678
|
+
*/
|
|
4679
|
+
return initialValues[key] !== undefined &&
|
|
4680
|
+
valueFromInitial === undefined
|
|
4681
|
+
? undefined
|
|
4682
|
+
: baseTarget[key];
|
|
4655
4683
|
},
|
|
4656
4684
|
// Lifecyles ========================
|
|
4657
4685
|
...lifecycles,
|
|
@@ -5970,7 +5998,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
5970
5998
|
*/
|
|
5971
5999
|
if (!hasLayoutChanged &&
|
|
5972
6000
|
this.animationProgress === 0) {
|
|
5973
|
-
|
|
6001
|
+
finishAnimation(this);
|
|
5974
6002
|
}
|
|
5975
6003
|
this.isLead() && ((_e = (_d = this.options).onExitComplete) === null || _e === void 0 ? void 0 : _e.call(_d));
|
|
5976
6004
|
}
|
|
@@ -6379,7 +6407,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
6379
6407
|
}
|
|
6380
6408
|
}
|
|
6381
6409
|
getClosestProjectingParent() {
|
|
6382
|
-
if (!this.parent ||
|
|
6410
|
+
if (!this.parent ||
|
|
6411
|
+
hasScale(this.parent.latestValues) ||
|
|
6412
|
+
has2DTranslate(this.parent.latestValues))
|
|
6383
6413
|
return undefined;
|
|
6384
6414
|
if ((this.parent.relativeTarget || this.parent.targetDelta) &&
|
|
6385
6415
|
this.parent.layout) {
|
|
@@ -14,7 +14,7 @@ import { NodeStack } from '../shared/stack.mjs';
|
|
|
14
14
|
import { scaleCorrectors } from '../styles/scale-correction.mjs';
|
|
15
15
|
import { buildProjectionTransform } from '../styles/transform.mjs';
|
|
16
16
|
import { eachAxis } from '../utils/each-axis.mjs';
|
|
17
|
-
import { hasTransform, hasScale } from '../utils/has-transform.mjs';
|
|
17
|
+
import { hasTransform, hasScale, has2DTranslate } from '../utils/has-transform.mjs';
|
|
18
18
|
import { FlatTree } from '../../render/utils/flat-tree.mjs';
|
|
19
19
|
import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
|
|
20
20
|
import { globalProjectionState } from './state.mjs';
|
|
@@ -230,7 +230,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
230
230
|
*/
|
|
231
231
|
if (!hasLayoutChanged &&
|
|
232
232
|
this.animationProgress === 0) {
|
|
233
|
-
|
|
233
|
+
finishAnimation(this);
|
|
234
234
|
}
|
|
235
235
|
this.isLead() && ((_e = (_d = this.options).onExitComplete) === null || _e === void 0 ? void 0 : _e.call(_d));
|
|
236
236
|
}
|
|
@@ -639,7 +639,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
getClosestProjectingParent() {
|
|
642
|
-
if (!this.parent ||
|
|
642
|
+
if (!this.parent ||
|
|
643
|
+
hasScale(this.parent.latestValues) ||
|
|
644
|
+
has2DTranslate(this.parent.latestValues))
|
|
643
645
|
return undefined;
|
|
644
646
|
if ((this.parent.relativeTarget || this.parent.targetDelta) &&
|
|
645
647
|
this.parent.layout) {
|
|
@@ -8,15 +8,17 @@ function hasScale({ scale, scaleX, scaleY }) {
|
|
|
8
8
|
}
|
|
9
9
|
function hasTransform(values) {
|
|
10
10
|
return (hasScale(values) ||
|
|
11
|
-
|
|
12
|
-
hasTranslate(values.y) ||
|
|
11
|
+
has2DTranslate(values) ||
|
|
13
12
|
values.z ||
|
|
14
13
|
values.rotate ||
|
|
15
14
|
values.rotateX ||
|
|
16
15
|
values.rotateY);
|
|
17
16
|
}
|
|
18
|
-
function
|
|
17
|
+
function has2DTranslate(values) {
|
|
18
|
+
return is2DTranslate(values.x) || is2DTranslate(values.y);
|
|
19
|
+
}
|
|
20
|
+
function is2DTranslate(value) {
|
|
19
21
|
return value && value !== "0%";
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
export { hasScale, hasTransform };
|
|
24
|
+
export { has2DTranslate, hasScale, hasTransform };
|
package/dist/es/render/index.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { invariant } from 'hey-listen';
|
|
|
14
14
|
import { featureDefinitions } from '../motion/features/definitions.mjs';
|
|
15
15
|
import { createElement } from 'react';
|
|
16
16
|
import { isRefObject } from '../utils/is-ref-object.mjs';
|
|
17
|
+
import { resolveVariantFromProps } from './utils/resolve-variants.mjs';
|
|
17
18
|
|
|
18
19
|
const featureNames = Object.keys(featureDefinitions);
|
|
19
20
|
const numFeatures = featureNames.length;
|
|
@@ -56,6 +57,10 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
|
|
|
56
57
|
const baseTarget = {
|
|
57
58
|
...latestValues,
|
|
58
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Create an object of the values we initially animated from (if initial prop present).
|
|
62
|
+
*/
|
|
63
|
+
const initialValues = props.initial ? { ...latestValues } : {};
|
|
59
64
|
// Internal methods ========================
|
|
60
65
|
/**
|
|
61
66
|
* On mount, this will be hydrated with a callback to disconnect
|
|
@@ -402,12 +407,34 @@ const visualElement = ({ treeType = "", build, getBaseTarget, makeTargetAnimatab
|
|
|
402
407
|
* props.
|
|
403
408
|
*/
|
|
404
409
|
getBaseTarget(key) {
|
|
410
|
+
var _a;
|
|
411
|
+
const { initial } = props;
|
|
412
|
+
const valueFromInitial = typeof initial === "string" || typeof initial === "object"
|
|
413
|
+
? (_a = resolveVariantFromProps(props, initial)) === null || _a === void 0 ? void 0 : _a[key]
|
|
414
|
+
: undefined;
|
|
415
|
+
/**
|
|
416
|
+
* If this value still exists in the current initial variant, read that.
|
|
417
|
+
*/
|
|
418
|
+
if (initial && valueFromInitial !== undefined) {
|
|
419
|
+
return valueFromInitial;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Alternatively, if this VisualElement config has defined a getBaseTarget
|
|
423
|
+
* so we can read the value from an alternative source, try that.
|
|
424
|
+
*/
|
|
405
425
|
if (getBaseTarget) {
|
|
406
426
|
const target = getBaseTarget(props, key);
|
|
407
427
|
if (target !== undefined && !isMotionValue(target))
|
|
408
428
|
return target;
|
|
409
429
|
}
|
|
410
|
-
|
|
430
|
+
/**
|
|
431
|
+
* If the value was initially defined on initial, but it doesn't any more,
|
|
432
|
+
* return undefined. Otherwise return the value as initially read from the DOM.
|
|
433
|
+
*/
|
|
434
|
+
return initialValues[key] !== undefined &&
|
|
435
|
+
valueFromInitial === undefined
|
|
436
|
+
? undefined
|
|
437
|
+
: baseTarget[key];
|
|
411
438
|
},
|
|
412
439
|
// Lifecyles ========================
|
|
413
440
|
...lifecycles,
|
|
@@ -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 === "7.5.
|
|
25
|
+
warnOnce(nextValue.version === "7.5.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.5.4 may not work as expected.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else if (isMotionValue(prevValue)) {
|
package/dist/es/value/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ class MotionValue {
|
|
|
24
24
|
* This will be replaced by the build step with the latest version number.
|
|
25
25
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
26
26
|
*/
|
|
27
|
-
this.version = "7.5.
|
|
27
|
+
this.version = "7.5.4";
|
|
28
28
|
/**
|
|
29
29
|
* Duration, in milliseconds, since last updating frame.
|
|
30
30
|
*
|
|
@@ -3413,7 +3413,7 @@
|
|
|
3413
3413
|
* This will be replaced by the build step with the latest version number.
|
|
3414
3414
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
3415
3415
|
*/
|
|
3416
|
-
this.version = "7.5.
|
|
3416
|
+
this.version = "7.5.4";
|
|
3417
3417
|
/**
|
|
3418
3418
|
* Duration, in milliseconds, since last updating frame.
|
|
3419
3419
|
*
|
|
@@ -4701,14 +4701,16 @@
|
|
|
4701
4701
|
}
|
|
4702
4702
|
function hasTransform(values) {
|
|
4703
4703
|
return (hasScale(values) ||
|
|
4704
|
-
|
|
4705
|
-
hasTranslate(values.y) ||
|
|
4704
|
+
has2DTranslate(values) ||
|
|
4706
4705
|
values.z ||
|
|
4707
4706
|
values.rotate ||
|
|
4708
4707
|
values.rotateX ||
|
|
4709
4708
|
values.rotateY);
|
|
4710
4709
|
}
|
|
4711
|
-
function
|
|
4710
|
+
function has2DTranslate(values) {
|
|
4711
|
+
return is2DTranslate(values.x) || is2DTranslate(values.y);
|
|
4712
|
+
}
|
|
4713
|
+
function is2DTranslate(value) {
|
|
4712
4714
|
return value && value !== "0%";
|
|
4713
4715
|
}
|
|
4714
4716
|
|
|
@@ -5389,7 +5391,7 @@
|
|
|
5389
5391
|
* and warn against mismatches.
|
|
5390
5392
|
*/
|
|
5391
5393
|
{
|
|
5392
|
-
warnOnce(nextValue.version === "7.5.
|
|
5394
|
+
warnOnce(nextValue.version === "7.5.4", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.5.4 may not work as expected.`);
|
|
5393
5395
|
}
|
|
5394
5396
|
}
|
|
5395
5397
|
else if (isMotionValue(prevValue)) {
|
|
@@ -5468,6 +5470,10 @@
|
|
|
5468
5470
|
const baseTarget = {
|
|
5469
5471
|
...latestValues,
|
|
5470
5472
|
};
|
|
5473
|
+
/**
|
|
5474
|
+
* Create an object of the values we initially animated from (if initial prop present).
|
|
5475
|
+
*/
|
|
5476
|
+
const initialValues = props.initial ? { ...latestValues } : {};
|
|
5471
5477
|
// Internal methods ========================
|
|
5472
5478
|
/**
|
|
5473
5479
|
* On mount, this will be hydrated with a callback to disconnect
|
|
@@ -5814,12 +5820,34 @@
|
|
|
5814
5820
|
* props.
|
|
5815
5821
|
*/
|
|
5816
5822
|
getBaseTarget(key) {
|
|
5823
|
+
var _a;
|
|
5824
|
+
const { initial } = props;
|
|
5825
|
+
const valueFromInitial = typeof initial === "string" || typeof initial === "object"
|
|
5826
|
+
? (_a = resolveVariantFromProps(props, initial)) === null || _a === void 0 ? void 0 : _a[key]
|
|
5827
|
+
: undefined;
|
|
5828
|
+
/**
|
|
5829
|
+
* If this value still exists in the current initial variant, read that.
|
|
5830
|
+
*/
|
|
5831
|
+
if (initial && valueFromInitial !== undefined) {
|
|
5832
|
+
return valueFromInitial;
|
|
5833
|
+
}
|
|
5834
|
+
/**
|
|
5835
|
+
* Alternatively, if this VisualElement config has defined a getBaseTarget
|
|
5836
|
+
* so we can read the value from an alternative source, try that.
|
|
5837
|
+
*/
|
|
5817
5838
|
if (getBaseTarget) {
|
|
5818
5839
|
const target = getBaseTarget(props, key);
|
|
5819
5840
|
if (target !== undefined && !isMotionValue(target))
|
|
5820
5841
|
return target;
|
|
5821
5842
|
}
|
|
5822
|
-
|
|
5843
|
+
/**
|
|
5844
|
+
* If the value was initially defined on initial, but it doesn't any more,
|
|
5845
|
+
* return undefined. Otherwise return the value as initially read from the DOM.
|
|
5846
|
+
*/
|
|
5847
|
+
return initialValues[key] !== undefined &&
|
|
5848
|
+
valueFromInitial === undefined
|
|
5849
|
+
? undefined
|
|
5850
|
+
: baseTarget[key];
|
|
5823
5851
|
},
|
|
5824
5852
|
// Lifecyles ========================
|
|
5825
5853
|
...lifecycles,
|
|
@@ -7138,7 +7166,7 @@
|
|
|
7138
7166
|
*/
|
|
7139
7167
|
if (!hasLayoutChanged &&
|
|
7140
7168
|
this.animationProgress === 0) {
|
|
7141
|
-
|
|
7169
|
+
finishAnimation(this);
|
|
7142
7170
|
}
|
|
7143
7171
|
this.isLead() && ((_e = (_d = this.options).onExitComplete) === null || _e === void 0 ? void 0 : _e.call(_d));
|
|
7144
7172
|
}
|
|
@@ -7547,7 +7575,9 @@
|
|
|
7547
7575
|
}
|
|
7548
7576
|
}
|
|
7549
7577
|
getClosestProjectingParent() {
|
|
7550
|
-
if (!this.parent ||
|
|
7578
|
+
if (!this.parent ||
|
|
7579
|
+
hasScale(this.parent.latestValues) ||
|
|
7580
|
+
has2DTranslate(this.parent.latestValues))
|
|
7551
7581
|
return undefined;
|
|
7552
7582
|
if ((this.parent.relativeTarget || this.parent.targetDelta) &&
|
|
7553
7583
|
this.parent.layout) {
|