Git Product home page Git Product logo

Comments (4)

Fanna1119 avatar Fanna1119 commented on July 23, 2024 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.

Tahul avatar Tahul commented on July 23, 2024 3

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.

Fanna1119 avatar Fanna1119 commented on July 23, 2024 1

Hello, I'm trying to make a Reusable Modal with animation baked in using vueuse/motion. And I'm stuck with leave animation. I followed the demo folder's Transitions.vue and it is showing TypeError: Cannot read property 'leave' of undefined.

Which is as far as I know, in <transition :css="false" @leave="(el, done) => motions.pop.leave(done)"> code pop is undefined. 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.

wai-lin avatar wai-lin commented on July 23, 2024

Hello, I'm trying to make a Reusable Modal with animation baked in using vueuse/motion. And I'm stuck with leave animation. I followed the demo folder's Transitions.vue and it is showing TypeError: Cannot read property 'leave' of undefined.
Which is as far as I know, in <transition :css="false" @leave="(el, done) => motions.pop.leave(done)"> code pop is undefined. 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

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.