Svelte: Built-in transitions

Created on 2 May 2017  Â·  3Comments  Â·  Source: sveltejs/svelte

We should make transition plugins like svelte-transition-fade so that people can use them easily in their components...

<div in:fade>...</div>

<script>
  import fade from 'svelte-transition-fade';

  export default {
    transitions: { fade }
  };
</script>

...but, given that we're a compiler and we can do this with zero cost, I think we should also have certain transitions built-in. There's something rather appealing about being able to use transitions without even needing a <script> tag in the component.

transitions rfc-1

Most helpful comment

As discussed in chat, a compromise that would avoid too much 'magic' would be to publish the official transitions in the main package under svelte/transitions.js.

One slight wrinkle with doing this that I just noticed is that three of the official transitions currently have eases-jsnext as a (production) dependency. If we go ahead with including the transitions in this package, I think the best thing to do here would be to introduce eases-jsnext as a devdependency of Svelte, and just bundle the required eases in svelte/transitions.js.

Also briefly mentioned in chat was bringing svelte-extras in as well, to svelte/extras.js.

I'm not sure where would be the best place for documentation for all of these to live. Not in the svelte.technology guide, I don't think, although perhaps they could be linked from there. I think a new folder in the svelte repo containing markdown files would be good. This might even be used to collect docs for things that are a little too esoteric for the main guide.

All 3 comments

So it's basically up to how many we want to ship with the compiler. While they're completely different projects, we could copy jQuery's built-in effects and ship fade[in/out] / slide[up/down/toggle].

As discussed in chat, a compromise that would avoid too much 'magic' would be to publish the official transitions in the main package under svelte/transitions.js.

One slight wrinkle with doing this that I just noticed is that three of the official transitions currently have eases-jsnext as a (production) dependency. If we go ahead with including the transitions in this package, I think the best thing to do here would be to introduce eases-jsnext as a devdependency of Svelte, and just bundle the required eases in svelte/transitions.js.

Also briefly mentioned in chat was bringing svelte-extras in as well, to svelte/extras.js.

I'm not sure where would be the best place for documentation for all of these to live. Not in the svelte.technology guide, I don't think, although perhaps they could be linked from there. I think a new folder in the svelte repo containing markdown files would be good. This might even be used to collect docs for things that are a little too esoteric for the main guide.

As of Svelte 3, 'official' transitions live in svelte/transition — closing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robnagler picture robnagler  Â·  3Comments

clitetailor picture clitetailor  Â·  3Comments

angelozehr picture angelozehr  Â·  3Comments

bestguy picture bestguy  Â·  3Comments

juniorsd picture juniorsd  Â·  3Comments