Skip to content

Animations break when adding / removing items during a transition #223

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

Closed
rihok opened this issue Feb 18, 2018 · 3 comments
Closed

Animations break when adding / removing items during a transition #223

rihok opened this issue Feb 18, 2018 · 3 comments

Comments

@rihok
Copy link

rihok commented Feb 18, 2018

This is easiest to show with an example, so here's a codepen showing the problem (click the toggle state button in quick succession):
https://codepen.io/rihok/pen/qxpzEr

I guess this is a bug.

@joshwcomeau
Copy link
Owner

Yep, this is documented under Known Issues in the README. We've spent a bunnnnch of time trying to fix this, but it's a surprisingly hard problem (at least, without using the poorly-supported Web Animations API).

Some workarounds are discussed in #195.

Sorry about that, hope you can find a solution!

@rihok
Copy link
Author

rihok commented Feb 18, 2018

Can you explain in a little more detail about what the issues are specifically? This ought to be solvable without WAAPI.

I can maybe throw out a naive solution that's certainly not the most elegant one, but should work quite consistently, which would be to hide the original elements and render duplicates during the transition. That way you can read layout position directly and just have the clones find the target, where ever it may be at any given time. Without knowing more about the problem, it's hard to suggest something tho.

@joshwcomeau
Copy link
Owner

The current solution for enter/leave animations doesn't involve duplicate elements (this is something I wanted to avoid, since with long lists and complex trees it felt like it would be impossible to do it in a performant way).

Essentially how it works is by removing the item from the DOM flow by giving it position: absolute. This is a required step so that siblings can translate into the vacuum that leaving items create. This works quite well, generally, but interrupts can be problematic. The reasons aren't entirely clear to me anymore, it's been a while.

You're welcome to take a stab at fixing it if you'd like; we've tried to keep the code well-commented and easy to follow (although, dozens of bugfixes and bolted-on additional features means that the code is quite complex). But yeah, I'd like to avoid duplicating nodes.

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

2 participants