framer-motion 6.5.1 → 7.0.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/README.md +14 -11
- package/dist/cjs/index.js +17 -11
- package/dist/es/context/MotionContext/create.mjs +1 -1
- package/dist/es/gestures/PanSession.mjs +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -1
- package/dist/es/gestures/drag/utils/constraints.mjs +1 -1
- package/dist/es/projection/animation/mix-values.mjs +2 -2
- package/dist/es/projection/node/create-projection-node.mjs +1 -1
- package/dist/es/render/dom/utils/unit-conversion.mjs +1 -1
- package/dist/es/render/html/visual-element.mjs +1 -1
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/utils/use-animation-frame.mjs +5 -7
- package/dist/es/value/index.mjs +1 -1
- package/dist/es/value/scroll/use-element-scroll.mjs +3 -0
- package/dist/es/value/scroll/use-viewport-scroll.mjs +3 -0
- package/dist/framer-motion.dev.js +326 -166
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +18 -2
- package/dist/projection.dev.js +295 -118
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -2
- package/dist/size-webpack-m.js +0 -1
- package/package.json +13 -18
- package/dist/size-webpack-dom-max.js.LICENSE.txt +0 -14
- package/dist/size-webpack-m.js.LICENSE.txt +0 -14
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://
|
|
2
|
+
<img src="https://framerusercontent.com/images/48ha9ZR9oZQGQ6gZ8YUfElP3T0A.png" width="50" height="50" alt="Framer Motion Icon" />
|
|
3
3
|
</p>
|
|
4
4
|
<h1 align="center">Framer Motion</h1>
|
|
5
5
|
<h3 align="center">
|
|
6
|
-
An open source
|
|
6
|
+
An open source motion library for React, <a href="https://www.framer.com">made by Framer</a>.
|
|
7
7
|
</h3>
|
|
8
8
|
|
|
9
9
|
<br>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
<br>
|
|
27
27
|
|
|
28
|
-
Framer Motion is an open source, production-ready library that
|
|
28
|
+
Framer Motion is an open source, production-ready library that’s designed for all creative developers.
|
|
29
29
|
|
|
30
30
|
It looks like this:
|
|
31
31
|
|
|
@@ -52,10 +52,14 @@ It does all this:
|
|
|
52
52
|
|
|
53
53
|
### 🐇 Quick start
|
|
54
54
|
|
|
55
|
+
Install `framer-motion` with via your package manager:
|
|
56
|
+
|
|
55
57
|
```
|
|
56
58
|
npm install framer-motion
|
|
57
59
|
```
|
|
58
60
|
|
|
61
|
+
Then import the `motion` component:
|
|
62
|
+
|
|
59
63
|
```jsx
|
|
60
64
|
import { motion } from "framer-motion"
|
|
61
65
|
|
|
@@ -66,18 +70,17 @@ export const MyComponent = ({ isVisible }) => (
|
|
|
66
70
|
|
|
67
71
|
### 📚 Docs
|
|
68
72
|
|
|
69
|
-
Check out [our documentation](https://www.framer.com/docs/) for guides and a full API reference.
|
|
70
|
-
|
|
71
|
-
Or checkout [our examples](https://www.framer.com/docs/examples/) for inspiration.
|
|
73
|
+
- Check out [our documentation](https://www.framer.com/docs/) for guides and a full API reference.
|
|
74
|
+
- Or see [our examples](https://www.framer.com/docs/examples/) for inspiration.
|
|
72
75
|
|
|
73
|
-
###
|
|
76
|
+
### 💎 Contribute
|
|
74
77
|
|
|
75
|
-
Want to contribute to Framer Motion? Our [contributing guide](https://github.com/framer/motion/blob/master/CONTRIBUTING.md) has you covered.
|
|
78
|
+
- Want to contribute to Framer Motion? Our [contributing guide](https://github.com/framer/motion/blob/master/CONTRIBUTING.md) has you covered.
|
|
76
79
|
|
|
77
80
|
### 👩🏻⚖️ License
|
|
78
81
|
|
|
79
|
-
Framer Motion is MIT licensed.
|
|
82
|
+
- Framer Motion is MIT licensed.
|
|
80
83
|
|
|
81
|
-
|
|
84
|
+
### ✨ Framer
|
|
82
85
|
|
|
83
|
-
|
|
86
|
+
- Design and publish sites that inspire. [Try Framer for free](https://www.framer.com/).
|
package/dist/cjs/index.js
CHANGED
|
@@ -2449,7 +2449,7 @@ var MotionValue = /** @class */ (function () {
|
|
|
2449
2449
|
* This will be replaced by the build step with the latest version number.
|
|
2450
2450
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2451
2451
|
*/
|
|
2452
|
-
this.version = "
|
|
2452
|
+
this.version = "7.0.0";
|
|
2453
2453
|
/**
|
|
2454
2454
|
* Duration, in milliseconds, since last updating frame.
|
|
2455
2455
|
*
|
|
@@ -3375,8 +3375,8 @@ var animations = {
|
|
|
3375
3375
|
*/
|
|
3376
3376
|
var PanSession = /** @class */ (function () {
|
|
3377
3377
|
function PanSession(event, handlers, _a) {
|
|
3378
|
-
var _this = this;
|
|
3379
3378
|
var _b = _a === void 0 ? {} : _a, transformPagePoint = _b.transformPagePoint;
|
|
3379
|
+
var _this = this;
|
|
3380
3380
|
/**
|
|
3381
3381
|
* @internal
|
|
3382
3382
|
*/
|
|
@@ -4247,7 +4247,7 @@ var VisualElementDragControls = /** @class */ (function () {
|
|
|
4247
4247
|
* If the element's layout changes, calculate the delta and apply that to
|
|
4248
4248
|
* the drag gesture's origin point.
|
|
4249
4249
|
*/
|
|
4250
|
-
projection.addEventListener("didUpdate", (function (_a) {
|
|
4250
|
+
var stopLayoutUpdateListener = projection.addEventListener("didUpdate", (function (_a) {
|
|
4251
4251
|
var delta = _a.delta, hasLayoutChanged = _a.hasLayoutChanged;
|
|
4252
4252
|
if (_this.isDragging && hasLayoutChanged) {
|
|
4253
4253
|
eachAxis(function (axis) {
|
|
@@ -4264,6 +4264,7 @@ var VisualElementDragControls = /** @class */ (function () {
|
|
|
4264
4264
|
stopResizeListener();
|
|
4265
4265
|
stopPointerListener();
|
|
4266
4266
|
stopMeasureLayoutListener();
|
|
4267
|
+
stopLayoutUpdateListener === null || stopLayoutUpdateListener === void 0 ? void 0 : stopLayoutUpdateListener();
|
|
4267
4268
|
};
|
|
4268
4269
|
};
|
|
4269
4270
|
VisualElementDragControls.prototype.getProps = function () {
|
|
@@ -4418,7 +4419,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
4418
4419
|
* and warn against mismatches.
|
|
4419
4420
|
*/
|
|
4420
4421
|
if (process.env.NODE_ENV === "development") {
|
|
4421
|
-
warnOnce(nextValue.version === "
|
|
4422
|
+
warnOnce(nextValue.version === "7.0.0", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 7.0.0 may not work as expected."));
|
|
4422
4423
|
}
|
|
4423
4424
|
}
|
|
4424
4425
|
else if (isMotionValue(prevValue)) {
|
|
@@ -5257,9 +5258,9 @@ var htmlConfig = {
|
|
|
5257
5258
|
* can be animated by Motion.
|
|
5258
5259
|
*/
|
|
5259
5260
|
makeTargetAnimatable: function (element, _a, _b, isMounted) {
|
|
5261
|
+
var transition = _a.transition, transitionEnd = _a.transitionEnd, target = tslib.__rest(_a, ["transition", "transitionEnd"]);
|
|
5260
5262
|
var transformValues = _b.transformValues;
|
|
5261
5263
|
if (isMounted === void 0) { isMounted = true; }
|
|
5262
|
-
var transition = _a.transition, transitionEnd = _a.transitionEnd, target = tslib.__rest(_a, ["transition", "transitionEnd"]);
|
|
5263
5264
|
var origin = getOrigin(target, transition || {}, element);
|
|
5264
5265
|
/**
|
|
5265
5266
|
* If Framer has provided a function to convert `Color` etc value types, convert them
|
|
@@ -5919,9 +5920,9 @@ function createProjectionNode(_a) {
|
|
|
5919
5920
|
var attachResizeListener = _a.attachResizeListener, defaultParent = _a.defaultParent, measureScroll = _a.measureScroll, checkIsScrollRoot = _a.checkIsScrollRoot, resetTransform = _a.resetTransform;
|
|
5920
5921
|
return /** @class */ (function () {
|
|
5921
5922
|
function ProjectionNode(id, latestValues, parent) {
|
|
5922
|
-
var _this = this;
|
|
5923
5923
|
if (latestValues === void 0) { latestValues = {}; }
|
|
5924
5924
|
if (parent === void 0) { parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent(); }
|
|
5925
|
+
var _this = this;
|
|
5925
5926
|
/**
|
|
5926
5927
|
* A Set containing all this component's children. This is used to iterate
|
|
5927
5928
|
* through the children.
|
|
@@ -7909,28 +7910,33 @@ function useScroll(_a) {
|
|
|
7909
7910
|
return values;
|
|
7910
7911
|
}
|
|
7911
7912
|
|
|
7913
|
+
/**
|
|
7914
|
+
* @deprecated useElementScroll is deprecated. Convert to useScroll({ container: ref })
|
|
7915
|
+
*/
|
|
7912
7916
|
function useElementScroll(ref) {
|
|
7913
7917
|
warnOnce(false, "useElementScroll is deprecated. Convert to useScroll({ container: ref }).");
|
|
7914
7918
|
return useScroll({ container: ref });
|
|
7915
7919
|
}
|
|
7916
7920
|
|
|
7921
|
+
/**
|
|
7922
|
+
* @deprecated useViewportScroll is deprecated. Convert to useScroll()
|
|
7923
|
+
*/
|
|
7917
7924
|
function useViewportScroll() {
|
|
7918
7925
|
warnOnce(false, "useViewportScroll is deprecated. Convert to useScroll().");
|
|
7919
7926
|
return useScroll();
|
|
7920
7927
|
}
|
|
7921
7928
|
|
|
7922
|
-
var getCurrentTime = typeof performance !== "undefined"
|
|
7923
|
-
? function () { return performance.now(); }
|
|
7924
|
-
: function () { return Date.now(); };
|
|
7925
7929
|
function useAnimationFrame(callback) {
|
|
7926
|
-
var initialTimestamp =
|
|
7930
|
+
var initialTimestamp = React.useRef(0);
|
|
7927
7931
|
var isStatic = React.useContext(MotionConfigContext).isStatic;
|
|
7928
7932
|
React.useEffect(function () {
|
|
7929
7933
|
if (isStatic)
|
|
7930
7934
|
return;
|
|
7931
7935
|
var provideTimeSinceStart = function (_a) {
|
|
7932
7936
|
var timestamp = _a.timestamp;
|
|
7933
|
-
|
|
7937
|
+
if (!initialTimestamp.current)
|
|
7938
|
+
initialTimestamp.current = timestamp;
|
|
7939
|
+
callback(timestamp - initialTimestamp.current);
|
|
7934
7940
|
};
|
|
7935
7941
|
sync__default["default"].update(provideTimeSinceStart, true);
|
|
7936
7942
|
return function () { return sync.cancelSync.update(provideTimeSinceStart); };
|
|
@@ -11,8 +11,8 @@ import { distance, pipe } from 'popmotion';
|
|
|
11
11
|
*/
|
|
12
12
|
var PanSession = /** @class */ (function () {
|
|
13
13
|
function PanSession(event, handlers, _a) {
|
|
14
|
-
var _this = this;
|
|
15
14
|
var _b = _a === void 0 ? {} : _a, transformPagePoint = _b.transformPagePoint;
|
|
15
|
+
var _this = this;
|
|
16
16
|
/**
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
@@ -394,7 +394,7 @@ var VisualElementDragControls = /** @class */ (function () {
|
|
|
394
394
|
* If the element's layout changes, calculate the delta and apply that to
|
|
395
395
|
* the drag gesture's origin point.
|
|
396
396
|
*/
|
|
397
|
-
projection.addEventListener("didUpdate", (function (_a) {
|
|
397
|
+
var stopLayoutUpdateListener = projection.addEventListener("didUpdate", (function (_a) {
|
|
398
398
|
var delta = _a.delta, hasLayoutChanged = _a.hasLayoutChanged;
|
|
399
399
|
if (_this.isDragging && hasLayoutChanged) {
|
|
400
400
|
eachAxis(function (axis) {
|
|
@@ -411,6 +411,7 @@ var VisualElementDragControls = /** @class */ (function () {
|
|
|
411
411
|
stopResizeListener();
|
|
412
412
|
stopPointerListener();
|
|
413
413
|
stopMeasureLayoutListener();
|
|
414
|
+
stopLayoutUpdateListener === null || stopLayoutUpdateListener === void 0 ? void 0 : stopLayoutUpdateListener();
|
|
414
415
|
};
|
|
415
416
|
};
|
|
416
417
|
VisualElementDragControls.prototype.getProps = function () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mix, progress,
|
|
2
|
-
import {
|
|
1
|
+
import { mix, progress, circOut, linear } from 'popmotion';
|
|
2
|
+
import { percent, px } from 'style-value-types';
|
|
3
3
|
|
|
4
4
|
var borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
|
|
5
5
|
var numBorders = borders.length;
|
|
@@ -30,9 +30,9 @@ function createProjectionNode(_a) {
|
|
|
30
30
|
var attachResizeListener = _a.attachResizeListener, defaultParent = _a.defaultParent, measureScroll = _a.measureScroll, checkIsScrollRoot = _a.checkIsScrollRoot, resetTransform = _a.resetTransform;
|
|
31
31
|
return /** @class */ (function () {
|
|
32
32
|
function ProjectionNode(id, latestValues, parent) {
|
|
33
|
-
var _this = this;
|
|
34
33
|
if (latestValues === void 0) { latestValues = {}; }
|
|
35
34
|
if (parent === void 0) { parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent(); }
|
|
35
|
+
var _this = this;
|
|
36
36
|
/**
|
|
37
37
|
* A Set containing all this component's children. This is used to iterate
|
|
38
38
|
* through the children.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __read } from 'tslib';
|
|
2
|
-
import {
|
|
2
|
+
import { px, number } from 'style-value-types';
|
|
3
3
|
import { isKeyframesTarget } from '../../../animation/utils/is-keyframes-target.mjs';
|
|
4
4
|
import { invariant } from 'hey-listen';
|
|
5
5
|
import { transformProps } from '../../html/utils/transform.mjs';
|
|
@@ -71,9 +71,9 @@ var htmlConfig = {
|
|
|
71
71
|
* can be animated by Motion.
|
|
72
72
|
*/
|
|
73
73
|
makeTargetAnimatable: function (element, _a, _b, isMounted) {
|
|
74
|
+
var transition = _a.transition, transitionEnd = _a.transitionEnd, target = __rest(_a, ["transition", "transitionEnd"]);
|
|
74
75
|
var transformValues = _b.transformValues;
|
|
75
76
|
if (isMounted === void 0) { isMounted = true; }
|
|
76
|
-
var transition = _a.transition, transitionEnd = _a.transitionEnd, target = __rest(_a, ["transition", "transitionEnd"]);
|
|
77
77
|
var origin = getOrigin(target, transition || {}, element);
|
|
78
78
|
/**
|
|
79
79
|
* If Framer has provided a function to convert `Color` etc value types, convert them
|
|
@@ -18,7 +18,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
18
18
|
* and warn against mismatches.
|
|
19
19
|
*/
|
|
20
20
|
if (process.env.NODE_ENV === "development") {
|
|
21
|
-
warnOnce(nextValue.version === "
|
|
21
|
+
warnOnce(nextValue.version === "7.0.0", "Attempting to mix Framer Motion versions ".concat(nextValue.version, " with 7.0.0 may not work as expected."));
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
else if (isMotionValue(prevValue)) {
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import sync, { cancelSync } from 'framesync';
|
|
2
|
-
import { useContext, useEffect } from 'react';
|
|
3
|
-
import { useConstant } from './use-constant.mjs';
|
|
2
|
+
import { useRef, useContext, useEffect } from 'react';
|
|
4
3
|
import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
|
|
5
4
|
|
|
6
|
-
var getCurrentTime = typeof performance !== "undefined"
|
|
7
|
-
? function () { return performance.now(); }
|
|
8
|
-
: function () { return Date.now(); };
|
|
9
5
|
function useAnimationFrame(callback) {
|
|
10
|
-
var initialTimestamp =
|
|
6
|
+
var initialTimestamp = useRef(0);
|
|
11
7
|
var isStatic = useContext(MotionConfigContext).isStatic;
|
|
12
8
|
useEffect(function () {
|
|
13
9
|
if (isStatic)
|
|
14
10
|
return;
|
|
15
11
|
var provideTimeSinceStart = function (_a) {
|
|
16
12
|
var timestamp = _a.timestamp;
|
|
17
|
-
|
|
13
|
+
if (!initialTimestamp.current)
|
|
14
|
+
initialTimestamp.current = timestamp;
|
|
15
|
+
callback(timestamp - initialTimestamp.current);
|
|
18
16
|
};
|
|
19
17
|
sync.update(provideTimeSinceStart, true);
|
|
20
18
|
return function () { return cancelSync.update(provideTimeSinceStart); };
|
package/dist/es/value/index.mjs
CHANGED
|
@@ -25,7 +25,7 @@ var MotionValue = /** @class */ (function () {
|
|
|
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 = "
|
|
28
|
+
this.version = "7.0.0";
|
|
29
29
|
/**
|
|
30
30
|
* Duration, in milliseconds, since last updating frame.
|
|
31
31
|
*
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { warnOnce } from '../../utils/warn-once.mjs';
|
|
2
2
|
import { useScroll } from '../use-scroll.mjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated useElementScroll is deprecated. Convert to useScroll({ container: ref })
|
|
6
|
+
*/
|
|
4
7
|
function useElementScroll(ref) {
|
|
5
8
|
warnOnce(false, "useElementScroll is deprecated. Convert to useScroll({ container: ref }).");
|
|
6
9
|
return useScroll({ container: ref });
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { warnOnce } from '../../utils/warn-once.mjs';
|
|
2
2
|
import { useScroll } from '../use-scroll.mjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated useViewportScroll is deprecated. Convert to useScroll()
|
|
6
|
+
*/
|
|
4
7
|
function useViewportScroll() {
|
|
5
8
|
warnOnce(false, "useViewportScroll is deprecated. Convert to useScroll().");
|
|
6
9
|
return useScroll();
|