framer-motion 12.20.2 → 12.20.3

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 CHANGED
@@ -2,6 +2,10 @@
2
2
  <img width="100" height="100" 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/motiondotdev" target="_blank">
16
- <img src="https://img.shields.io/twitter/follow/framer.svg?style=social&label=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
- Install `motion` via your package manager:
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
- export function Component({ isVisible }) {
67
- return <motion.div animate={{ opacity: isVisible ? 1 : 0 }} />
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
+ ![Video of bezier curve editing](https://framerusercontent.com/images/KO5dnHOUSNGb9S73p1J7nLhoFI.gif)
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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var create = require('./create-C4jfsA_8.js');
5
+ var create = require('./create-ByDLj_LU.js');
6
6
  require('motion-dom');
7
7
  require('motion-utils');
8
8
  require('react/jsx-runtime');
@@ -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
- this.animationCommitId = this.animationId;
1330
- this.isUpdating = false;
1331
- /**
1332
- * Write
1333
- */
1334
- this.nodes.forEach(resetTransformStyle);
1335
- /**
1336
- * Read ==================
1337
- */
1338
- // Update layout measurements of updated children
1339
- this.nodes.forEach(updateLayout);
1340
- /**
1341
- * Write
1342
- */
1343
- // Notify listeners that the layout is updated
1344
- this.nodes.forEach(notifyLayoutUpdate);
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) {
@@ -5093,6 +5094,11 @@ class PanGesture extends Feature {
5093
5094
  */
5094
5095
  const SwitchLayoutGroupContext = React.createContext({});
5095
5096
 
5097
+ /**
5098
+ * Track whether we've taken any snapshots yet. If not,
5099
+ * we can safely skip notification of didUpdate.
5100
+ */
5101
+ let hasTakenAnySnapshot = false;
5096
5102
  class MeasureLayoutWithContext extends React.Component {
5097
5103
  /**
5098
5104
  * This only mounts projection nodes for components that
@@ -5109,7 +5115,9 @@ class MeasureLayoutWithContext extends React.Component {
5109
5115
  if (switchLayoutGroup && switchLayoutGroup.register && layoutId) {
5110
5116
  switchLayoutGroup.register(projection);
5111
5117
  }
5112
- projection.root.didUpdate();
5118
+ if (hasTakenAnySnapshot) {
5119
+ projection.root.didUpdate();
5120
+ }
5113
5121
  projection.addEventListener("animationComplete", () => {
5114
5122
  this.safeToRemove();
5115
5123
  });
@@ -5133,6 +5141,7 @@ class MeasureLayoutWithContext extends React.Component {
5133
5141
  * perhaps in didUpdate
5134
5142
  */
5135
5143
  projection.isPresent = isPresent;
5144
+ hasTakenAnySnapshot = true;
5136
5145
  if (drag ||
5137
5146
  prevProps.layoutDependency !== layoutDependency ||
5138
5147
  layoutDependency === undefined ||
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-C4jfsA_8.js');
7
+ var create = require('./create-ByDLj_LU.js');
8
8
  var motionDom = require('motion-dom');
9
9
  var motionUtils = require('motion-utils');
10
10
 
@@ -10,6 +10,11 @@ import { correctBorderRadius } from '../../../projection/styles/scale-border-rad
10
10
  import { correctBoxShadow } from '../../../projection/styles/scale-box-shadow.mjs';
11
11
  import { addScaleCorrector } from '../../../projection/styles/scale-correction.mjs';
12
12
 
13
+ /**
14
+ * Track whether we've taken any snapshots yet. If not,
15
+ * we can safely skip notification of didUpdate.
16
+ */
17
+ let hasTakenAnySnapshot = false;
13
18
  class MeasureLayoutWithContext extends Component {
14
19
  /**
15
20
  * This only mounts projection nodes for components that
@@ -26,7 +31,9 @@ class MeasureLayoutWithContext extends Component {
26
31
  if (switchLayoutGroup && switchLayoutGroup.register && layoutId) {
27
32
  switchLayoutGroup.register(projection);
28
33
  }
29
- projection.root.didUpdate();
34
+ if (hasTakenAnySnapshot) {
35
+ projection.root.didUpdate();
36
+ }
30
37
  projection.addEventListener("animationComplete", () => {
31
38
  this.safeToRemove();
32
39
  });
@@ -50,6 +57,7 @@ class MeasureLayoutWithContext extends Component {
50
57
  * perhaps in didUpdate
51
58
  */
52
59
  projection.isPresent = isPresent;
60
+ hasTakenAnySnapshot = true;
53
61
  if (drag ||
54
62
  prevProps.layoutDependency !== layoutDependency ||
55
63
  layoutDependency === undefined ||
@@ -437,25 +437,27 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
437
437
  this.nodes.forEach(clearIsLayoutDirty);
438
438
  return;
439
439
  }
440
+ this.animationCommitId = this.animationId;
440
441
  if (!this.isUpdating) {
441
442
  this.nodes.forEach(clearIsLayoutDirty);
442
443
  }
443
- this.animationCommitId = this.animationId;
444
- this.isUpdating = false;
445
- /**
446
- * Write
447
- */
448
- this.nodes.forEach(resetTransformStyle);
449
- /**
450
- * Read ==================
451
- */
452
- // Update layout measurements of updated children
453
- this.nodes.forEach(updateLayout);
454
- /**
455
- * Write
456
- */
457
- // Notify listeners that the layout is updated
458
- this.nodes.forEach(notifyLayoutUpdate);
444
+ else {
445
+ this.isUpdating = false;
446
+ /**
447
+ * Write
448
+ */
449
+ this.nodes.forEach(resetTransformStyle);
450
+ /**
451
+ * Read ==================
452
+ */
453
+ // Update layout measurements of updated children
454
+ this.nodes.forEach(updateLayout);
455
+ /**
456
+ * Write
457
+ */
458
+ // Notify listeners that the layout is updated
459
+ this.nodes.forEach(notifyLayoutUpdate);
460
+ }
459
461
  this.clearAllSnapshots();
460
462
  /**
461
463
  * Manually flush any pending updates. Ideally
@@ -518,7 +520,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
518
520
  updateLayout() {
519
521
  if (!this.instance)
520
522
  return;
521
- // TODO: Incorporate into a forwarded scroll offset
522
523
  this.updateScroll();
523
524
  if (!(this.options.alwaysMeasureLayout && this.isLead()) &&
524
525
  !this.isLayoutDirty) {
@@ -6612,25 +6612,27 @@
6612
6612
  this.nodes.forEach(clearIsLayoutDirty);
6613
6613
  return;
6614
6614
  }
6615
+ this.animationCommitId = this.animationId;
6615
6616
  if (!this.isUpdating) {
6616
6617
  this.nodes.forEach(clearIsLayoutDirty);
6617
6618
  }
6618
- this.animationCommitId = this.animationId;
6619
- this.isUpdating = false;
6620
- /**
6621
- * Write
6622
- */
6623
- this.nodes.forEach(resetTransformStyle);
6624
- /**
6625
- * Read ==================
6626
- */
6627
- // Update layout measurements of updated children
6628
- this.nodes.forEach(updateLayout);
6629
- /**
6630
- * Write
6631
- */
6632
- // Notify listeners that the layout is updated
6633
- this.nodes.forEach(notifyLayoutUpdate);
6619
+ else {
6620
+ this.isUpdating = false;
6621
+ /**
6622
+ * Write
6623
+ */
6624
+ this.nodes.forEach(resetTransformStyle);
6625
+ /**
6626
+ * Read ==================
6627
+ */
6628
+ // Update layout measurements of updated children
6629
+ this.nodes.forEach(updateLayout);
6630
+ /**
6631
+ * Write
6632
+ */
6633
+ // Notify listeners that the layout is updated
6634
+ this.nodes.forEach(notifyLayoutUpdate);
6635
+ }
6634
6636
  this.clearAllSnapshots();
6635
6637
  /**
6636
6638
  * Manually flush any pending updates. Ideally
@@ -6693,7 +6695,6 @@
6693
6695
  updateLayout() {
6694
6696
  if (!this.instance)
6695
6697
  return;
6696
- // TODO: Incorporate into a forwarded scroll offset
6697
6698
  this.updateScroll();
6698
6699
  if (!(this.options.alwaysMeasureLayout && this.isLead()) &&
6699
6700
  !this.isLayoutDirty) {
@@ -10568,6 +10569,11 @@
10568
10569
  */
10569
10570
  const SwitchLayoutGroupContext = React$1.createContext({});
10570
10571
 
10572
+ /**
10573
+ * Track whether we've taken any snapshots yet. If not,
10574
+ * we can safely skip notification of didUpdate.
10575
+ */
10576
+ let hasTakenAnySnapshot = false;
10571
10577
  class MeasureLayoutWithContext extends React$1.Component {
10572
10578
  /**
10573
10579
  * This only mounts projection nodes for components that
@@ -10584,7 +10590,9 @@
10584
10590
  if (switchLayoutGroup && switchLayoutGroup.register && layoutId) {
10585
10591
  switchLayoutGroup.register(projection);
10586
10592
  }
10587
- projection.root.didUpdate();
10593
+ if (hasTakenAnySnapshot) {
10594
+ projection.root.didUpdate();
10595
+ }
10588
10596
  projection.addEventListener("animationComplete", () => {
10589
10597
  this.safeToRemove();
10590
10598
  });
@@ -10608,6 +10616,7 @@
10608
10616
  * perhaps in didUpdate
10609
10617
  */
10610
10618
  projection.isPresent = isPresent;
10619
+ hasTakenAnySnapshot = true;
10611
10620
  if (drag ||
10612
10621
  prevProps.layoutDependency !== layoutDependency ||
10613
10622
  layoutDependency === undefined ||