framer-motion 10.0.0 → 10.0.2
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 +22 -13
- package/dist/es/animation/legacy-popmotion/index.mjs +11 -1
- package/dist/es/animation/waapi/create-accelerated-animation.mjs +1 -1
- package/dist/es/animation/waapi/index.mjs +4 -1
- package/dist/es/context/MotionContext/index.mjs +2 -5
- package/dist/es/index.mjs +1 -1
- package/dist/es/motion/features/definitions.mjs +2 -2
- package/dist/es/motion/utils/use-visual-element.mjs +2 -2
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/es/value/use-inverted-scale.mjs +3 -2
- package/dist/framer-motion.dev.js +22 -13
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/projection.dev.js +20 -7
- package/dist/size-rollup-dom-animation-assets.js +1 -1
- 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-assets.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 +7 -2
- package/package.json +7 -7
package/dist/cjs/index.js
CHANGED
|
@@ -37,9 +37,6 @@ const MotionConfigContext = React.createContext({
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
const MotionContext = React.createContext({});
|
|
40
|
-
function useVisualElementContext() {
|
|
41
|
-
return React.useContext(MotionContext).visualElement;
|
|
42
|
-
}
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
42
|
* @public
|
|
@@ -53,7 +50,7 @@ const useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : React.useE
|
|
|
53
50
|
const LazyContext = React.createContext({ strict: false });
|
|
54
51
|
|
|
55
52
|
function useVisualElement(Component, visualState, props, createVisualElement) {
|
|
56
|
-
const parent =
|
|
53
|
+
const { visualElement: parent } = React.useContext(MotionContext);
|
|
57
54
|
const lazyContext = React.useContext(LazyContext);
|
|
58
55
|
const presenceContext = React.useContext(PresenceContext);
|
|
59
56
|
const reducedMotionConfig = React.useContext(MotionConfigContext).reducedMotion;
|
|
@@ -193,13 +190,13 @@ function variantLabelsAsDependency(prop) {
|
|
|
193
190
|
const featureProps = {
|
|
194
191
|
animation: [
|
|
195
192
|
"animate",
|
|
196
|
-
"exit",
|
|
197
193
|
"variants",
|
|
198
194
|
"whileHover",
|
|
199
195
|
"whileTap",
|
|
196
|
+
"exit",
|
|
197
|
+
"whileInView",
|
|
200
198
|
"whileFocus",
|
|
201
199
|
"whileDrag",
|
|
202
|
-
"whileInView",
|
|
203
200
|
],
|
|
204
201
|
exit: ["exit"],
|
|
205
202
|
drag: ["drag", "dragControls"],
|
|
@@ -1987,7 +1984,7 @@ class MotionValue {
|
|
|
1987
1984
|
* This will be replaced by the build step with the latest version number.
|
|
1988
1985
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
1989
1986
|
*/
|
|
1990
|
-
this.version = "10.0.
|
|
1987
|
+
this.version = "10.0.2";
|
|
1991
1988
|
/**
|
|
1992
1989
|
* Duration, in milliseconds, since last updating frame.
|
|
1993
1990
|
*
|
|
@@ -3519,9 +3516,19 @@ function animateValue({ duration, driver = framesync, elapsed = 0, repeat: repea
|
|
|
3519
3516
|
* animate() can't yet be sampled for time, instead it
|
|
3520
3517
|
* consumes time. So to sample it we have to run a low
|
|
3521
3518
|
* temporal-resolution version.
|
|
3519
|
+
*
|
|
3520
|
+
* isControlled should be set to true if sample is being run within
|
|
3521
|
+
* a loop. This indicates that we're not arbitrarily sampling
|
|
3522
|
+
* the animation but running it one step after another. Therefore
|
|
3523
|
+
* we don't need to run a low-res version here. This is a stop-gap
|
|
3524
|
+
* until a rewrite can sample for time.
|
|
3522
3525
|
*/
|
|
3523
|
-
sample: (t) => {
|
|
3526
|
+
sample: (t, isControlled = false) => {
|
|
3524
3527
|
elapsed = initialElapsed;
|
|
3528
|
+
if (isControlled) {
|
|
3529
|
+
update(t);
|
|
3530
|
+
return state;
|
|
3531
|
+
}
|
|
3525
3532
|
const sampleResolution = duration && typeof duration === "number"
|
|
3526
3533
|
? Math.max(duration * 0.5, 50)
|
|
3527
3534
|
: 50;
|
|
@@ -3563,7 +3570,10 @@ function mapEasingToNativeEasing(easing) {
|
|
|
3563
3570
|
}
|
|
3564
3571
|
|
|
3565
3572
|
function animateStyle(element, valueName, keyframes, { delay = 0, duration, repeat = 0, repeatType = "loop", ease, times, } = {}) {
|
|
3566
|
-
|
|
3573
|
+
const keyframeOptions = { [valueName]: keyframes };
|
|
3574
|
+
if (times)
|
|
3575
|
+
keyframeOptions.offset = times;
|
|
3576
|
+
return element.animate(keyframeOptions, {
|
|
3567
3577
|
delay,
|
|
3568
3578
|
duration,
|
|
3569
3579
|
easing: mapEasingToNativeEasing(ease),
|
|
@@ -3641,7 +3651,7 @@ function createAcceleratedAnimation(value, valueName, { onUpdate, onComplete, ..
|
|
|
3641
3651
|
*/
|
|
3642
3652
|
let t = 0;
|
|
3643
3653
|
while (!state.done && t < 20000) {
|
|
3644
|
-
state = sampleAnimation.sample(t);
|
|
3654
|
+
state = sampleAnimation.sample(t, true);
|
|
3645
3655
|
pregeneratedKeyframes.push(state.value);
|
|
3646
3656
|
t += sampleDelta;
|
|
3647
3657
|
}
|
|
@@ -7830,7 +7840,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
7830
7840
|
* and warn against mismatches.
|
|
7831
7841
|
*/
|
|
7832
7842
|
if (process.env.NODE_ENV === "development") {
|
|
7833
|
-
warnOnce(nextValue.version === "10.0.
|
|
7843
|
+
warnOnce(nextValue.version === "10.0.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.0.2 may not work as expected.`);
|
|
7834
7844
|
}
|
|
7835
7845
|
}
|
|
7836
7846
|
else if (isMotionValue(prevValue)) {
|
|
@@ -10639,7 +10649,7 @@ let hasWarned = false;
|
|
|
10639
10649
|
function useInvertedScale(scale) {
|
|
10640
10650
|
let parentScaleX = useMotionValue(1);
|
|
10641
10651
|
let parentScaleY = useMotionValue(1);
|
|
10642
|
-
const visualElement =
|
|
10652
|
+
const { visualElement } = React.useContext(MotionContext);
|
|
10643
10653
|
exports.invariant(!!(scale || visualElement), "If no scale values are provided, useInvertedScale must be used within a child of another motion component.");
|
|
10644
10654
|
exports.warning(hasWarned, "useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.");
|
|
10645
10655
|
hasWarned = true;
|
|
@@ -10766,6 +10776,5 @@ exports.useTransform = useTransform;
|
|
|
10766
10776
|
exports.useUnmountEffect = useUnmountEffect;
|
|
10767
10777
|
exports.useVelocity = useVelocity;
|
|
10768
10778
|
exports.useViewportScroll = useViewportScroll;
|
|
10769
|
-
exports.useVisualElementContext = useVisualElementContext;
|
|
10770
10779
|
exports.useWillChange = useWillChange;
|
|
10771
10780
|
exports.wrap = wrap;
|
|
@@ -132,9 +132,19 @@ function animateValue({ duration, driver = framesync, elapsed = 0, repeat: repea
|
|
|
132
132
|
* animate() can't yet be sampled for time, instead it
|
|
133
133
|
* consumes time. So to sample it we have to run a low
|
|
134
134
|
* temporal-resolution version.
|
|
135
|
+
*
|
|
136
|
+
* isControlled should be set to true if sample is being run within
|
|
137
|
+
* a loop. This indicates that we're not arbitrarily sampling
|
|
138
|
+
* the animation but running it one step after another. Therefore
|
|
139
|
+
* we don't need to run a low-res version here. This is a stop-gap
|
|
140
|
+
* until a rewrite can sample for time.
|
|
135
141
|
*/
|
|
136
|
-
sample: (t) => {
|
|
142
|
+
sample: (t, isControlled = false) => {
|
|
137
143
|
elapsed = initialElapsed;
|
|
144
|
+
if (isControlled) {
|
|
145
|
+
update(t);
|
|
146
|
+
return state;
|
|
147
|
+
}
|
|
138
148
|
const sampleResolution = duration && typeof duration === "number"
|
|
139
149
|
? Math.max(duration * 0.5, 50)
|
|
140
150
|
: 50;
|
|
@@ -50,7 +50,7 @@ function createAcceleratedAnimation(value, valueName, { onUpdate, onComplete, ..
|
|
|
50
50
|
*/
|
|
51
51
|
let t = 0;
|
|
52
52
|
while (!state.done && t < 20000) {
|
|
53
|
-
state = sampleAnimation.sample(t);
|
|
53
|
+
state = sampleAnimation.sample(t, true);
|
|
54
54
|
pregeneratedKeyframes.push(state.value);
|
|
55
55
|
t += sampleDelta;
|
|
56
56
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { mapEasingToNativeEasing } from './easing.mjs';
|
|
2
2
|
|
|
3
3
|
function animateStyle(element, valueName, keyframes, { delay = 0, duration, repeat = 0, repeatType = "loop", ease, times, } = {}) {
|
|
4
|
-
|
|
4
|
+
const keyframeOptions = { [valueName]: keyframes };
|
|
5
|
+
if (times)
|
|
6
|
+
keyframeOptions.offset = times;
|
|
7
|
+
return element.animate(keyframeOptions, {
|
|
5
8
|
delay,
|
|
6
9
|
duration,
|
|
7
10
|
easing: mapEasingToNativeEasing(ease),
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { createContext
|
|
1
|
+
import { createContext } from 'react';
|
|
2
2
|
|
|
3
3
|
const MotionContext = createContext({});
|
|
4
|
-
function useVisualElementContext() {
|
|
5
|
-
return useContext(MotionContext).visualElement;
|
|
6
|
-
}
|
|
7
4
|
|
|
8
|
-
export { MotionContext
|
|
5
|
+
export { MotionContext };
|
package/dist/es/index.mjs
CHANGED
|
@@ -63,7 +63,7 @@ export { px } from './value/types/numbers/units.mjs';
|
|
|
63
63
|
export { startOptimizedAppearAnimation } from './animation/optimized-appear/start.mjs';
|
|
64
64
|
export { optimizedAppearDataAttribute } from './animation/optimized-appear/data-id.mjs';
|
|
65
65
|
export { spring } from './animation/legacy-popmotion/spring.mjs';
|
|
66
|
-
export { MotionContext
|
|
66
|
+
export { MotionContext } from './context/MotionContext/index.mjs';
|
|
67
67
|
export { MotionConfigContext } from './context/MotionConfigContext.mjs';
|
|
68
68
|
export { PresenceContext } from './context/PresenceContext.mjs';
|
|
69
69
|
export { LayoutGroupContext } from './context/LayoutGroupContext.mjs';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useContext, useRef, useInsertionEffect, useEffect } from 'react';
|
|
2
2
|
import { PresenceContext } from '../../context/PresenceContext.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { MotionContext } from '../../context/MotionContext/index.mjs';
|
|
4
4
|
import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';
|
|
5
5
|
import { LazyContext } from '../../context/LazyContext.mjs';
|
|
6
6
|
import { MotionConfigContext } from '../../context/MotionConfigContext.mjs';
|
|
7
7
|
|
|
8
8
|
function useVisualElement(Component, visualState, props, createVisualElement) {
|
|
9
|
-
const parent =
|
|
9
|
+
const { visualElement: parent } = useContext(MotionContext);
|
|
10
10
|
const lazyContext = useContext(LazyContext);
|
|
11
11
|
const presenceContext = useContext(PresenceContext);
|
|
12
12
|
const reducedMotionConfig = useContext(MotionConfigContext).reducedMotion;
|
|
@@ -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.0.
|
|
25
|
+
warnOnce(nextValue.version === "10.0.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.0.2 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.0.
|
|
29
|
+
this.version = "10.0.2";
|
|
30
30
|
/**
|
|
31
31
|
* Duration, in milliseconds, since last updating frame.
|
|
32
32
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useTransform } from './use-transform.mjs';
|
|
2
2
|
import { invariant, warning } from '../utils/errors.mjs';
|
|
3
3
|
import { useMotionValue } from './use-motion-value.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { MotionContext } from '../context/MotionContext/index.mjs';
|
|
5
|
+
import { useContext } from 'react';
|
|
5
6
|
|
|
6
7
|
// Keep things reasonable and avoid scale: Infinity. In practise we might need
|
|
7
8
|
// to add another value, opacity, that could interpolate scaleX/Y [0,0.01] => [0,1]
|
|
@@ -31,7 +32,7 @@ let hasWarned = false;
|
|
|
31
32
|
function useInvertedScale(scale) {
|
|
32
33
|
let parentScaleX = useMotionValue(1);
|
|
33
34
|
let parentScaleY = useMotionValue(1);
|
|
34
|
-
const visualElement =
|
|
35
|
+
const { visualElement } = useContext(MotionContext);
|
|
35
36
|
invariant(!!(scale || visualElement), "If no scale values are provided, useInvertedScale must be used within a child of another motion component.");
|
|
36
37
|
warning(hasWarned, "useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.");
|
|
37
38
|
hasWarned = true;
|
|
@@ -37,9 +37,6 @@
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
const MotionContext = React.createContext({});
|
|
40
|
-
function useVisualElementContext() {
|
|
41
|
-
return React.useContext(MotionContext).visualElement;
|
|
42
|
-
}
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
42
|
* @public
|
|
@@ -53,7 +50,7 @@
|
|
|
53
50
|
const LazyContext = React.createContext({ strict: false });
|
|
54
51
|
|
|
55
52
|
function useVisualElement(Component, visualState, props, createVisualElement) {
|
|
56
|
-
const parent =
|
|
53
|
+
const { visualElement: parent } = React.useContext(MotionContext);
|
|
57
54
|
const lazyContext = React.useContext(LazyContext);
|
|
58
55
|
const presenceContext = React.useContext(PresenceContext);
|
|
59
56
|
const reducedMotionConfig = React.useContext(MotionConfigContext).reducedMotion;
|
|
@@ -193,13 +190,13 @@
|
|
|
193
190
|
const featureProps = {
|
|
194
191
|
animation: [
|
|
195
192
|
"animate",
|
|
196
|
-
"exit",
|
|
197
193
|
"variants",
|
|
198
194
|
"whileHover",
|
|
199
195
|
"whileTap",
|
|
196
|
+
"exit",
|
|
197
|
+
"whileInView",
|
|
200
198
|
"whileFocus",
|
|
201
199
|
"whileDrag",
|
|
202
|
-
"whileInView",
|
|
203
200
|
],
|
|
204
201
|
exit: ["exit"],
|
|
205
202
|
drag: ["drag", "dragControls"],
|
|
@@ -1987,7 +1984,7 @@
|
|
|
1987
1984
|
* This will be replaced by the build step with the latest version number.
|
|
1988
1985
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
1989
1986
|
*/
|
|
1990
|
-
this.version = "10.0.
|
|
1987
|
+
this.version = "10.0.2";
|
|
1991
1988
|
/**
|
|
1992
1989
|
* Duration, in milliseconds, since last updating frame.
|
|
1993
1990
|
*
|
|
@@ -3519,9 +3516,19 @@
|
|
|
3519
3516
|
* animate() can't yet be sampled for time, instead it
|
|
3520
3517
|
* consumes time. So to sample it we have to run a low
|
|
3521
3518
|
* temporal-resolution version.
|
|
3519
|
+
*
|
|
3520
|
+
* isControlled should be set to true if sample is being run within
|
|
3521
|
+
* a loop. This indicates that we're not arbitrarily sampling
|
|
3522
|
+
* the animation but running it one step after another. Therefore
|
|
3523
|
+
* we don't need to run a low-res version here. This is a stop-gap
|
|
3524
|
+
* until a rewrite can sample for time.
|
|
3522
3525
|
*/
|
|
3523
|
-
sample: (t) => {
|
|
3526
|
+
sample: (t, isControlled = false) => {
|
|
3524
3527
|
elapsed = initialElapsed;
|
|
3528
|
+
if (isControlled) {
|
|
3529
|
+
update(t);
|
|
3530
|
+
return state;
|
|
3531
|
+
}
|
|
3525
3532
|
const sampleResolution = duration && typeof duration === "number"
|
|
3526
3533
|
? Math.max(duration * 0.5, 50)
|
|
3527
3534
|
: 50;
|
|
@@ -3563,7 +3570,10 @@
|
|
|
3563
3570
|
}
|
|
3564
3571
|
|
|
3565
3572
|
function animateStyle(element, valueName, keyframes, { delay = 0, duration, repeat = 0, repeatType = "loop", ease, times, } = {}) {
|
|
3566
|
-
|
|
3573
|
+
const keyframeOptions = { [valueName]: keyframes };
|
|
3574
|
+
if (times)
|
|
3575
|
+
keyframeOptions.offset = times;
|
|
3576
|
+
return element.animate(keyframeOptions, {
|
|
3567
3577
|
delay,
|
|
3568
3578
|
duration,
|
|
3569
3579
|
easing: mapEasingToNativeEasing(ease),
|
|
@@ -3641,7 +3651,7 @@
|
|
|
3641
3651
|
*/
|
|
3642
3652
|
let t = 0;
|
|
3643
3653
|
while (!state.done && t < 20000) {
|
|
3644
|
-
state = sampleAnimation.sample(t);
|
|
3654
|
+
state = sampleAnimation.sample(t, true);
|
|
3645
3655
|
pregeneratedKeyframes.push(state.value);
|
|
3646
3656
|
t += sampleDelta;
|
|
3647
3657
|
}
|
|
@@ -7830,7 +7840,7 @@
|
|
|
7830
7840
|
* and warn against mismatches.
|
|
7831
7841
|
*/
|
|
7832
7842
|
{
|
|
7833
|
-
warnOnce(nextValue.version === "10.0.
|
|
7843
|
+
warnOnce(nextValue.version === "10.0.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.0.2 may not work as expected.`);
|
|
7834
7844
|
}
|
|
7835
7845
|
}
|
|
7836
7846
|
else if (isMotionValue(prevValue)) {
|
|
@@ -10637,7 +10647,7 @@
|
|
|
10637
10647
|
function useInvertedScale(scale) {
|
|
10638
10648
|
let parentScaleX = useMotionValue(1);
|
|
10639
10649
|
let parentScaleY = useMotionValue(1);
|
|
10640
|
-
const visualElement =
|
|
10650
|
+
const { visualElement } = React.useContext(MotionContext);
|
|
10641
10651
|
exports.invariant(!!(scale || visualElement), "If no scale values are provided, useInvertedScale must be used within a child of another motion component.");
|
|
10642
10652
|
exports.warning(hasWarned, "useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.");
|
|
10643
10653
|
hasWarned = true;
|
|
@@ -10764,7 +10774,6 @@
|
|
|
10764
10774
|
exports.useUnmountEffect = useUnmountEffect;
|
|
10765
10775
|
exports.useVelocity = useVelocity;
|
|
10766
10776
|
exports.useViewportScroll = useViewportScroll;
|
|
10767
|
-
exports.useVisualElementContext = useVisualElementContext;
|
|
10768
10777
|
exports.useWillChange = useWillChange;
|
|
10769
10778
|
exports.wrap = wrap;
|
|
10770
10779
|
|