You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was experimenting with transitions and I believe I’ve found a bug in the scale transition, specifically related to how it handles opacity.
The documentation for scale states:
Animates the opacity and scale of an element. in transitions animate from the provided values, passed as parameters, to an element's current (default) values.
This works as expected when the element's default style has opacity: 1 and you pass opacity: 0 to the scale transition — it smoothly fades in from 0 to 1.
However, if you reverse it — i.e. set the element’s default opacity to 0 and pass opacity: 1 to the scale function — the element never appears. The transition seems to have no visible effect.
This way the transition seems to behave correctly in both directions. That said, I'm still new to Svelte, so I’m not sure if this could have consequences in other animations..
Describe the bug
I was experimenting with transitions and I believe I’ve found a bug in the
scale
transition, specifically related to how it handles opacity.The documentation for scale states:
Animates the opacity and scale of an element. in transitions animate from the provided values, passed as parameters, to an element's current (default) values.
This works as expected when the element's default style has opacity: 1 and you pass opacity: 0 to the scale transition — it smoothly fades in from 0 to 1.
However, if you reverse it — i.e. set the element’s default opacity to 0 and pass opacity: 1 to the scale function — the element never appears. The transition seems to have no visible effect.
I believe the problem is on this line
svelte/packages/svelte/src/transition/index.js
Line 167 in c544a59
I tried to fix it on my own and came up with this
This way the transition seems to behave correctly in both directions. That said, I'm still new to Svelte, so I’m not sure if this could have consequences in other animations..
Reproduction
https://svelte.dev/playground/cc49650a563446849594dd179537ce35?version=5.25.7
You can see the difference between the normal scale function and scale2 (my fix).
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: