Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you animate on leave/exit? #142

Open
jetlej opened this issue Jul 17, 2023 · 6 comments
Open

How do you animate on leave/exit? #142

jetlej opened this issue Jul 17, 2023 · 6 comments

Comments

@jetlej
Copy link

jetlej commented Jul 17, 2023

I don't see any mentions in the documentation. Is this possible to do?

@StitiFatah
Copy link

@Soahr
Copy link

Soahr commented Aug 2, 2023

I'm sorry but I can't get the leave variant to work with the demo ....
Does someone can post a working full exemple ?

@alexrichardsweb
Copy link

Same here. Can't get any form of leave transition working. There is a link to an example demo in the docs but not example code (from what I can see).

I have found other examples but this is the only one using composition API https://codesandbox.io/s/vueuse-motion-playground-forked-61xpz?file=/src/components/Modal.vue:122-176 - I have replicated this but in a Nuxt 3 project, is there anything else required on top of the above example to get leave animations working with Nuxt 3?

@gazreyn
Copy link

gazreyn commented Oct 2, 2023

Also been having issues trying to get it to work and what I have isn't perfect but it's just some observations I have.

  • The element you're trying to animate in/out have to be wrapped in a element
  • I found that I had to both account for both @enter and @leave events on the transition
  • The :leave property never seemed to register, so I basically had the following
<script setup lang="ts">
const myElement = ref<HTMLElement>();
const { leave, apply } = useMotion(lowerthird);

async function onEnter(_: HTMLElement, done: () => void) {
  await apply({
    y: 0,
    opacity: 1,
  });
  done();
}

async function onLeave(_: HTMLElement, done: () => void) {
  await apply({
    y: 100,
    opacity: 0,
  });
  leave(done);
}
</script>

<template>
  <Transition @enter="onEnter" @leave="onLeave">
    <div ref="myElement" v-if="isVisible" v-motion...></div>
  </Transition>
</template>

@bernhardberger
Copy link

I can't get @Leave to work either..

@sneakylenny
Copy link

sneakylenny commented Oct 11, 2024

Couldn't find it either, I expected it to work with v-if or v-show but v-show doesn't do anything at all and v-if only shows the enter animation.

I tried to replicate the demo and apply the animation manually, but without success. Somehow I get the same result: only the enter animation works.

I guess I'm switching back to https://github.com/oku-ui/motion though it's not as well maintained as this one, it does have working and easy to apply leave animations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants