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 bindings on animate directive #4547

Open
Oreilles opened this issue Mar 12, 2020 · 5 comments
Open

Event bindings on animate directive #4547

Oreilles opened this issue Mar 12, 2020 · 5 comments

Comments

@Oreilles
Copy link

It would be nice to be able to bind events on the animate:* directive, much like the one that are available with the transition directive (introstart, introend, outrostart, outroend).

This feature would be useful in order to prevent other changes to the current component state while an animation is occuring, as a component update during an animation can make it glitch.

I think two events named animstart and animend would be appropriate.

In the meantime, is there a way to emulate this feature with what svelte already offers ?

@multics
Copy link

multics commented Apr 27, 2020

❤️Very much needed!

@dummdidumm
Copy link
Member

Related to #6479 where the opposite is requested

@BlueGreenMagick
Copy link
Contributor

+1

This is what I'm using to emulate this feature.

export function customAnimation(node: Element, ) {
  /* function body */
  return {
    delay, duration, easing, css,
    tick: (t, u) => {
      if (t === 0) {
        node.dispatchEvent(new CustomEvent("animationStart"));
      } else if (t === 1) {
        node.dispatchEvent(new CustomEvent("animationEnd"));
      }
    },
  };
}

@cpt-n3mo
Copy link

good day,

anyone have a solution for this..? as the above answer is not clear to me..

how can i use this with a flip animation..

kind regards

@jdgamble555
Copy link

I had to hack this. You can basically do what you want by doing a timeout on the duration (assuming your transition duration is 100):

setTImeout(() => {
  // whatever I want to do
}, 100);

J

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

No branches or pull requests

9 participants