svelte icon indicating copy to clipboard operation
svelte copied to clipboard

Add a `component` scope to transitions

Open oodavid opened this issue 1 year ago • 1 comments

Describe the problem

It would be useful to have a component scope for transitions so that we can limit our transitions to the component.

This would let us be confident how a transition will behave without knowing anything about how the component is being used.

The issue with global scope is the behaviour depends on whether the component is inside a block or not. With local scope, we cannot animate within nested blocks.

I've created a REPL playground:

https://svelte.dev/repl/30f6e9d08aa2466daab7eaa0f739076f?version=4.0.0

And recorded a short video explaining the idea / issue:

https://www.loom.com/share/a25fc70f3987474ea3fbe647e1716a10

Describe the proposed solution

Adding transition:slide|component that limits the scope of transitions to the current component.

Alternatives considered

None

Importance

would make my life easier

oodavid avatar Jun 26 '23 12:06 oodavid

One of the best things about Svelte is having all component parts in a single file (ie: the script, HTML and style). Because of this, it might even make sense for component to be the default behaviour for transitions.

I know this has been a breaking change in 4.0.0, so I understand if there would be push-back against this.

oodavid avatar Jun 26 '23 12:06 oodavid