Skip to content

Commit 86dfcf7

Browse files
authored
Merge pull request #213 from motiondivision/fix/unmount-loop
fix: infinite loop in unmount causing browser crash
2 parents 335bb3c + a7c4681 commit 86dfcf7

File tree

2 files changed

+145
-11
lines changed

2 files changed

+145
-11
lines changed

packages/motion/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/motion/README.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<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 Vue</h1>
2+
3+
<p align="center">
4+
<a href="https://www.npmjs.com/package/motion-v" target="_blank">
5+
<img src="https://img.shields.io/npm/v/motion-v.svg?style=flat-square" />
6+
</a>
7+
<a href="https://www.npmjs.com/package/motion-v" target="_blank">
8+
<img src="https://img.shields.io/npm/dm/motion-v.svg?style=flat-square" />
9+
</a>
10+
<a href="https://twitter.com/motiondotdev" target="_blank">
11+
<img src="https://img.shields.io/twitter/follow/framer.svg?style=social&label=Follow" />
12+
</a>
13+
</p>
14+
15+
<br>
16+
<hr>
17+
<br>
18+
19+
Motion for Vue is an open source, production-ready library that’s designed for all creative developers.
20+
21+
It's the only animation library with a hybrid engine, combining the power of JavaScript animations with the performance of native browser APIs.
22+
23+
It looks like this:
24+
25+
```jsx
26+
<motion.div :animate="{ x: 100 }" />
27+
```
28+
29+
It does all this:
30+
31+
- Springs
32+
- Keyframes
33+
- Layout animations
34+
- Shared layout animations
35+
- Gestures (drag/tap/hover)
36+
- Scroll animations
37+
- SVG paths
38+
- Exit animations
39+
- Server-side rendering
40+
- Independent transforms
41+
- Orchestrate animations across components
42+
- CSS variables
43+
44+
...and a whole lot more.
45+
46+
## Get started
47+
48+
### 🐇 Quick start
49+
50+
Install `motion-v` via your package manager:
51+
52+
```
53+
npm install motion-v
54+
```
55+
56+
Then import the `motion` component:
57+
58+
```vue
59+
<script setup>
60+
import { motion } from 'motion-v'
61+
</script>
62+
63+
<template>
64+
<motion.div :animate="{ x: 100 }" />
65+
</template>
66+
```
67+
68+
## ⚡️ Motion+
69+
70+
Learn, Design, Build. [Motion+](https://motion.dev/plus) is a one-time fee, lifetime update membership that provides:
71+
- 160+ premium Motion Examples
72+
- Motion UI features like Cursor and Ticker
73+
- Motion Studio animation editing for VS Code `alpha`
74+
- Early access content
75+
- Private Discord
76+
77+
[Get Motion+](https://motion.dev/plus)
78+
79+
## 🎨 Studio
80+
81+
![Video of bezier curve editing](https://framerusercontent.com/images/KO5dnHOUSNGb9S73p1J7nLhoFI.gif)
82+
83+
Motion Studio is a versatile suite of developer tools allowing you to:
84+
85+
- Visually edit CSS and Motion easing curves in VS Code
86+
- Generate CSS springs with LLMs
87+
- Load Motion docs into your LLM
88+
89+
Get started with [Motion Studio](https://motion.dev/docs/tools-quick-start).
90+
91+
### 💎 Contribute
92+
93+
- Want to contribute to Motion? Our [contributing guide](https://github.com/motiondivision/motion-vue/blob/master/CONTRIBUTING.md) has you covered.
94+
- [Join our discord ](https://discord.com/invite/dCBuRgdNDG)
95+
96+
### 👩🏻‍⚖️ License
97+
98+
- Motion for Vue is MIT licensed.
99+
100+
## ✨ Sponsors
101+
102+
Motion is sustainable thanks to the kind support of its sponsors.
103+
104+
### Partners
105+
106+
#### Framer
107+
108+
Motion powers Framer animations, the web builder for creative pros. Design and ship your dream site. Zero code, maximum speed.
109+
110+
<a href="https://www.framer.com?utm_source=motion-readme">
111+
<img alt="Framer" src="https://github.com/user-attachments/assets/0404c7a1-c29d-4785-89ae-aae315f3c759" width="300px" height="200px">
112+
</a>
113+
114+
### Platinum
115+
116+
<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>
117+
118+
### Gold
119+
120+
<a href="https://tailwindcss.com"><img alt="Tailwind" src="https://github.com/user-attachments/assets/1d5f2571-8bc3-4367-9fec-14d291168ff0" width="200px" height="120px"></a> <a href="https://emilkowal.ski"><img alt="Emil Kowalski" src="https://github.com/user-attachments/assets/33d1cb98-238a-4eed-a0df-9c7ab097d65b" width="200px" height="120px"></a> <a href="https://liveblocks.io"><img alt="Liveblocks" src="https://github.com/user-attachments/assets/28eddbe5-1617-4e74-969d-2eb6fcd481af" width="200px" height="120px"></a> <a href="https://vercel.com"><img alt="Vercel" src="https://github.com/user-attachments/assets/abc473bd-07ae-4a7d-9833-efe9dadb3773" width="200px" height="120px"></a> <a href="https://lu.ma"><img alt="Luma" src="https://github.com/user-attachments/assets/ac282433-6adb-4ad2-9fd2-5c6ee513c14b" width="200px" height="120px"></a> <a href="https://notion.com"><img alt="Notion" src="https://github.com/user-attachments/assets/a27a6033-3cb0-4232-a6bb-625e1824517b" width="200px" height="120px"></a>
121+
122+
### Silver
123+
124+
<a href="https://www.frontend.fyi/?utm_source=motion"><img alt="Frontend.fyi" src="https://github.com/user-attachments/assets/f16e3eb9-f0bd-4ad1-8049-f079a3d65c69" width="150px" height="100px"></a> <a href="https://firecrawl.dev"><img alt="Firecrawl" src="https://github.com/user-attachments/assets/2c44e7f4-5c2a-4714-9050-1570538665ff" width="150px" height="100px"></a> <a href="https://puzzmo.com"><img alt="Puzzmo" src="https://github.com/user-attachments/assets/e32205a7-3ab1-41ec-8729-a794058fd655" width="150px" height="100px"></a> <a href="https://bolt.new"><img alt="Bolt.new" src="https://github.com/user-attachments/assets/7932d4b2-bb6c-422e-82b9-6ad78a7e3090" width="150px" height="100px"></a>
125+
126+
### Personal sponsors
127+
128+
- [OlegWock](https://sinja.io)
129+
- [Lambert Weller](https://github.com/l-mbert)
130+
- [Jake LeBoeuf](https://jklb.wf)
131+
- [Han Lee](https://github.com/hahnlee)

packages/motion/src/state/motion-state.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,25 @@ export class MotionState {
169169

170170
unmount(unMountChildren = false) {
171171
const shouldDelay = this.options.layoutId && this.visualElement.projection?.getStack().lead === this.visualElement.projection && this.visualElement.projection.isProjecting()
172+
const unmountState = () => {
173+
if (unMountChildren) {
174+
Array.from(this.children).reverse().forEach(this.unmountChild)
175+
}
176+
this.parent?.children?.delete(this)
177+
mountedStates.delete(this.element)
178+
this.featureManager.unmount()
179+
this.visualElement?.unmount()
180+
// clear animation
181+
this.clearAnimation()
182+
}
172183
if (shouldDelay) {
173184
Promise.resolve().then(() => {
174-
this.unmount(unMountChildren)
185+
unmountState()
175186
})
176-
return
177187
}
178-
if (unMountChildren) {
179-
Array.from(this.children).reverse().forEach(this.unmountChild)
188+
else {
189+
unmountState()
180190
}
181-
this.parent?.children?.delete(this)
182-
mountedStates.delete(this.element)
183-
this.featureManager.unmount()
184-
this.visualElement?.unmount()
185-
// clear animation
186-
this.clearAnimation()
187191
}
188192

189193
private unmountChild(child: MotionState) {

0 commit comments

Comments
 (0)