svelte icon indicating copy to clipboard operation
svelte copied to clipboard

A rotated element's crossfade animation goes in wrong direction

Open ffossum opened this issue 2 years ago • 6 comments

Describe the bug

An element with a css transform rotation will move in the wrong direction when transitioning using crossfade. The result is that the illusion (of one element moving from one place to the other) breaks, and instead it looks like two separate elements appearing from and disappearing into different locations.

I love the crossfade feature :heart:. I'll just have to avoid using it with rotated elements until this is fixed.

Reproduction

https://svelte.dev/repl/7683202144db47858ab63591919ae131?version=3.48.0

By removing the rotation from the css transform, everything looks normal again: https://svelte.dev/repl/19da212e1b9446338b05ab73091d1cee?version=3.48.0

Logs

No response

System Info

Svelte 3.48.0

Severity

annoyance

ffossum avatar Jul 06 '22 13:07 ffossum

I'm working on it and I've pinpointed the issue. Basically when it moves the b element where a was getClientBoundRect does not take into consideration the rotation. The fix could be moving all the already present rotation at the end...but this won't take into account elements that are rotated not in multiples of 90 deg.

paoloricciuti avatar Jul 06 '22 17:07 paoloricciuti

As an update: you can't move the rotation at the end because the getComputedStyle().transform return a matrix of all the transformation applied. I have to dig deeper into this to find a way to get the actual position of a rotated object instead of the clientBoundRect.

paoloricciuti avatar Jul 07 '22 07:07 paoloricciuti

is this still being worked on, because i think i have an idea on how to solve this issue?

pedeEli avatar Jul 03 '23 10:07 pedeEli

is this still being worked on, because i think i have an idea on how to solve this issue?

Completely forgot to update this issue, feel free to go ahead and solve this if you have a solution

paoloricciuti avatar Jul 03 '23 10:07 paoloricciuti

do you know of an easy way to test this?

pedeEli avatar Jul 03 '23 11:07 pedeEli

do you know of an easy way to test this?

Sure, just copy the code of the action inside the repl, do your modification there. This way you can easily test it

paoloricciuti avatar Jul 03 '23 12:07 paoloricciuti