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

Animate inside AnimateGroup ignores complete #56

Closed
stroborobo opened this issue Jul 17, 2019 · 11 comments
Closed

Animate inside AnimateGroup ignores complete #56

stroborobo opened this issue Jul 17, 2019 · 11 comments
Labels

Comments

@stroborobo
Copy link

Describe the bug
When an Animation with a complete prop is placed inside of an AnimationGroup the complete styles are not applied.

To Reproduce
https://codesandbox.io/s/animate-components-in-sequences-e18mv

Expected behavior
The completion styles are applied after the animation is completed.

Desktop (please complete the following information):

  • OS: macOS
  • Browser Chrome 75 & Safari 12.1.1
@bluebill1049
Copy link
Member

Hi @stroborobo,

Can you try with AniamteKeyFrames for now? leave the last keyFrame as complete style?

I will update the doc to exclude <Animate /> onCompelete for <AnimateGroup />.

The reason I didn't want to support onComplete style for <AnimateGroup /> is the nature of onComplete involves setTimeout, which will result in inaccurate animation. I guess for single <Aniamte /> is ok, but when you doing in a group or sequence you will see the unexpected animation result. hence <AniamteKeyFrames /> will perform better.

let me know if this makes sense and see if <AnimateKeyFrames /> works for you.

cheers
bill

@stroborobo
Copy link
Author

I see, thanks for the fast reply. Turns out I didn't really need it in the first place, so I'm just using two independent Animations. But I'll keep your advice in mind for later :)

@bluebill1049
Copy link
Member

no worries mate, happy to help with issues 👍

@bluebill1049
Copy link
Member

going to close this issue, feel free to reopen if have more questions

@harry-sm
Copy link

harry-sm commented Apr 27, 2022

For the onComplete callback instead of using a timer, you could use a transitionend event.

element.addEventListener('transitionend', () => {
  onComplete && onComplete();
});

@bluebill1049
Copy link
Member

That would be amazing. Please send a PR.

@harry-sm
Copy link

No problem, I'll look at it this weekend. Not sure how to go about implementing this feature in the hooks though. Thinking of passing a ref const { play, style } = useAnimate({ ref: elRef }); so I can bind the listener to the element.

@bluebill1049
Copy link
Member

lol maybe borrow react hook form's API, register :)

@harry-sm
Copy link

Never used react hook forms but I'll take a look at it

@harry-sm
Copy link

harry-sm commented May 2, 2022

I've added the event listener but getting a few warning from jest. I think it has something to with the onComplete event firing after the test has completed. Im going to add a onComplete callback for animation keyframes. You can view the progress here for now repo

@bluebill1049
Copy link
Member

that's awesome! @harry-sm

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

No branches or pull requests

3 participants