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

Elements (components) with transition overlap each other in an each block using flip animation #4910

Closed
Fygo opened this issue May 26, 2020 · 9 comments

Comments

@Fygo
Copy link

Fygo commented May 26, 2020

Issue: When an each block which has animation:flip set contains items which have transition:xyz set and this each block is updated (e.g. some items removed), the items may not get the correct position if the update occurs while the previous transitions are running.

REPL: https://svelte.dev/repl/324c3d19fe1b4648919af7b2eef7e4f3?version=3.22.3

Steps to reproduce: click the button quickly 2-3 times, (or change the input field's value while the list is animating).

Result: Some elements overlap each other, breaking the order.

@kuhlaid
Copy link

kuhlaid commented May 28, 2020

You likely need to use deferred transitions https://svelte.dev/tutorial/deferred-transitions.

@Fygo
Copy link
Author

Fygo commented Sep 10, 2020

Any feedback on this?

Here is a simpler example: https://svelte.dev/repl/9a81a545111b475f86639dafcd8f35a5?version=3.24.1

Just double click the button.

Result: elements overlapping, flip animation not pushing down the 2nd element.

Edit: I changed the duration of the animations to 2 seconds, meaning it is not even necessary to click the button "that fast". The key is to click it the second time WHILE the first animations are running.

This is the result:
Overlap

@mquandalle
Copy link

mquandalle commented Nov 29, 2020

I'm encountering the same issue. Is anyone aware of a workaround?
It seems that we should disable transitions while performing the "flip" layout calculation?

Edit: Interestingly the issue only happen with the out transition. In my case removing the out and only keeping the in gives a good result, see the amended example from @Fygo https://svelte.dev/repl/76cdc13f5a5b462bba8d6a082edf367f?version=3.24.1

@mquandalle
Copy link

Possibly related to #5808.

@ForrestFire0
Copy link

ForrestFire0 commented May 12, 2021

This is still an issue. Any updates about this?

My workaround was to delay the animation until the previous one has fixed wherever it was buggy. I had a list that varied in size, and so when I decreased the list size and increased it too soon, I would get the overlap. I simply delayed the increase in list size until the animation had completed.

@HalfVoxel
Copy link

I'm also running into this bug. I have an animation, in and out directive on a node in a keyed each block.
When the list changes quickly, the last element (all others seem to work fine, I think) sometimes gets stuck with some style=position: absolute; transform: ... css that makes it stay in the wrong position.

image

@legowhales
Copy link

Same here, I made a workaround that I think is a bit better than delays (delays where not working for me , and are pretty random imo).

Here it is : https://svelte.dev/repl/63bb44e18284450388bad41fc0df7c6c?version=3.44.1

Another problem is how transitions work. There is no way to dynamically modify the behaviour in the outro, if the animation is called with transition:fly. I think this is because svelte is using the css function for all outros instead of calling the transition function again. So you need to have in:customFlyIn and out:customFlyOut.

In the mean time, I hope this helps.
Cheers!

@Blankeos
Copy link

Blankeos commented Apr 29, 2024

@legowhales you're nuts, I know this is like 3 years after but thanks man!

It went from this:

Svelte Animate and Transition bug

To this:
Svelte Animate and Transition bug

I wonder why is not included in the default API for flip, fly?

Repro: https://svelte.dev/repl/4d641551906e4b82a893918bb43fd6d3?version=4.2.12

@dummdidumm
Copy link
Member

Fixed in Svelte 5

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

Successfully merging a pull request may close this issue.

10 participants