framer-motion 12.23.10 → 12.23.12

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
@@ -1,62 +1,46 @@
1
- <p align="center">
2
- <img width="42" height="42" alt="Motion logo" src="https://github.com/user-attachments/assets/00d6d1c3-72c4-4c2f-a664-69da13182ffc" />
3
- </p>
4
- <h1 align="center">Motion for React</h1>
1
+
2
+ <h1 align="center"> <img width="35" height="35" alt="Motion logo" src="https://github.com/user-attachments/assets/00d6d1c3-72c4-4c2f-a664-69da13182ffc" /><br />Motion for React</h1>
5
3
  <h3 align="center">
6
- An open source, production-ready animation library
4
+ An open source animation library<br />for React
7
5
  </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>
9
-
10
- <br>
11
6
 
12
7
  <p align="center">
13
- <a href="https://www.npmjs.com/package/framer-motion" target="_blank">
14
- <img src="https://img.shields.io/npm/v/framer-motion.svg?style=flat-square" />
15
- </a>
16
- <a href="https://www.npmjs.com/package/framer-motion" target="_blank">
17
- <img src="https://img.shields.io/npm/dm/framer-motion.svg?style=flat-square" />
18
- </a>
19
- <a href="https://twitter.com/mattgperry" target="_blank">
20
- <img src="https://img.shields.io/twitter/follow/mattgperry.svg?style=social&label=Follow" />
21
- </a>
8
+ <a href="https://www.npmjs.com/package/motion" rel="noopener noreferrer nofollow" ><img src="https://img.shields.io/npm/v/motion?color=0368FF&label=version" alt="npm version"></a>
9
+ <a href="https://www.npmjs.com/package/motion" rel="noopener noreferrer nofollow" ><img src="https://img.shields.io/npm/dm/framer-motion?color=8D30FF&label=npm" alt="npm downloads per month"></a>
10
+ <a target="_blank" rel="noopener noreferrer nofollow" href="https://www.jsdelivr.com/package/npm/motion"><img alt="jsDelivr hits (npm)" src="https://img.shields.io/jsdelivr/npm/hm/framer-motion?logo=jsdeliver&color=FF4FBA"></a>
11
+ <img alt="NPM License" src="https://img.shields.io/npm/l/motion?color=FF2B6E">
22
12
  </p>
23
13
 
24
- <br>
25
-
26
- Motion for React is an open source, production-ready library that’s designed for all creative developers.
27
14
 
28
- It's the only animation library with a hybrid engine, combining the power of JavaScript animations with the performance of native browser APIs.
15
+ ```bash
16
+ npm install motion
17
+ ```
29
18
 
30
- It looks like this:
19
+ ## Table of Contents
31
20
 
32
- ```jsx
33
- <motion.div animate={{ x: 0 }} />
34
- ```
21
+ 1. [Why Motion?](#why-motion)
22
+ 2. [🍦 Flavours](#-flavours)
23
+ 3. [🎓 Examples](#-examples)
24
+ 4. [🎨 Studio](#-studio)
25
+ 5. [⚡️ Motion+](#-motion)
26
+ 6. [👩🏻‍⚖️ License](#-license)
27
+ 7. [💎 Contribute](#-contribute)
28
+ 8. [✨ Sponsors](#-sponsors)
35
29
 
36
- It does all this:
30
+ ## Why Motion?
37
31
 
38
- - [Springs](https://motion.dev/docs/react-transitions#spring)
39
- - [Keyframes](https://motion.dev/docs/react-animation#keyframes)
40
- - [Layout animations](https://motion.dev/docs/react-layout-animations)
41
- - [Shared layout animations](https://motion.dev/docs/react-layout-animations#shared-layout-animations)
42
- - [Gestures (drag/tap/hover)](https://motion.dev/docs/react-gestures)
43
- - [Scroll animations](https://motion.dev/docs/react-scroll-animations)
44
- - [SVG paths](https://motion.dev/docs/react-animation#svg-line-drawing)
45
- - [Exit animations](https://motion.dev/docs/react-animation#exit-animations)
46
- - [Server-side rendering](https://motion.dev/docs/react-motion-component#server-side-rendering)
47
- - [Independent transforms](https://motion.dev/docs/react-motion-component#style)
48
- - [Orchestrate animations across components](https://motion.dev/docs/react-animation#orchestration)
49
- - [CSS variables](https://motion.dev/docs/react-animation#css-variables)
32
+ Motion is an animation library for making beautiful animations.
50
33
 
51
- ...and a whole lot more.
34
+ * The **only** library with first‑class APIs for React, JavaScript, **and** Vue.
35
+ * Powered by a **hybrid engine** that blends JavaScript flexibility with native browser APIs for **120fps GPU‑accelerated** motion.
36
+ * Tiny footprint, tree‑shakable, and fully TypeScript‑typed.
52
37
 
53
- ## Get started
38
+ ## 🍦 Flavours
54
39
 
55
- ### 🐇 Quick start
40
+ Motion is available for [React](https://motion.dev/docs/react), [JavaScript](https://motion.dev/docs/quick-start) and [Vue](https://motion.dev/docs/vue).
56
41
 
57
- ```bash
58
- npm install motion
59
- ```
42
+ <details>
43
+ <summary>React ⬇</summary>
60
44
 
61
45
  ```jsx
62
46
  import { motion } from "motion/react"
@@ -66,42 +50,72 @@ function Component() {
66
50
  }
67
51
  ```
68
52
 
69
- Get started with [Motion for React](https://motion.dev/docs/react-quick-start).
53
+ Get started with [Motion for React](https://motion.dev/docs/react).
70
54
 
71
- ## 🎨 Studio
55
+ </details>
72
56
 
73
- ![Video of bezier curve editing](https://framerusercontent.com/images/KO5dnHOUSNGb9S73p1J7nLhoFI.gif)
57
+ <details>
58
+ <summary>JavaScript ⬇</summary>
74
59
 
75
- Motion Studio is a versatile suite of developer tools allowing you to:
60
+ ```javascript
61
+ import { animate } from "motion"
76
62
 
77
- - Visually edit CSS and Motion easing curves in VS Code
78
- - Generate CSS springs with LLMs
79
- - Load Motion docs into your LLM
63
+ animate("#box", { x: 100 })
64
+ ```
80
65
 
81
- Get started with [Motion Studio](https://motion.dev/docs/tools-quick-start).
66
+ Get started with [JavaScript](https://motion.dev/docs/quick-start).
67
+
68
+ </details>
69
+
70
+ <details>
71
+ <summary>Vue ⬇</summary>
72
+
73
+ ```html
74
+ <script>
75
+ import { motion } from "motion-v"
76
+ </script>
77
+
78
+ <template> <motion.div :animate={{ x: 100 }} /> </template>
79
+ ```
80
+
81
+ Get started with [Motion for Vue](https://motion.dev/docs/vue).
82
+
83
+ </details>
82
84
 
83
85
  ## 🎓 Examples
84
86
 
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.
87
+ [Motion Examples](https://motion.dev/examples) offers 100s of free and Motion+ examples for beginners and advanced users alike. Easy copy/paste code to kick‑start your next project.
86
88
 
87
89
  ## ⚡️ Motion+
88
90
 
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
91
+ Learn, Design, Build. [Motion+](https://motion.dev/plus) is a one-time fee, lifetime update membership that provides:
92
+ - 160+ premium Motion Examples
93
+ - Motion UI features like Cursor and Ticker
94
+ - Motion Studio animation editing for VS Code `alpha`
95
+ - Early access content
96
+ - Private Discord
95
97
 
96
98
  [Get Motion+](https://motion.dev/plus)
97
99
 
98
- ### 💎 Contribute
100
+ ## 🎨 Studio
99
101
 
100
- - Want to contribute to Motion? Our [contributing guide](https://github.com/motiondivision/motion/blob/master/CONTRIBUTING.md) has you covered.
102
+ ![Video of bezier curve editing](https://framerusercontent.com/images/KO5dnHOUSNGb9S73p1J7nLhoFI.gif)
101
103
 
102
- ### 👩🏻‍⚖️ License
104
+ Motion Studio is a versatile suite of developer tools allowing you to:
103
105
 
104
- - Motion for React is MIT licensed.
106
+ - Visually edit CSS and Motion easing curves in VS Code
107
+ - Generate CSS springs with LLMs
108
+ - Load Motion docs into your LLM
109
+
110
+ Get started with [Motion Studio](https://motion.dev/docs/tools-quick-start).
111
+
112
+ ## 👩🏻‍⚖️ License
113
+
114
+ - Motion is MIT licensed.
115
+
116
+ ## 💎 Contribute
117
+
118
+ - Want to contribute to Motion? Our [contributing guide](https://github.com/motiondivision/motion/blob/master/CONTRIBUTING.md) has you covered.
105
119
 
106
120
  ## ✨ Sponsors
107
121
 
@@ -119,11 +133,11 @@ Motion powers Framer animations, the web builder for creative pros. Design and s
119
133
 
120
134
  ### Platinum
121
135
 
122
- <a href="https://tailwindcss.com"><img alt="Tailwind" src="https://github.com/user-attachments/assets/c0496f09-b8ee-4bc4-85ab-83a071bbbdec" width="300px" height="200px"></a> <a href="https://emilkowal.ski"><img alt="Emil Kowalski" src="https://github.com/user-attachments/assets/29f56b1a-37fb-4695-a6a6-151f6c24864f" width="300px" height="200px"></a> <a href="https://linear.app"><img alt="Linear" src="https://github.com/user-attachments/assets/a93710bb-d8ed-40e3-b0fb-1c5b3e2b16bb" width="300px" height="200px"></a>
136
+ <a href="https://tailwindcss.com"><img alt="Tailwind" src="https://github.com/user-attachments/assets/c0496f09-b8ee-4bc4-85ab-83a071bbbdec" width="300px" height="200px"></a> <a href="https://linear.app"><img alt="Linear" src="https://github.com/user-attachments/assets/a93710bb-d8ed-40e3-b0fb-1c5b3e2b16bb" width="300px" height="200px"></a>
123
137
 
124
138
  ### Gold
125
139
 
126
- <a href="https://vercel.com"><img alt="Vercel" src="https://github.com/user-attachments/assets/23cb1e37-fa67-49ad-8f77-7f4b8eaba325" width="225px" height="150px"></a> <a href="https://liveblocks.io"><img alt="Liveblocks" src="https://github.com/user-attachments/assets/31436a47-951e-4eab-9a68-bdd54ccf9444" width="225px" height="150px"></a> <a href="https://lu.ma"><img alt="Luma" src="https://github.com/user-attachments/assets/4fae0c9d-de0f-4042-9cd6-e07885d028a9" width="225px" height="150px"></a>
140
+ <a href="https://vercel.com"><img alt="Vercel" src="https://github.com/user-attachments/assets/23cb1e37-fa67-49ad-8f77-7f4b8eaba325" width="225px" height="150px"></a> <a href="https://liveblocks.io"><img alt="Liveblocks" src="https://github.com/user-attachments/assets/31436a47-951e-4eab-9a68-bdd54ccf9444" width="225px" height="150px"></a> <a href="https://lu.ma"><img alt="Luma" src="https://github.com/user-attachments/assets/4fae0c9d-de0f-4042-9cd6-e07885d028a9" width="225px" height="150px"></a> <a href="https://emilkowal.ski"><img alt="Emil Kowalski" src="https://github.com/user-attachments/assets/29f56b1a-37fb-4695-a6a6-151f6c24864f" width="300px" height="200px"></a>
127
141
 
128
142
  ### Silver
129
143
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var featureBundle = require('./feature-bundle-CQ-jKhGL.js');
5
+ var featureBundle = require('./feature-bundle-PNQ-8QDo.js');
6
6
  require('react');
7
7
  require('motion-dom');
8
8
  require('motion-utils');
package/dist/cjs/dom.js CHANGED
@@ -986,8 +986,7 @@ class VisualElement {
986
986
  if (process.env.NODE_ENV !== "production") {
987
987
  motionUtils.warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
988
988
  }
989
- if (this.parent)
990
- this.parent.children.add(this);
989
+ this.parent?.addChild(this);
991
990
  this.update(this.props, this.presenceContext);
992
991
  }
993
992
  unmount() {
@@ -997,7 +996,7 @@ class VisualElement {
997
996
  this.valueSubscriptions.forEach((remove) => remove());
998
997
  this.valueSubscriptions.clear();
999
998
  this.removeFromVariantTree && this.removeFromVariantTree();
1000
- this.parent && this.parent.children.delete(this);
999
+ this.parent?.removeChild(this);
1001
1000
  for (const key in this.events) {
1002
1001
  this.events[key].clear();
1003
1002
  }
@@ -1010,6 +1009,15 @@ class VisualElement {
1010
1009
  }
1011
1010
  this.current = null;
1012
1011
  }
1012
+ addChild(child) {
1013
+ this.children.add(child);
1014
+ this.enteringChildren ?? (this.enteringChildren = new Set());
1015
+ this.enteringChildren.add(child);
1016
+ }
1017
+ removeChild(child) {
1018
+ this.children.delete(child);
1019
+ this.enteringChildren && this.enteringChildren.delete(child);
1020
+ }
1013
1021
  bindToMotionValue(key, value) {
1014
1022
  if (this.valueSubscriptions.has(key)) {
1015
1023
  this.valueSubscriptions.get(key)();
@@ -2960,8 +2960,7 @@ class VisualElement {
2960
2960
  if (process.env.NODE_ENV !== "production") {
2961
2961
  motionUtils.warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
2962
2962
  }
2963
- if (this.parent)
2964
- this.parent.children.add(this);
2963
+ this.parent?.addChild(this);
2965
2964
  this.update(this.props, this.presenceContext);
2966
2965
  }
2967
2966
  unmount() {
@@ -2971,7 +2970,7 @@ class VisualElement {
2971
2970
  this.valueSubscriptions.forEach((remove) => remove());
2972
2971
  this.valueSubscriptions.clear();
2973
2972
  this.removeFromVariantTree && this.removeFromVariantTree();
2974
- this.parent && this.parent.children.delete(this);
2973
+ this.parent?.removeChild(this);
2975
2974
  for (const key in this.events) {
2976
2975
  this.events[key].clear();
2977
2976
  }
@@ -2984,6 +2983,15 @@ class VisualElement {
2984
2983
  }
2985
2984
  this.current = null;
2986
2985
  }
2986
+ addChild(child) {
2987
+ this.children.add(child);
2988
+ this.enteringChildren ?? (this.enteringChildren = new Set());
2989
+ this.enteringChildren.add(child);
2990
+ }
2991
+ removeChild(child) {
2992
+ this.children.delete(child);
2993
+ this.enteringChildren && this.enteringChildren.delete(child);
2994
+ }
2987
2995
  bindToMotionValue(key, value) {
2988
2996
  if (this.valueSubscriptions.has(key)) {
2989
2997
  this.valueSubscriptions.get(key)();
@@ -4183,6 +4191,11 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
4183
4191
  });
4184
4192
  wantsHandoff.current = false;
4185
4193
  }
4194
+ /**
4195
+ * Now we've finished triggering animations for this element we
4196
+ * can wipe the enteringChildren set for the next render.
4197
+ */
4198
+ visualElement.enteringChildren = undefined;
4186
4199
  });
4187
4200
  return visualElement;
4188
4201
  }
@@ -4436,6 +4449,20 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
4436
4449
  return animations;
4437
4450
  }
4438
4451
 
4452
+ function calcChildStagger(children, child, delayChildren, staggerChildren = 0, staggerDirection = 1) {
4453
+ const index = Array.from(children)
4454
+ .sort((a, b) => a.sortNodePosition(b))
4455
+ .indexOf(child);
4456
+ const numChildren = children.size;
4457
+ const maxStaggerDuration = (numChildren - 1) * staggerChildren;
4458
+ const delayIsFunction = typeof delayChildren === "function";
4459
+ return delayIsFunction
4460
+ ? delayChildren(index, numChildren)
4461
+ : staggerDirection === 1
4462
+ ? index * staggerChildren
4463
+ : maxStaggerDuration - index * staggerChildren;
4464
+ }
4465
+
4439
4466
  function animateVariant(visualElement, variant, options = {}) {
4440
4467
  const resolved = resolveVariant(visualElement, variant, options.type === "exit"
4441
4468
  ? visualElement.presenceContext?.custom
@@ -4478,31 +4505,17 @@ function animateVariant(visualElement, variant, options = {}) {
4478
4505
  }
4479
4506
  function animateChildren(visualElement, variant, delay = 0, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
4480
4507
  const animations = [];
4481
- const numChildren = visualElement.variantChildren.size;
4482
- const maxStaggerDuration = (numChildren - 1) * staggerChildren;
4483
- const delayIsFunction = typeof delayChildren === "function";
4484
- const generateStaggerDuration = delayIsFunction
4485
- ? (i) => delayChildren(i, numChildren)
4486
- : // Support deprecated staggerChildren
4487
- staggerDirection === 1
4488
- ? (i = 0) => i * staggerChildren
4489
- : (i = 0) => maxStaggerDuration - i * staggerChildren;
4490
- Array.from(visualElement.variantChildren)
4491
- .sort(sortByTreeOrder)
4492
- .forEach((child, i) => {
4508
+ for (const child of visualElement.variantChildren) {
4493
4509
  child.notify("AnimationStart", variant);
4494
4510
  animations.push(animateVariant(child, variant, {
4495
4511
  ...options,
4496
4512
  delay: delay +
4497
- (delayIsFunction ? 0 : delayChildren) +
4498
- generateStaggerDuration(i),
4513
+ (typeof delayChildren === "function" ? 0 : delayChildren) +
4514
+ calcChildStagger(visualElement.variantChildren, child, delayChildren, staggerChildren, staggerDirection),
4499
4515
  }).then(() => child.notify("AnimationComplete", variant)));
4500
- });
4516
+ }
4501
4517
  return Promise.all(animations);
4502
4518
  }
4503
- function sortByTreeOrder(a, b) {
4504
- return a.sortNodePosition(b);
4505
- }
4506
4519
 
4507
4520
  function animateVisualElement(visualElement, definition, options = {}) {
4508
4521
  visualElement.notify("AnimationStart", definition);
@@ -4655,9 +4668,6 @@ function createAnimationState(visualElement) {
4655
4668
  let isInherited = prop === context[type] &&
4656
4669
  prop !== props[type] &&
4657
4670
  propIsVariant;
4658
- /**
4659
- *
4660
- */
4661
4671
  if (isInherited &&
4662
4672
  isInitialRender &&
4663
4673
  visualElement.manuallyAnimateOnMount) {
@@ -4778,9 +4788,6 @@ function createAnimationState(visualElement) {
4778
4788
  */
4779
4789
  typeState.prevProp = prop;
4780
4790
  typeState.prevResolvedValues = resolvedValues;
4781
- /**
4782
- *
4783
- */
4784
4791
  if (typeState.isActive) {
4785
4792
  encounteredKeys = { ...encounteredKeys, ...resolvedValues };
4786
4793
  }
@@ -4794,10 +4801,30 @@ function createAnimationState(visualElement) {
4794
4801
  const willAnimateViaParent = isInherited && variantDidChange;
4795
4802
  const needsAnimating = !willAnimateViaParent || handledRemovedValues;
4796
4803
  if (shouldAnimateType && needsAnimating) {
4797
- animations.push(...definitionList.map((animation) => ({
4798
- animation: animation,
4799
- options: { type },
4800
- })));
4804
+ animations.push(...definitionList.map((animation) => {
4805
+ const options = { type };
4806
+ /**
4807
+ * If we're performing the initial animation, but we're not
4808
+ * rendering at the same time as the variant-controlling parent,
4809
+ * we want to use the parent's transition to calculate the stagger.
4810
+ */
4811
+ if (typeof animation === "string" &&
4812
+ isInitialRender &&
4813
+ !willAnimateViaParent &&
4814
+ visualElement.manuallyAnimateOnMount &&
4815
+ visualElement.parent) {
4816
+ const { parent } = visualElement;
4817
+ const parentVariant = resolveVariant(parent, animation);
4818
+ if (parent.enteringChildren && parentVariant) {
4819
+ const { delayChildren } = parentVariant.transition || {};
4820
+ options.delay = calcChildStagger(parent.enteringChildren, visualElement, delayChildren);
4821
+ }
4822
+ }
4823
+ return {
4824
+ animation: animation,
4825
+ options,
4826
+ };
4827
+ }));
4801
4828
  }
4802
4829
  }
4803
4830
  /**
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 featureBundle = require('./feature-bundle-CQ-jKhGL.js');
7
+ var featureBundle = require('./feature-bundle-PNQ-8QDo.js');
8
8
  var motionDom = require('motion-dom');
9
9
  var motionUtils = require('motion-utils');
10
10
 
package/dist/cjs/m.js CHANGED
@@ -909,6 +909,11 @@ function useVisualElement(Component, visualState, props, createVisualElement, Pr
909
909
  });
910
910
  wantsHandoff.current = false;
911
911
  }
912
+ /**
913
+ * Now we've finished triggering animations for this element we
914
+ * can wipe the enteringChildren set for the next render.
915
+ */
916
+ visualElement.enteringChildren = undefined;
912
917
  });
913
918
  return visualElement;
914
919
  }