kit icon indicating copy to clipboard operation
kit copied to clipboard

Allow playing transitions on initial render

Open geoffrich opened this issue 3 years ago • 6 comments

Describe the problem

In Svelte, you can play transitions on initial render by setting intro: true in the component constructor. There doesn't seem to be a way to do this in SvelteKit.

Describe the proposed solution

Add a setting in svelte.config.js that will set intro: true in the component constructor. This would only apply during the initial render. After client-side navigation, transitions should play automatically as components are mounted.

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

geoffrich avatar Nov 08 '21 17:11 geoffrich

This has come up in Sapper (https://github.com/sveltejs/sapper/issues/1106) and I don't think the question of what this would mean for SvelteKit is any clearer.

Conduitry avatar Nov 08 '21 17:11 Conduitry

Also interested in using this. I think it makes sense to implement with a browser check since the transitions wouldn't need to play in SSR.

nathancahill avatar Apr 02 '22 17:04 nathancahill

Yes, please! 😄

mattcroat avatar May 03 '22 15:05 mattcroat

I am wondering if I am actually also running into this issue at the moment.

I have a page, which has a date as URL parameter. If I switch to another page (actually just navigating to a route with a different date), a new view is created and each cell (in a month view) is animated.

However: when firing up the page directly via URL, it shows the first a loading animation and then instead of playing transitions as expected (e.g. in:fade), it just draws everything in a finished state. When moving, the animation is performed as expected.

Is it perhaps this limitation?

divStar avatar Sep 12 '22 00:09 divStar

It's the same problem, yes. This library provides a hacky workaround you can use for now: https://fractils.fractal-hq.com/#OnMount

3mdistal avatar Sep 13 '22 16:09 3mdistal

It might also be a good idea to be able to enable this functionality per-component or per-page. I really need this feature in my own project and it would be very nice to have.

talwat avatar Nov 08 '22 19:11 talwat

It's the same problem, yes. This library provides a hacky workaround you can use for now: https://fractils.fractal-hq.com/#OnMount

This works, but it prevents SSR. I get similar results by:

{#if someVar}
    <Component transition:someAnimation/>
{if}

gwerneckp avatar Jan 05 '23 23:01 gwerneckp

What's the status of this?

jrhager84 avatar Mar 09 '23 23:03 jrhager84

is it possible to revert back to svelte 3 until this is resolved? or is it going to break more things by doing so?

I'm on a completely empty sveltekit skeleton project. I'm starting fresh, but it comes with svelte 4.

ioucyf avatar Sep 11 '23 18:09 ioucyf

What's the status on this feature?

socketopp avatar Jan 28 '24 20:01 socketopp

Any update? 👀

DaveKeehl avatar Mar 30 '24 09:03 DaveKeehl

There's still no way to do this after 3 years since this issue was opened? 😖

Spimy avatar Apr 26 '24 18:04 Spimy

I just ran into this after trying to update my svelte site, originally when clicking between links it seems like transitions were played per component being swapped in and out, allowing a pretty interesting visual when updating between pages. I'd really like to achieve the same effect with as minimal a code change as possible, I really like how it worked previously.

Andersama avatar Apr 27 '24 17:04 Andersama

Is this still being considered or is there a potential workaround?

brittneypostma avatar Jul 01 '24 12:07 brittneypostma