Comments (4)
I am also confused about this.
looking at the code example:
https://github.com/vueuse/motion/blob/main/demo/src/demos/Transitions.vue
https://github.com/vueuse/motion/blob/efb8150197262cb4390c70667b2ea922070a4766/docs/variants.md
My first assumption was that i need to set up the import { useMotions } from '@vueuse/motion'
to initialise.
I am getting:
TypeError: Cannot read property 'leave' of undefined
my code is:
<transition :css="false" @leave="(el, done) => motions.cube.leave(done)">
<sidebar
v-if="showSidebar"
v-motion
:initial="{
x: -400,
opacity: 0,
}"
:enter="{
x: 0,
opacity: 1,
}"
:leave="{
x: -400,
opacity: 0,
}"
/>
</transition>
import { useMotions } from '@vueuse/motion'
import { ref } from '@vue/reactivity'
import sidebar from './sidebar.vue'
export default {
components: {
sidebar
},
setup() {
const showSidebar = ref(false);
const motions = useMotions()
return { showSidebar, motions }
}
}
i feel that the :leave
|| @leave
is a bit obscure. Hope in a future release or doc update this is made a bit easier to implement :)
(edit) removing the cube
solved it.
@leave="(el, done) => motions.cube.leave(done)"
-> @leave="(el, done) => motions.leave(done)"
(edit 2) better yet. just name the transition in the v-motion directive.
v-motion="'cube'"
then
<transition :css="false" @leave="(el, done) => motions.cube.leave(done)">
from motion.
Hey;
I updated your CodeSandbox showing the path on how to implement what you asked.
I will try to get a better naming convention for the 2.0 of this package. 😄
It should work properly with the code here:
https://codesandbox.io/s/vueuse-motion-playground-forked-61xpz?file=/src/components/Modal.vue
I'm closing this issue, if any additional question feel free to re-open. 😄
from motion.
Hello, I'm trying to make a Reusable Modal with animation baked in using
vueuse/motion
. And I'm stuck withleave
animation. I followed thedemo
folder'sTransitions.vue
and it is showingTypeError: Cannot read property 'leave' of undefined
.Which is as far as I know, in
<transition :css="false" @leave="(el, done) => motions.pop.leave(done)">
codepop
isundefined
. Am I missing anything?Here's is my code. https://codesandbox.io/s/vueuse-motion-playground-71ut4
your issue however was just because you imported the wrong module
you imported const motions = useMotion();
it should be:
import { useMotions } from "@vueuse/motion";
const motions = useMotions();
the naming convention blindsided me as well :)
https://codesandbox.io/s/vueuse-motion-playground-forked-7me8o
from motion.
Hello, I'm trying to make a Reusable Modal with animation baked in using
vueuse/motion
. And I'm stuck withleave
animation. I followed thedemo
folder'sTransitions.vue
and it is showingTypeError: Cannot read property 'leave' of undefined
.
Which is as far as I know, in<transition :css="false" @leave="(el, done) => motions.pop.leave(done)">
codepop
isundefined
. Am I missing anything?
Here's is my code. https://codesandbox.io/s/vueuse-motion-playground-71ut4your issue however was just because you imported the wrong module
you importedconst motions = useMotion();
it should be:
import { useMotions } from "@vueuse/motion";
const motions = useMotions();
the naming convention blindsided me as well :)
https://codesandbox.io/s/vueuse-motion-playground-forked-7me8o
Thanks @Fanna1119 , I didn't notice the extra s
in useMontions
. As you said hopefully maybe the next version of docs will help clarify this more.
from motion.
Related Issues (20)
- The nuxt plugin is missing motion.d.ts HOT 2
- No types exported
- Subject: Request for Assistance Regarding Residual Style Element from @vueuse/motion's Animation
- I've got a horizontal scroll with v-motion-slide-visible-once-right HOT 4
- [Bug] Could not find a declaration file for module '@vueuse/motion'. HOT 5
- Trigger animation based on visibility of another element
- Nuxt 3 custom directive error. HOT 2
- Support v-show, to avoid missing @leave transitions HOT 4
- Does it support SVG morph?
- Can't resolve defu in @vueuse/motion/dist/index.mjs HOT 3
- Repository maintainer status HOT 6
- Roadmap DRAFT HOT 11
- [Bug Report] Since v2.1.0, animations no longer work when navigating back between routes from the bottom of a page HOT 9
- CSS Custom properties support? HOT 1
- Unable to use leave in jsx file
- explain how work with useMotion
- Hover on nested element removes "hovered" styles HOT 4
- Custom directives/presets do not work for Motion components HOT 2
- motion component applied expired styles after component updated HOT 1
- Bug with amimations for several components by key property change HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from motion.