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

Event #13

Open
maximebodereauseelab opened this issue Nov 7, 2024 · 3 comments
Open

Event #13

maximebodereauseelab opened this issue Nov 7, 2024 · 3 comments

Comments

@maximebodereauseelab
Copy link

Can we "activate" the animation on click event ?

@leonardobetti
Copy link

leonardobetti commented Nov 7, 2024

same question, cant make it work when I click just hover or page refresh

@xenvi
Copy link

xenvi commented Nov 8, 2024

this can be done by creating a state variable and defining the css animation class when that variable meets a condition (ex: set state to true on click, play animation, settimeout state back to false). unsure if there are plans to make an easier handler but this works for now

@MarkusRink
Copy link

The shortest way I found is this (for non looping animations):

<script>
const doAnimation = ref(false)
</script>
<template>
<button
  :class="{'motion-opacity-out-0':doAnimation}"
  @click='doAnimation = true'
  @animationend='doAnimation = false'
>
anmiate
</button
</template>

In Vue, maybe a wrapper component with slot props could help remove the animation variable from the script.

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

4 participants