sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
77.94k stars 4.07k forks source link

Svelte 5: Motion does not work in kit #9534

Closed zhihengGet closed 5 months ago

zhihengGet commented 9 months ago

Describe the bug

below code works on svelte 4 and svelte 5

    const progress = tweened(0, {
        duration: 400,
        easing: cubicOut
    });
    progress.set(0.25)

but not sveltekit with svelte 5

svelte 5

Reproduction

included

Logs

No response

System Info

windows

Severity

cant run my code :(

paoloricciuti commented 9 months ago

This is because the component is run on the server where requestAnimationFrame is not defined...if you try to wrap everything in onMount or $effect it'll work

rosemarymaker commented 9 months ago

This is because the component is run on the server where requestAnimationFrame is not defined...if you try to wrap everything in onMount or $effect it'll work

Thanks! Most likely will solve my problem.

but since this is working in sveltekit+svelte4 and it is just initializing the tween value in server side, i don't think it should call requestAnimationFrame

I think it is still a bug.

benmccann commented 9 months ago

Adding this to the 5.0 milestone for the team to take a look at. At the very least we'd need to mention it in the breaking changes section and migration guide