-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fade-in transition showing flash of visible content before fading in #14732
Comments
Just an update on this. Here's a workaround I came up with, but yeah ... it's obviously not ideal. Basically, if you wrap the state triggering the fade in, in a Still, it would be good to fix this properly. <script>
/**
* Fix for Svelte 5 (apparent) bug where fade in transitions
* seem to flash a frame of the object before it disappearing
* and then fading in as usual.
*/
import { Tween } from "svelte/motion";
import { fade } from "svelte/transition";
import { linear } from "svelte/easing";
const progress = new Tween(0, {
duration: 10000,
easing: linear,
});
let showCircle = $derived(Math.floor(progress.current / 10) % 2 === 0);
async function togglePlay() {
await progress.set(0, { duration: 0 });
await progress.set(100);
}
let showCircle2 = $state(false);
$effect(() => {
// setTimeout required to fix Svelte 5 transition issue
// https://github.com/sveltejs/svelte/issues/14732
setTimeout(() => {
showCircle2 = showCircle;
}, 0);
// REACTIVE DEPENDENCY: showCircle
showCircle;
});
</script>
<svg width="400" height="400">
{#if showCircle2}
<circle in:fade cx="200" cy="200" r="150" fill="salmon" />
{/if}
</svg>
<div>
<button onclick={togglePlay}>Start</button>
Progress: {Math.round(progress.current)}%
</div>
|
I have no idea what's going on in this repro. Nothing is fading at all. Can you simplify it so that it's a minimal reproduction? |
Oh, sorry, it looks like the REPL saved my half-finished fix. It should be reverted back to a minimal reproduction. Thanks @Rich-Harris Edit: Seems to flash in Firefox and Safari more often than in Chrome. |
Yeah, I see it. This is super weird. Hmm |
Describe the bug
In Svelte 5 (doesn't happen in Svelte 4) when you have an element that fades in with a Svelte transition there will be a flash of content before it disappears and then the fade-in happens as normal.
Possibly related to #13882
Am I doing something wrong, or is this an actual bug? It only started happening in my project after upgrading to Svelte 5.
Reproduction
REPL https://svelte.dev/playground/510da9e8fd0f45fb85593cef8ce0f095?version=5.14.1
Click Start (the flash should happen almost always)
Logs
No response
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: