framer-motion 8.0.4 → 8.1.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 +28 -16
- package/dist/es/render/dom/utils/unit-conversion.mjs +2 -8
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +17 -2
- package/dist/es/value/use-spring.mjs +9 -6
- package/dist/framer-motion.dev.js +28 -16
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/projection.dev.js +20 -11
- 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 +6 -0
- package/package.json +5 -5
package/dist/cjs/index.js
CHANGED
|
@@ -2061,7 +2061,7 @@ class MotionValue {
|
|
|
2061
2061
|
* This will be replaced by the build step with the latest version number.
|
|
2062
2062
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2063
2063
|
*/
|
|
2064
|
-
this.version = "8.0
|
|
2064
|
+
this.version = "8.1.0";
|
|
2065
2065
|
/**
|
|
2066
2066
|
* Duration, in milliseconds, since last updating frame.
|
|
2067
2067
|
*
|
|
@@ -2214,8 +2214,9 @@ class MotionValue {
|
|
|
2214
2214
|
*
|
|
2215
2215
|
* @internal
|
|
2216
2216
|
*/
|
|
2217
|
-
attach(passiveEffect) {
|
|
2217
|
+
attach(passiveEffect, stopPassiveEffect) {
|
|
2218
2218
|
this.passiveEffect = passiveEffect;
|
|
2219
|
+
this.stopPassiveEffect = stopPassiveEffect;
|
|
2219
2220
|
}
|
|
2220
2221
|
/**
|
|
2221
2222
|
* Sets the state of the `MotionValue`.
|
|
@@ -2245,6 +2246,17 @@ class MotionValue {
|
|
|
2245
2246
|
this.prev = prev;
|
|
2246
2247
|
this.timeDelta = delta;
|
|
2247
2248
|
}
|
|
2249
|
+
/**
|
|
2250
|
+
* Set the state of the `MotionValue`, stopping any active animations,
|
|
2251
|
+
* effects, and resets velocity to `0`.
|
|
2252
|
+
*/
|
|
2253
|
+
jump(v) {
|
|
2254
|
+
this.updateAndNotify(v);
|
|
2255
|
+
this.prev = v;
|
|
2256
|
+
this.stop();
|
|
2257
|
+
if (this.stopPassiveEffect)
|
|
2258
|
+
this.stopPassiveEffect();
|
|
2259
|
+
}
|
|
2248
2260
|
/**
|
|
2249
2261
|
* Returns the latest state of `MotionValue`
|
|
2250
2262
|
*
|
|
@@ -2340,6 +2352,9 @@ class MotionValue {
|
|
|
2340
2352
|
destroy() {
|
|
2341
2353
|
this.clearListeners();
|
|
2342
2354
|
this.stop();
|
|
2355
|
+
if (this.stopPassiveEffect) {
|
|
2356
|
+
this.stopPassiveEffect();
|
|
2357
|
+
}
|
|
2343
2358
|
}
|
|
2344
2359
|
}
|
|
2345
2360
|
function motionValue(init, options) {
|
|
@@ -5611,12 +5626,6 @@ const isPositionalKey = (key) => positionalKeys.has(key);
|
|
|
5611
5626
|
const hasPositionalKey = (target) => {
|
|
5612
5627
|
return Object.keys(target).some(isPositionalKey);
|
|
5613
5628
|
};
|
|
5614
|
-
const setAndResetVelocity = (value, to) => {
|
|
5615
|
-
// Looks odd but setting it twice doesn't render, it'll just
|
|
5616
|
-
// set both prev and current to the latest value
|
|
5617
|
-
value.set(to, false);
|
|
5618
|
-
value.set(to);
|
|
5619
|
-
};
|
|
5620
5629
|
const isNumOrPxType = (v) => v === number || v === px;
|
|
5621
5630
|
var BoundingBoxDimension;
|
|
5622
5631
|
(function (BoundingBoxDimension) {
|
|
@@ -5697,7 +5706,7 @@ const convertChangedValueTypes = (target, visualElement, changedKeys) => {
|
|
|
5697
5706
|
// Restore styles to their **calculated computed style**, not their actual
|
|
5698
5707
|
// originally set style. This allows us to animate between equivalent pixel units.
|
|
5699
5708
|
const value = visualElement.getValue(key);
|
|
5700
|
-
|
|
5709
|
+
value && value.jump(origin[key]);
|
|
5701
5710
|
target[key] = positionalValues[key](targetBbox, elementComputedStyle);
|
|
5702
5711
|
});
|
|
5703
5712
|
return target;
|
|
@@ -5782,7 +5791,7 @@ const checkAndConvertChangedValueTypes = (visualElement, target, origin = {}, tr
|
|
|
5782
5791
|
transitionEnd[key] !== undefined
|
|
5783
5792
|
? transitionEnd[key]
|
|
5784
5793
|
: target[key];
|
|
5785
|
-
|
|
5794
|
+
value.jump(to);
|
|
5786
5795
|
}
|
|
5787
5796
|
}
|
|
5788
5797
|
});
|
|
@@ -5871,7 +5880,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5871
5880
|
* and warn against mismatches.
|
|
5872
5881
|
*/
|
|
5873
5882
|
if (process.env.NODE_ENV === "development") {
|
|
5874
|
-
warnOnce(nextValue.version === "8.0
|
|
5883
|
+
warnOnce(nextValue.version === "8.1.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.1.0 may not work as expected.`);
|
|
5875
5884
|
}
|
|
5876
5885
|
}
|
|
5877
5886
|
else if (isMotionValue(prevValue)) {
|
|
@@ -9150,7 +9159,12 @@ function useSpring(source, config = {}) {
|
|
|
9150
9159
|
const { isStatic } = React.useContext(MotionConfigContext);
|
|
9151
9160
|
const activeSpringAnimation = React.useRef(null);
|
|
9152
9161
|
const value = useMotionValue(isMotionValue(source) ? source.get() : source);
|
|
9153
|
-
|
|
9162
|
+
const stopAnimation = () => {
|
|
9163
|
+
if (activeSpringAnimation.current) {
|
|
9164
|
+
activeSpringAnimation.current.stop();
|
|
9165
|
+
}
|
|
9166
|
+
};
|
|
9167
|
+
React.useInsertionEffect(() => {
|
|
9154
9168
|
return value.attach((v, set) => {
|
|
9155
9169
|
/**
|
|
9156
9170
|
* A more hollistic approach to this might be to use isStatic to fix VisualElement animations
|
|
@@ -9158,9 +9172,7 @@ function useSpring(source, config = {}) {
|
|
|
9158
9172
|
*/
|
|
9159
9173
|
if (isStatic)
|
|
9160
9174
|
return set(v);
|
|
9161
|
-
|
|
9162
|
-
activeSpringAnimation.current.stop();
|
|
9163
|
-
}
|
|
9175
|
+
stopAnimation();
|
|
9164
9176
|
activeSpringAnimation.current = animate$1({
|
|
9165
9177
|
keyframes: [value.get(), v],
|
|
9166
9178
|
velocity: value.getVelocity(),
|
|
@@ -9169,7 +9181,7 @@ function useSpring(source, config = {}) {
|
|
|
9169
9181
|
onUpdate: set,
|
|
9170
9182
|
});
|
|
9171
9183
|
return value.get();
|
|
9172
|
-
});
|
|
9184
|
+
}, stopAnimation);
|
|
9173
9185
|
}, [JSON.stringify(config)]);
|
|
9174
9186
|
useIsomorphicLayoutEffect(() => {
|
|
9175
9187
|
if (isMotionValue(source)) {
|
|
@@ -20,12 +20,6 @@ const isPositionalKey = (key) => positionalKeys.has(key);
|
|
|
20
20
|
const hasPositionalKey = (target) => {
|
|
21
21
|
return Object.keys(target).some(isPositionalKey);
|
|
22
22
|
};
|
|
23
|
-
const setAndResetVelocity = (value, to) => {
|
|
24
|
-
// Looks odd but setting it twice doesn't render, it'll just
|
|
25
|
-
// set both prev and current to the latest value
|
|
26
|
-
value.set(to, false);
|
|
27
|
-
value.set(to);
|
|
28
|
-
};
|
|
29
23
|
const isNumOrPxType = (v) => v === number || v === px;
|
|
30
24
|
var BoundingBoxDimension;
|
|
31
25
|
(function (BoundingBoxDimension) {
|
|
@@ -106,7 +100,7 @@ const convertChangedValueTypes = (target, visualElement, changedKeys) => {
|
|
|
106
100
|
// Restore styles to their **calculated computed style**, not their actual
|
|
107
101
|
// originally set style. This allows us to animate between equivalent pixel units.
|
|
108
102
|
const value = visualElement.getValue(key);
|
|
109
|
-
|
|
103
|
+
value && value.jump(origin[key]);
|
|
110
104
|
target[key] = positionalValues[key](targetBbox, elementComputedStyle);
|
|
111
105
|
});
|
|
112
106
|
return target;
|
|
@@ -191,7 +185,7 @@ const checkAndConvertChangedValueTypes = (visualElement, target, origin = {}, tr
|
|
|
191
185
|
transitionEnd[key] !== undefined
|
|
192
186
|
? transitionEnd[key]
|
|
193
187
|
: target[key];
|
|
194
|
-
|
|
188
|
+
value.jump(to);
|
|
195
189
|
}
|
|
196
190
|
}
|
|
197
191
|
});
|
|
@@ -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.0
|
|
25
|
+
warnOnce(nextValue.version === "8.1.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.1.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.0
|
|
28
|
+
this.version = "8.1.0";
|
|
29
29
|
/**
|
|
30
30
|
* Duration, in milliseconds, since last updating frame.
|
|
31
31
|
*
|
|
@@ -178,8 +178,9 @@ class MotionValue {
|
|
|
178
178
|
*
|
|
179
179
|
* @internal
|
|
180
180
|
*/
|
|
181
|
-
attach(passiveEffect) {
|
|
181
|
+
attach(passiveEffect, stopPassiveEffect) {
|
|
182
182
|
this.passiveEffect = passiveEffect;
|
|
183
|
+
this.stopPassiveEffect = stopPassiveEffect;
|
|
183
184
|
}
|
|
184
185
|
/**
|
|
185
186
|
* Sets the state of the `MotionValue`.
|
|
@@ -209,6 +210,17 @@ class MotionValue {
|
|
|
209
210
|
this.prev = prev;
|
|
210
211
|
this.timeDelta = delta;
|
|
211
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Set the state of the `MotionValue`, stopping any active animations,
|
|
215
|
+
* effects, and resets velocity to `0`.
|
|
216
|
+
*/
|
|
217
|
+
jump(v) {
|
|
218
|
+
this.updateAndNotify(v);
|
|
219
|
+
this.prev = v;
|
|
220
|
+
this.stop();
|
|
221
|
+
if (this.stopPassiveEffect)
|
|
222
|
+
this.stopPassiveEffect();
|
|
223
|
+
}
|
|
212
224
|
/**
|
|
213
225
|
* Returns the latest state of `MotionValue`
|
|
214
226
|
*
|
|
@@ -304,6 +316,9 @@ class MotionValue {
|
|
|
304
316
|
destroy() {
|
|
305
317
|
this.clearListeners();
|
|
306
318
|
this.stop();
|
|
319
|
+
if (this.stopPassiveEffect) {
|
|
320
|
+
this.stopPassiveEffect();
|
|
321
|
+
}
|
|
307
322
|
}
|
|
308
323
|
}
|
|
309
324
|
function motionValue(init, options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, useRef,
|
|
1
|
+
import { useContext, useRef, useInsertionEffect } from 'react';
|
|
2
2
|
import { isMotionValue } from './utils/is-motion-value.mjs';
|
|
3
3
|
import { useMotionValue } from './use-motion-value.mjs';
|
|
4
4
|
import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
|
|
@@ -28,7 +28,12 @@ function useSpring(source, config = {}) {
|
|
|
28
28
|
const { isStatic } = useContext(MotionConfigContext);
|
|
29
29
|
const activeSpringAnimation = useRef(null);
|
|
30
30
|
const value = useMotionValue(isMotionValue(source) ? source.get() : source);
|
|
31
|
-
|
|
31
|
+
const stopAnimation = () => {
|
|
32
|
+
if (activeSpringAnimation.current) {
|
|
33
|
+
activeSpringAnimation.current.stop();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
useInsertionEffect(() => {
|
|
32
37
|
return value.attach((v, set) => {
|
|
33
38
|
/**
|
|
34
39
|
* A more hollistic approach to this might be to use isStatic to fix VisualElement animations
|
|
@@ -36,9 +41,7 @@ function useSpring(source, config = {}) {
|
|
|
36
41
|
*/
|
|
37
42
|
if (isStatic)
|
|
38
43
|
return set(v);
|
|
39
|
-
|
|
40
|
-
activeSpringAnimation.current.stop();
|
|
41
|
-
}
|
|
44
|
+
stopAnimation();
|
|
42
45
|
activeSpringAnimation.current = animate({
|
|
43
46
|
keyframes: [value.get(), v],
|
|
44
47
|
velocity: value.getVelocity(),
|
|
@@ -47,7 +50,7 @@ function useSpring(source, config = {}) {
|
|
|
47
50
|
onUpdate: set,
|
|
48
51
|
});
|
|
49
52
|
return value.get();
|
|
50
|
-
});
|
|
53
|
+
}, stopAnimation);
|
|
51
54
|
}, [JSON.stringify(config)]);
|
|
52
55
|
useIsomorphicLayoutEffect(() => {
|
|
53
56
|
if (isMotionValue(source)) {
|
|
@@ -2059,7 +2059,7 @@
|
|
|
2059
2059
|
* This will be replaced by the build step with the latest version number.
|
|
2060
2060
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2061
2061
|
*/
|
|
2062
|
-
this.version = "8.0
|
|
2062
|
+
this.version = "8.1.0";
|
|
2063
2063
|
/**
|
|
2064
2064
|
* Duration, in milliseconds, since last updating frame.
|
|
2065
2065
|
*
|
|
@@ -2212,8 +2212,9 @@
|
|
|
2212
2212
|
*
|
|
2213
2213
|
* @internal
|
|
2214
2214
|
*/
|
|
2215
|
-
attach(passiveEffect) {
|
|
2215
|
+
attach(passiveEffect, stopPassiveEffect) {
|
|
2216
2216
|
this.passiveEffect = passiveEffect;
|
|
2217
|
+
this.stopPassiveEffect = stopPassiveEffect;
|
|
2217
2218
|
}
|
|
2218
2219
|
/**
|
|
2219
2220
|
* Sets the state of the `MotionValue`.
|
|
@@ -2243,6 +2244,17 @@
|
|
|
2243
2244
|
this.prev = prev;
|
|
2244
2245
|
this.timeDelta = delta;
|
|
2245
2246
|
}
|
|
2247
|
+
/**
|
|
2248
|
+
* Set the state of the `MotionValue`, stopping any active animations,
|
|
2249
|
+
* effects, and resets velocity to `0`.
|
|
2250
|
+
*/
|
|
2251
|
+
jump(v) {
|
|
2252
|
+
this.updateAndNotify(v);
|
|
2253
|
+
this.prev = v;
|
|
2254
|
+
this.stop();
|
|
2255
|
+
if (this.stopPassiveEffect)
|
|
2256
|
+
this.stopPassiveEffect();
|
|
2257
|
+
}
|
|
2246
2258
|
/**
|
|
2247
2259
|
* Returns the latest state of `MotionValue`
|
|
2248
2260
|
*
|
|
@@ -2338,6 +2350,9 @@
|
|
|
2338
2350
|
destroy() {
|
|
2339
2351
|
this.clearListeners();
|
|
2340
2352
|
this.stop();
|
|
2353
|
+
if (this.stopPassiveEffect) {
|
|
2354
|
+
this.stopPassiveEffect();
|
|
2355
|
+
}
|
|
2341
2356
|
}
|
|
2342
2357
|
}
|
|
2343
2358
|
function motionValue(init, options) {
|
|
@@ -5624,12 +5639,6 @@
|
|
|
5624
5639
|
const hasPositionalKey = (target) => {
|
|
5625
5640
|
return Object.keys(target).some(isPositionalKey);
|
|
5626
5641
|
};
|
|
5627
|
-
const setAndResetVelocity = (value, to) => {
|
|
5628
|
-
// Looks odd but setting it twice doesn't render, it'll just
|
|
5629
|
-
// set both prev and current to the latest value
|
|
5630
|
-
value.set(to, false);
|
|
5631
|
-
value.set(to);
|
|
5632
|
-
};
|
|
5633
5642
|
const isNumOrPxType = (v) => v === number || v === px;
|
|
5634
5643
|
var BoundingBoxDimension;
|
|
5635
5644
|
(function (BoundingBoxDimension) {
|
|
@@ -5710,7 +5719,7 @@
|
|
|
5710
5719
|
// Restore styles to their **calculated computed style**, not their actual
|
|
5711
5720
|
// originally set style. This allows us to animate between equivalent pixel units.
|
|
5712
5721
|
const value = visualElement.getValue(key);
|
|
5713
|
-
|
|
5722
|
+
value && value.jump(origin[key]);
|
|
5714
5723
|
target[key] = positionalValues[key](targetBbox, elementComputedStyle);
|
|
5715
5724
|
});
|
|
5716
5725
|
return target;
|
|
@@ -5795,7 +5804,7 @@
|
|
|
5795
5804
|
transitionEnd[key] !== undefined
|
|
5796
5805
|
? transitionEnd[key]
|
|
5797
5806
|
: target[key];
|
|
5798
|
-
|
|
5807
|
+
value.jump(to);
|
|
5799
5808
|
}
|
|
5800
5809
|
}
|
|
5801
5810
|
});
|
|
@@ -5884,7 +5893,7 @@
|
|
|
5884
5893
|
* and warn against mismatches.
|
|
5885
5894
|
*/
|
|
5886
5895
|
{
|
|
5887
|
-
warnOnce(nextValue.version === "8.0
|
|
5896
|
+
warnOnce(nextValue.version === "8.1.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 8.1.0 may not work as expected.`);
|
|
5888
5897
|
}
|
|
5889
5898
|
}
|
|
5890
5899
|
else if (isMotionValue(prevValue)) {
|
|
@@ -9163,7 +9172,12 @@
|
|
|
9163
9172
|
const { isStatic } = React.useContext(MotionConfigContext);
|
|
9164
9173
|
const activeSpringAnimation = React.useRef(null);
|
|
9165
9174
|
const value = useMotionValue(isMotionValue(source) ? source.get() : source);
|
|
9166
|
-
|
|
9175
|
+
const stopAnimation = () => {
|
|
9176
|
+
if (activeSpringAnimation.current) {
|
|
9177
|
+
activeSpringAnimation.current.stop();
|
|
9178
|
+
}
|
|
9179
|
+
};
|
|
9180
|
+
React.useInsertionEffect(() => {
|
|
9167
9181
|
return value.attach((v, set) => {
|
|
9168
9182
|
/**
|
|
9169
9183
|
* A more hollistic approach to this might be to use isStatic to fix VisualElement animations
|
|
@@ -9171,9 +9185,7 @@
|
|
|
9171
9185
|
*/
|
|
9172
9186
|
if (isStatic)
|
|
9173
9187
|
return set(v);
|
|
9174
|
-
|
|
9175
|
-
activeSpringAnimation.current.stop();
|
|
9176
|
-
}
|
|
9188
|
+
stopAnimation();
|
|
9177
9189
|
activeSpringAnimation.current = animate$1({
|
|
9178
9190
|
keyframes: [value.get(), v],
|
|
9179
9191
|
velocity: value.getVelocity(),
|
|
@@ -9182,7 +9194,7 @@
|
|
|
9182
9194
|
onUpdate: set,
|
|
9183
9195
|
});
|
|
9184
9196
|
return value.get();
|
|
9185
|
-
});
|
|
9197
|
+
}, stopAnimation);
|
|
9186
9198
|
}, [JSON.stringify(config)]);
|
|
9187
9199
|
useIsomorphicLayoutEffect(() => {
|
|
9188
9200
|
if (isMotionValue(source)) {
|