vueuse / motion

🤹 Vue Composables putting your components in motion
https://motion.vueuse.org
MIT License
2.13k stars 75 forks source link

fix: `v-motion` directive variants leaking #173

Closed BobbieGoede closed 4 months ago

BobbieGoede commented 4 months ago

You may have noticed the demo page is not working as expected, it seems only the initial motion variant is triggered. While testing #171 in the vite playground I noticed that simply adding en element using a visibility variant would make all motion elements disappear.

Using the Netlify deploy history of the demo page (https://app.netlify.com/sites/vueuse-motion-demo/deploys) I narrowed down when this broke to this commit. I think that by changing the directive to accept a default value {} instead of undefined for variants, the same object is being reused for all v-motion usage, essentially each element using v-motion is overwriting/merging all the previous ones.

This partially fixes the demo page, but fixes what's probably a bigger bug. I'll have a separate PR to fix the demo page further soon.

BobbieGoede commented 4 months ago

@cpreston321 / @Tahul Tagging for review