sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
79.95k stars 4.25k forks source link

Feature: animate for components #14170

Closed dm-de closed 1 week ago

dm-de commented 1 week ago

Describe the problem

This code will not work: LINK

I understand... a component can have multiple elements or if-blocks etc... and this can not work....

Describe the proposed solution

but! What if, Svelte compiler could detect 100% safe single element components and apply animation on it? Otherwise, here should be an error.

so... if my Component looks like this:

<div class="xyz">
    <span>{value}</span>
</div>

it is clear, that here is a single element

A "deep" check could be required, if you have a nested component inside

Importance

would make my life easier

paoloricciuti commented 1 week ago

That would require cross file compilation (which we currently don't support) but most importantly it would mean that:

  1. a feature will only work half of the times
  2. adding a single letter outside the element can break your application

Also there are still plans to see what svelte 5 can unlock in terms of composability of transitions, animations and actions.

Therefore i'm gonna close this issue for the moment, but thanks for reporting!