framer-motion 12.20.2 → 12.20.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/README.md +39 -12
- package/dist/cjs/client.js +1 -1
- package/dist/cjs/{create-C4jfsA_8.js → create-7q3QlJ1Z.js} +42 -23
- package/dist/cjs/dom.js +15 -5
- package/dist/cjs/index.js +1 -1
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +1 -1
- package/dist/es/motion/features/layout/MeasureLayout.mjs +9 -1
- package/dist/es/projection/node/create-projection-node.mjs +18 -17
- package/dist/es/render/html/utils/render.mjs +14 -4
- package/dist/es/utils/reduced-motion/index.mjs +1 -1
- package/dist/framer-motion.dev.js +42 -23
- package/dist/framer-motion.js +1 -1
- package/dist/m.d.ts +14 -5
- package/dist/size-rollup-animate.js +1 -1
- 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/types/client.d.ts +1 -1
- package/dist/types/index.d.ts +8 -8
- package/dist/{types.d-BSoEx4Ea.d.ts → types.d-GIAd6Xhe.d.ts} +26 -17
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img width="
|
|
2
|
+
<img width="42" height="42" alt="Motion logo" src="https://github.com/user-attachments/assets/00d6d1c3-72c4-4c2f-a664-69da13182ffc" />
|
|
3
3
|
</p>
|
|
4
4
|
<h1 align="center">Motion for React</h1>
|
|
5
|
+
<h3 align="center">
|
|
6
|
+
An open source, production-ready animation library
|
|
7
|
+
</h3>
|
|
8
|
+
<p align="center">Previously Framer Motion. Also available for <a href="https://github.com/motiondivision/motion/tree/main/packages/motion">JavaScript</a> and <a href="https://github.com/motiondivision/motion-vue">Vue</a></p>
|
|
5
9
|
|
|
6
10
|
<br>
|
|
7
11
|
|
|
@@ -12,13 +16,11 @@
|
|
|
12
16
|
<a href="https://www.npmjs.com/package/framer-motion" target="_blank">
|
|
13
17
|
<img src="https://img.shields.io/npm/dm/framer-motion.svg?style=flat-square" />
|
|
14
18
|
</a>
|
|
15
|
-
<a href="https://twitter.com/
|
|
16
|
-
<img src="https://img.shields.io/twitter/follow/
|
|
19
|
+
<a href="https://twitter.com/mattgperry" target="_blank">
|
|
20
|
+
<img src="https://img.shields.io/twitter/follow/mattgperry.svg?style=social&label=Follow" />
|
|
17
21
|
</a>
|
|
18
22
|
</p>
|
|
19
23
|
|
|
20
|
-
<br>
|
|
21
|
-
<hr>
|
|
22
24
|
<br>
|
|
23
25
|
|
|
24
26
|
Motion for React is an open source, production-ready library that’s designed for all creative developers.
|
|
@@ -52,22 +54,47 @@ It does all this:
|
|
|
52
54
|
|
|
53
55
|
### 🐇 Quick start
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```
|
|
57
|
+
```bash
|
|
58
58
|
npm install motion
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
Then import the `motion` component:
|
|
62
|
-
|
|
63
61
|
```jsx
|
|
64
62
|
import { motion } from "motion/react"
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
return <motion.div animate={{
|
|
64
|
+
function Component() {
|
|
65
|
+
return <motion.div animate={{ x: 100 }} />
|
|
68
66
|
}
|
|
69
67
|
```
|
|
70
68
|
|
|
69
|
+
Get started with [Motion for React](https://motion.dev/docs/react-quick-start).
|
|
70
|
+
|
|
71
|
+
## 🎨 Studio
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
Motion Studio is a versatile suite of developer tools allowing you to:
|
|
76
|
+
|
|
77
|
+
- Visually edit CSS and Motion easing curves in VS Code
|
|
78
|
+
- Generate CSS springs with LLMs
|
|
79
|
+
- Load Motion docs into your LLM
|
|
80
|
+
|
|
81
|
+
Get started with [Motion Studio](https://motion.dev/docs/tools-quick-start).
|
|
82
|
+
|
|
83
|
+
## 🎓 Examples
|
|
84
|
+
|
|
85
|
+
[Motion Examples](https://examples.motion.dev/react) offers 100s of free and Motion+ examples for beginners and advanced users alike. Easy copy/paste code to kickstart your next project.
|
|
86
|
+
|
|
87
|
+
## ⚡️ Motion+
|
|
88
|
+
|
|
89
|
+
[Motion+](https://motion.dev/plus) is a one-time fee, lifetime membership that unlocks over 100 premium examples, early access, powerful Studio tools, a private Discord, and exclusive APIs like:
|
|
90
|
+
|
|
91
|
+
- Cursor
|
|
92
|
+
- Ticker
|
|
93
|
+
- AnimateNumber
|
|
94
|
+
- splitText
|
|
95
|
+
|
|
96
|
+
[Get Motion+](https://motion.dev/plus)
|
|
97
|
+
|
|
71
98
|
### 💎 Contribute
|
|
72
99
|
|
|
73
100
|
- Want to contribute to Motion? Our [contributing guide](https://github.com/motiondivision/motion/blob/master/CONTRIBUTING.md) has you covered.
|
package/dist/cjs/client.js
CHANGED
|
@@ -1323,25 +1323,27 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
1323
1323
|
this.nodes.forEach(clearIsLayoutDirty);
|
|
1324
1324
|
return;
|
|
1325
1325
|
}
|
|
1326
|
+
this.animationCommitId = this.animationId;
|
|
1326
1327
|
if (!this.isUpdating) {
|
|
1327
1328
|
this.nodes.forEach(clearIsLayoutDirty);
|
|
1328
1329
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1330
|
+
else {
|
|
1331
|
+
this.isUpdating = false;
|
|
1332
|
+
/**
|
|
1333
|
+
* Write
|
|
1334
|
+
*/
|
|
1335
|
+
this.nodes.forEach(resetTransformStyle);
|
|
1336
|
+
/**
|
|
1337
|
+
* Read ==================
|
|
1338
|
+
*/
|
|
1339
|
+
// Update layout measurements of updated children
|
|
1340
|
+
this.nodes.forEach(updateLayout);
|
|
1341
|
+
/**
|
|
1342
|
+
* Write
|
|
1343
|
+
*/
|
|
1344
|
+
// Notify listeners that the layout is updated
|
|
1345
|
+
this.nodes.forEach(notifyLayoutUpdate);
|
|
1346
|
+
}
|
|
1345
1347
|
this.clearAllSnapshots();
|
|
1346
1348
|
/**
|
|
1347
1349
|
* Manually flush any pending updates. Ideally
|
|
@@ -1404,7 +1406,6 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
1404
1406
|
updateLayout() {
|
|
1405
1407
|
if (!this.instance)
|
|
1406
1408
|
return;
|
|
1407
|
-
// TODO: Incorporate into a forwarded scroll offset
|
|
1408
1409
|
this.updateScroll();
|
|
1409
1410
|
if (!(this.options.alwaysMeasureLayout && this.isLead()) &&
|
|
1410
1411
|
!this.isLayoutDirty) {
|
|
@@ -2675,7 +2676,7 @@ function initPrefersReducedMotion() {
|
|
|
2675
2676
|
if (window.matchMedia) {
|
|
2676
2677
|
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
2677
2678
|
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
|
|
2678
|
-
motionMediaQuery.
|
|
2679
|
+
motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
|
|
2679
2680
|
setReducedMotionPreferences();
|
|
2680
2681
|
}
|
|
2681
2682
|
else {
|
|
@@ -3408,10 +3409,20 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
|
3408
3409
|
}
|
|
3409
3410
|
|
|
3410
3411
|
function renderHTML(element, { style, vars }, styleProp, projection) {
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
for (
|
|
3414
|
-
|
|
3412
|
+
const elementStyle = element.style;
|
|
3413
|
+
let key;
|
|
3414
|
+
for (key in style) {
|
|
3415
|
+
// CSSStyleDeclaration has [index: number]: string; in the types, so we use that as key type.
|
|
3416
|
+
elementStyle[key] = style[key];
|
|
3417
|
+
}
|
|
3418
|
+
const projectionStyle = projection?.getProjectionStyles(styleProp);
|
|
3419
|
+
for (key in projectionStyle) {
|
|
3420
|
+
elementStyle[key] = projectionStyle[key];
|
|
3421
|
+
}
|
|
3422
|
+
for (key in vars) {
|
|
3423
|
+
// Loop over any CSS variables and assign those.
|
|
3424
|
+
// They can only be assigned using `setProperty`.
|
|
3425
|
+
elementStyle.setProperty(key, vars[key]);
|
|
3415
3426
|
}
|
|
3416
3427
|
}
|
|
3417
3428
|
|
|
@@ -5093,6 +5104,11 @@ class PanGesture extends Feature {
|
|
|
5093
5104
|
*/
|
|
5094
5105
|
const SwitchLayoutGroupContext = React.createContext({});
|
|
5095
5106
|
|
|
5107
|
+
/**
|
|
5108
|
+
* Track whether we've taken any snapshots yet. If not,
|
|
5109
|
+
* we can safely skip notification of didUpdate.
|
|
5110
|
+
*/
|
|
5111
|
+
let hasTakenAnySnapshot = false;
|
|
5096
5112
|
class MeasureLayoutWithContext extends React.Component {
|
|
5097
5113
|
/**
|
|
5098
5114
|
* This only mounts projection nodes for components that
|
|
@@ -5109,7 +5125,9 @@ class MeasureLayoutWithContext extends React.Component {
|
|
|
5109
5125
|
if (switchLayoutGroup && switchLayoutGroup.register && layoutId) {
|
|
5110
5126
|
switchLayoutGroup.register(projection);
|
|
5111
5127
|
}
|
|
5112
|
-
|
|
5128
|
+
if (hasTakenAnySnapshot) {
|
|
5129
|
+
projection.root.didUpdate();
|
|
5130
|
+
}
|
|
5113
5131
|
projection.addEventListener("animationComplete", () => {
|
|
5114
5132
|
this.safeToRemove();
|
|
5115
5133
|
});
|
|
@@ -5133,6 +5151,7 @@ class MeasureLayoutWithContext extends React.Component {
|
|
|
5133
5151
|
* perhaps in didUpdate
|
|
5134
5152
|
*/
|
|
5135
5153
|
projection.isPresent = isPresent;
|
|
5154
|
+
hasTakenAnySnapshot = true;
|
|
5136
5155
|
if (drag ||
|
|
5137
5156
|
prevProps.layoutDependency !== layoutDependency ||
|
|
5138
5157
|
layoutDependency === undefined ||
|
package/dist/cjs/dom.js
CHANGED
|
@@ -747,7 +747,7 @@ function initPrefersReducedMotion() {
|
|
|
747
747
|
if (window.matchMedia) {
|
|
748
748
|
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
749
749
|
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
|
|
750
|
-
motionMediaQuery.
|
|
750
|
+
motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
|
|
751
751
|
setReducedMotionPreferences();
|
|
752
752
|
}
|
|
753
753
|
else {
|
|
@@ -1443,10 +1443,20 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
|
1443
1443
|
}
|
|
1444
1444
|
|
|
1445
1445
|
function renderHTML(element, { style, vars }, styleProp, projection) {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
for (
|
|
1449
|
-
|
|
1446
|
+
const elementStyle = element.style;
|
|
1447
|
+
let key;
|
|
1448
|
+
for (key in style) {
|
|
1449
|
+
// CSSStyleDeclaration has [index: number]: string; in the types, so we use that as key type.
|
|
1450
|
+
elementStyle[key] = style[key];
|
|
1451
|
+
}
|
|
1452
|
+
const projectionStyle = projection?.getProjectionStyles(styleProp);
|
|
1453
|
+
for (key in projectionStyle) {
|
|
1454
|
+
elementStyle[key] = projectionStyle[key];
|
|
1455
|
+
}
|
|
1456
|
+
for (key in vars) {
|
|
1457
|
+
// Loop over any CSS variables and assign those.
|
|
1458
|
+
// They can only be assigned using `setProperty`.
|
|
1459
|
+
elementStyle.setProperty(key, vars[key]);
|
|
1450
1460
|
}
|
|
1451
1461
|
}
|
|
1452
1462
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var create = require('./create-
|
|
7
|
+
var create = require('./create-7q3QlJ1Z.js');
|
|
8
8
|
var motionDom = require('motion-dom');
|
|
9
9
|
var motionUtils = require('motion-utils');
|
|
10
10
|
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UnresolvedValueKeyframe, MotionValue, Transition, ElementOrSelector, DOMKeyframesDefinition, AnimationOptions, AnimationPlaybackOptions, AnimationScope, AnimationPlaybackControlsWithThen, ValueAnimationTransition, AnimationPlaybackControls, DynamicOption } from 'motion-dom';
|
|
1
|
+
import { UnresolvedValueKeyframe, MotionValue, Transition, ElementOrSelector, DOMKeyframesDefinition, AnimationOptions, AnimationPlaybackOptions, AnyResolvedKeyframe, AnimationScope, AnimationPlaybackControlsWithThen, ValueAnimationTransition, AnimationPlaybackControls, DynamicOption } from 'motion-dom';
|
|
2
2
|
export * from 'motion-dom';
|
|
3
3
|
import { Easing, EasingFunction, Point } from 'motion-utils';
|
|
4
4
|
export * from 'motion-utils';
|
|
@@ -44,7 +44,7 @@ interface SequenceOptions extends AnimationPlaybackOptions {
|
|
|
44
44
|
defaultTransition?: Transition;
|
|
45
45
|
}
|
|
46
46
|
interface AbsoluteKeyframe {
|
|
47
|
-
value:
|
|
47
|
+
value: AnyResolvedKeyframe | null;
|
|
48
48
|
at: number;
|
|
49
49
|
easing?: Easing;
|
|
50
50
|
}
|