diff --git a/site/content/tutorial/09-lifecycle/01-onmount/app-a/App.svelte b/site/content/tutorial/07-lifecycle/01-onmount/app-a/App.svelte similarity index 100% rename from site/content/tutorial/09-lifecycle/01-onmount/app-a/App.svelte rename to site/content/tutorial/07-lifecycle/01-onmount/app-a/App.svelte diff --git a/site/content/tutorial/09-lifecycle/01-onmount/app-b/App.svelte b/site/content/tutorial/07-lifecycle/01-onmount/app-b/App.svelte similarity index 100% rename from site/content/tutorial/09-lifecycle/01-onmount/app-b/App.svelte rename to site/content/tutorial/07-lifecycle/01-onmount/app-b/App.svelte diff --git a/site/content/tutorial/09-lifecycle/01-onmount/text.md b/site/content/tutorial/07-lifecycle/01-onmount/text.md similarity index 100% rename from site/content/tutorial/09-lifecycle/01-onmount/text.md rename to site/content/tutorial/07-lifecycle/01-onmount/text.md diff --git a/site/content/tutorial/09-lifecycle/02-ondestroy/app-a/App.svelte b/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/App.svelte similarity index 100% rename from site/content/tutorial/09-lifecycle/02-ondestroy/app-a/App.svelte rename to site/content/tutorial/07-lifecycle/02-ondestroy/app-a/App.svelte diff --git a/site/content/tutorial/09-lifecycle/02-ondestroy/app-a/utils.js b/site/content/tutorial/07-lifecycle/02-ondestroy/app-a/utils.js similarity index 100% rename from site/content/tutorial/09-lifecycle/02-ondestroy/app-a/utils.js rename to site/content/tutorial/07-lifecycle/02-ondestroy/app-a/utils.js diff --git a/site/content/tutorial/09-lifecycle/02-ondestroy/app-b/App.svelte b/site/content/tutorial/07-lifecycle/02-ondestroy/app-b/App.svelte similarity index 100% rename from site/content/tutorial/09-lifecycle/02-ondestroy/app-b/App.svelte rename to site/content/tutorial/07-lifecycle/02-ondestroy/app-b/App.svelte diff --git a/site/content/tutorial/09-lifecycle/02-ondestroy/app-b/utils.js b/site/content/tutorial/07-lifecycle/02-ondestroy/app-b/utils.js similarity index 100% rename from site/content/tutorial/09-lifecycle/02-ondestroy/app-b/utils.js rename to site/content/tutorial/07-lifecycle/02-ondestroy/app-b/utils.js diff --git a/site/content/tutorial/09-lifecycle/02-ondestroy/text.md b/site/content/tutorial/07-lifecycle/02-ondestroy/text.md similarity index 100% rename from site/content/tutorial/09-lifecycle/02-ondestroy/text.md rename to site/content/tutorial/07-lifecycle/02-ondestroy/text.md diff --git a/site/content/tutorial/09-lifecycle/03-update/app-a/App.svelte b/site/content/tutorial/07-lifecycle/03-update/app-a/App.svelte similarity index 100% rename from site/content/tutorial/09-lifecycle/03-update/app-a/App.svelte rename to site/content/tutorial/07-lifecycle/03-update/app-a/App.svelte diff --git a/site/content/tutorial/09-lifecycle/03-update/app-b/App.svelte b/site/content/tutorial/07-lifecycle/03-update/app-b/App.svelte similarity index 100% rename from site/content/tutorial/09-lifecycle/03-update/app-b/App.svelte rename to site/content/tutorial/07-lifecycle/03-update/app-b/App.svelte diff --git a/site/content/tutorial/09-lifecycle/03-update/text.md b/site/content/tutorial/07-lifecycle/03-update/text.md similarity index 100% rename from site/content/tutorial/09-lifecycle/03-update/text.md rename to site/content/tutorial/07-lifecycle/03-update/text.md diff --git a/site/content/tutorial/09-lifecycle/meta.json b/site/content/tutorial/07-lifecycle/meta.json similarity index 100% rename from site/content/tutorial/09-lifecycle/meta.json rename to site/content/tutorial/07-lifecycle/meta.json diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-a/App.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-a/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-a/App.svelte rename to site/content/tutorial/08-stores/01-writable-stores/app-a/App.svelte diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-a/Decrementer.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-a/Decrementer.svelte similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-a/Decrementer.svelte rename to site/content/tutorial/08-stores/01-writable-stores/app-a/Decrementer.svelte diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-a/Incrementer.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-a/Incrementer.svelte similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-a/Incrementer.svelte rename to site/content/tutorial/08-stores/01-writable-stores/app-a/Incrementer.svelte diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-a/Resetter.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-a/Resetter.svelte similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-a/Resetter.svelte rename to site/content/tutorial/08-stores/01-writable-stores/app-a/Resetter.svelte diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-a/stores.js b/site/content/tutorial/08-stores/01-writable-stores/app-a/stores.js similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-a/stores.js rename to site/content/tutorial/08-stores/01-writable-stores/app-a/stores.js diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-b/App.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-b/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-b/App.svelte rename to site/content/tutorial/08-stores/01-writable-stores/app-b/App.svelte diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-b/Decrementer.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-b/Decrementer.svelte similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-b/Decrementer.svelte rename to site/content/tutorial/08-stores/01-writable-stores/app-b/Decrementer.svelte diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-b/Incrementer.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-b/Incrementer.svelte similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-b/Incrementer.svelte rename to site/content/tutorial/08-stores/01-writable-stores/app-b/Incrementer.svelte diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-b/Resetter.svelte b/site/content/tutorial/08-stores/01-writable-stores/app-b/Resetter.svelte similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-b/Resetter.svelte rename to site/content/tutorial/08-stores/01-writable-stores/app-b/Resetter.svelte diff --git a/site/content/tutorial/07-stores/01-writable-stores/app-b/stores.js b/site/content/tutorial/08-stores/01-writable-stores/app-b/stores.js similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/app-b/stores.js rename to site/content/tutorial/08-stores/01-writable-stores/app-b/stores.js diff --git a/site/content/tutorial/07-stores/01-writable-stores/text.md b/site/content/tutorial/08-stores/01-writable-stores/text.md similarity index 100% rename from site/content/tutorial/07-stores/01-writable-stores/text.md rename to site/content/tutorial/08-stores/01-writable-stores/text.md diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-a/App.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-a/App.svelte rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-a/App.svelte diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-a/Decrementer.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Decrementer.svelte similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-a/Decrementer.svelte rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Decrementer.svelte diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-a/Incrementer.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Incrementer.svelte similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-a/Incrementer.svelte rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Incrementer.svelte diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-a/Resetter.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Resetter.svelte similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-a/Resetter.svelte rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-a/Resetter.svelte diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-a/stores.js b/site/content/tutorial/08-stores/02-auto-subscriptions/app-a/stores.js similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-a/stores.js rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-a/stores.js diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-b/App.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-b/App.svelte rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-b/App.svelte diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-b/Decrementer.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Decrementer.svelte similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-b/Decrementer.svelte rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Decrementer.svelte diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-b/Incrementer.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Incrementer.svelte similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-b/Incrementer.svelte rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Incrementer.svelte diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-b/Resetter.svelte b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Resetter.svelte similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-b/Resetter.svelte rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-b/Resetter.svelte diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/app-b/stores.js b/site/content/tutorial/08-stores/02-auto-subscriptions/app-b/stores.js similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/app-b/stores.js rename to site/content/tutorial/08-stores/02-auto-subscriptions/app-b/stores.js diff --git a/site/content/tutorial/07-stores/02-auto-subscriptions/text.md b/site/content/tutorial/08-stores/02-auto-subscriptions/text.md similarity index 100% rename from site/content/tutorial/07-stores/02-auto-subscriptions/text.md rename to site/content/tutorial/08-stores/02-auto-subscriptions/text.md diff --git a/site/content/tutorial/07-stores/03-readable-stores/app-a/App.svelte b/site/content/tutorial/08-stores/03-readable-stores/app-a/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/03-readable-stores/app-a/App.svelte rename to site/content/tutorial/08-stores/03-readable-stores/app-a/App.svelte diff --git a/site/content/tutorial/07-stores/03-readable-stores/app-a/stores.js b/site/content/tutorial/08-stores/03-readable-stores/app-a/stores.js similarity index 100% rename from site/content/tutorial/07-stores/03-readable-stores/app-a/stores.js rename to site/content/tutorial/08-stores/03-readable-stores/app-a/stores.js diff --git a/site/content/tutorial/07-stores/03-readable-stores/app-b/App.svelte b/site/content/tutorial/08-stores/03-readable-stores/app-b/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/03-readable-stores/app-b/App.svelte rename to site/content/tutorial/08-stores/03-readable-stores/app-b/App.svelte diff --git a/site/content/tutorial/07-stores/03-readable-stores/app-b/stores.js b/site/content/tutorial/08-stores/03-readable-stores/app-b/stores.js similarity index 100% rename from site/content/tutorial/07-stores/03-readable-stores/app-b/stores.js rename to site/content/tutorial/08-stores/03-readable-stores/app-b/stores.js diff --git a/site/content/tutorial/07-stores/03-readable-stores/text.md b/site/content/tutorial/08-stores/03-readable-stores/text.md similarity index 100% rename from site/content/tutorial/07-stores/03-readable-stores/text.md rename to site/content/tutorial/08-stores/03-readable-stores/text.md diff --git a/site/content/tutorial/07-stores/04-derived-stores/app-a/App.svelte b/site/content/tutorial/08-stores/04-derived-stores/app-a/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/04-derived-stores/app-a/App.svelte rename to site/content/tutorial/08-stores/04-derived-stores/app-a/App.svelte diff --git a/site/content/tutorial/07-stores/04-derived-stores/app-a/stores.js b/site/content/tutorial/08-stores/04-derived-stores/app-a/stores.js similarity index 100% rename from site/content/tutorial/07-stores/04-derived-stores/app-a/stores.js rename to site/content/tutorial/08-stores/04-derived-stores/app-a/stores.js diff --git a/site/content/tutorial/07-stores/04-derived-stores/app-b/App.svelte b/site/content/tutorial/08-stores/04-derived-stores/app-b/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/04-derived-stores/app-b/App.svelte rename to site/content/tutorial/08-stores/04-derived-stores/app-b/App.svelte diff --git a/site/content/tutorial/07-stores/04-derived-stores/app-b/stores.js b/site/content/tutorial/08-stores/04-derived-stores/app-b/stores.js similarity index 100% rename from site/content/tutorial/07-stores/04-derived-stores/app-b/stores.js rename to site/content/tutorial/08-stores/04-derived-stores/app-b/stores.js diff --git a/site/content/tutorial/07-stores/04-derived-stores/text.md b/site/content/tutorial/08-stores/04-derived-stores/text.md similarity index 100% rename from site/content/tutorial/07-stores/04-derived-stores/text.md rename to site/content/tutorial/08-stores/04-derived-stores/text.md diff --git a/site/content/tutorial/07-stores/05-custom-stores/app-a/App.svelte b/site/content/tutorial/08-stores/05-custom-stores/app-a/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/05-custom-stores/app-a/App.svelte rename to site/content/tutorial/08-stores/05-custom-stores/app-a/App.svelte diff --git a/site/content/tutorial/07-stores/05-custom-stores/app-a/stores.js b/site/content/tutorial/08-stores/05-custom-stores/app-a/stores.js similarity index 100% rename from site/content/tutorial/07-stores/05-custom-stores/app-a/stores.js rename to site/content/tutorial/08-stores/05-custom-stores/app-a/stores.js diff --git a/site/content/tutorial/07-stores/05-custom-stores/app-b/App.svelte b/site/content/tutorial/08-stores/05-custom-stores/app-b/App.svelte similarity index 100% rename from site/content/tutorial/07-stores/05-custom-stores/app-b/App.svelte rename to site/content/tutorial/08-stores/05-custom-stores/app-b/App.svelte diff --git a/site/content/tutorial/07-stores/05-custom-stores/app-b/stores.js b/site/content/tutorial/08-stores/05-custom-stores/app-b/stores.js similarity index 100% rename from site/content/tutorial/07-stores/05-custom-stores/app-b/stores.js rename to site/content/tutorial/08-stores/05-custom-stores/app-b/stores.js diff --git a/site/content/tutorial/07-stores/05-custom-stores/text.md b/site/content/tutorial/08-stores/05-custom-stores/text.md similarity index 100% rename from site/content/tutorial/07-stores/05-custom-stores/text.md rename to site/content/tutorial/08-stores/05-custom-stores/text.md diff --git a/site/content/tutorial/07-stores/meta.json b/site/content/tutorial/08-stores/meta.json similarity index 100% rename from site/content/tutorial/07-stores/meta.json rename to site/content/tutorial/08-stores/meta.json diff --git a/site/content/tutorial/08-motion/01-tweened/app-a/App.svelte b/site/content/tutorial/09-motion/01-tweened/app-a/App.svelte similarity index 100% rename from site/content/tutorial/08-motion/01-tweened/app-a/App.svelte rename to site/content/tutorial/09-motion/01-tweened/app-a/App.svelte diff --git a/site/content/tutorial/08-motion/01-tweened/app-b/App.svelte b/site/content/tutorial/09-motion/01-tweened/app-b/App.svelte similarity index 100% rename from site/content/tutorial/08-motion/01-tweened/app-b/App.svelte rename to site/content/tutorial/09-motion/01-tweened/app-b/App.svelte diff --git a/site/content/tutorial/08-motion/01-tweened/text.md b/site/content/tutorial/09-motion/01-tweened/text.md similarity index 89% rename from site/content/tutorial/08-motion/01-tweened/text.md rename to site/content/tutorial/09-motion/01-tweened/text.md index 23f4147a9d..def011c993 100644 --- a/site/content/tutorial/08-motion/01-tweened/text.md +++ b/site/content/tutorial/09-motion/01-tweened/text.md @@ -28,13 +28,13 @@ Clicking the buttons causes the progress bar to animate to its new value. It's a ``` -> The `svelte/easing` module contains the [Penner easing equations](http://robertpenner.com/easing/), or you can supply your own `t => u` function where `t` and `u` are both values between 0 and 1. +> The `svelte/easing` module contains the [Penner easing equations](http://robertpenner.com/easing/), or you can supply your own `p => t` function where `p` and `t` are both values between 0 and 1. The full set of options available to `tweened`: * `delay` — milliseconds before the tween starts * `duration` — either the duration of the tween in milliseconds, or a `(from, to) => milliseconds` function allowing you to (e.g.) specify longer tweens for larger changes in value -* `easing` — a `t => u` function -* `interpolate` — a custom `(from, to) => u => value` function for interpolating between arbitrary values. By default, Svelte will interpolate between numbers, dates, and identically-shaped arrays and objects (as long as they only contain numbers and dates or other valid arrays and objects). If you want to interpolate (for example) colour strings or transformation matrices, supply a custom interpolator +* `easing` — a `p => t` function +* `interpolate` — a custom `(from, to) => t => value` function for interpolating between arbitrary values. By default, Svelte will interpolate between numbers, dates, and identically-shaped arrays and objects (as long as they only contain numbers and dates or other valid arrays and objects). If you want to interpolate (for example) colour strings or transformation matrices, supply a custom interpolator You can also pass these options to `progress.set` and `progress.update` as a second argument, in which case they will override the defaults. The `set` and `update` methods both return a promise that resolves when the tween completes. \ No newline at end of file diff --git a/site/content/tutorial/08-motion/02-spring/app-a/App.svelte b/site/content/tutorial/09-motion/02-spring/app-a/App.svelte similarity index 100% rename from site/content/tutorial/08-motion/02-spring/app-a/App.svelte rename to site/content/tutorial/09-motion/02-spring/app-a/App.svelte diff --git a/site/content/tutorial/08-motion/02-spring/app-b/App.svelte b/site/content/tutorial/09-motion/02-spring/app-b/App.svelte similarity index 100% rename from site/content/tutorial/08-motion/02-spring/app-b/App.svelte rename to site/content/tutorial/09-motion/02-spring/app-b/App.svelte diff --git a/site/content/tutorial/08-motion/02-spring/text.md b/site/content/tutorial/09-motion/02-spring/text.md similarity index 100% rename from site/content/tutorial/08-motion/02-spring/text.md rename to site/content/tutorial/09-motion/02-spring/text.md diff --git a/site/content/tutorial/08-motion/meta.json b/site/content/tutorial/09-motion/meta.json similarity index 100% rename from site/content/tutorial/08-motion/meta.json rename to site/content/tutorial/09-motion/meta.json diff --git a/site/content/tutorial/10-transitions/01-transition/app-a/App.svelte b/site/content/tutorial/10-transitions/01-transition/app-a/App.svelte new file mode 100644 index 0000000000..fdb1d21540 --- /dev/null +++ b/site/content/tutorial/10-transitions/01-transition/app-a/App.svelte @@ -0,0 +1,14 @@ + + + + +{#if visible} +

+ Fades in and out +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/01-transition/app-b/App.svelte b/site/content/tutorial/10-transitions/01-transition/app-b/App.svelte new file mode 100644 index 0000000000..b7909fb86e --- /dev/null +++ b/site/content/tutorial/10-transitions/01-transition/app-b/App.svelte @@ -0,0 +1,15 @@ + + + + +{#if visible} +

+ Fades in and out +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/01-transition/text.md b/site/content/tutorial/10-transitions/01-transition/text.md new file mode 100644 index 0000000000..741511f233 --- /dev/null +++ b/site/content/tutorial/10-transitions/01-transition/text.md @@ -0,0 +1,20 @@ +--- +title: The transition directive +--- + +We can make more appealing user interfaces by gracefully transitioning elements into and out of the DOM. Svelte makes this very easy with the `transition` directive. + +First, import the `fade` function from `svelte/transition`... + +```html + +``` + +...then add it to the `

` element: + +```html +

Fades in and out

+``` \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/02-adding-parameters/app-a/App.svelte b/site/content/tutorial/10-transitions/02-adding-parameters/app-a/App.svelte new file mode 100644 index 0000000000..b7909fb86e --- /dev/null +++ b/site/content/tutorial/10-transitions/02-adding-parameters/app-a/App.svelte @@ -0,0 +1,15 @@ + + + + +{#if visible} +

+ Fades in and out +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/02-adding-parameters/app-b/App.svelte b/site/content/tutorial/10-transitions/02-adding-parameters/app-b/App.svelte new file mode 100644 index 0000000000..01047f5e37 --- /dev/null +++ b/site/content/tutorial/10-transitions/02-adding-parameters/app-b/App.svelte @@ -0,0 +1,15 @@ + + + + +{#if visible} +

+ Flies in and out +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/02-adding-parameters/text.md b/site/content/tutorial/10-transitions/02-adding-parameters/text.md new file mode 100644 index 0000000000..5712b7e8c4 --- /dev/null +++ b/site/content/tutorial/10-transitions/02-adding-parameters/text.md @@ -0,0 +1,22 @@ +--- +title: Adding parameters +--- + +Transition functions can accept parameters. Replace the `fade` transition with `fly`... + +```html + +``` + +...and apply it to the `

` along with some options: + +```html +

+ Flies in and out +

+``` + +Note that the transition is *reversible* — if you toggle the checkbox while the transition is ongoing, it transitions from the current point, rather than the beginning or the end. \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/03-in-and-out/app-a/App.svelte b/site/content/tutorial/10-transitions/03-in-and-out/app-a/App.svelte new file mode 100644 index 0000000000..01047f5e37 --- /dev/null +++ b/site/content/tutorial/10-transitions/03-in-and-out/app-a/App.svelte @@ -0,0 +1,15 @@ + + + + +{#if visible} +

+ Flies in and out +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/03-in-and-out/app-b/App.svelte b/site/content/tutorial/10-transitions/03-in-and-out/app-b/App.svelte new file mode 100644 index 0000000000..36d36664e6 --- /dev/null +++ b/site/content/tutorial/10-transitions/03-in-and-out/app-b/App.svelte @@ -0,0 +1,15 @@ + + + + +{#if visible} +

+ Flies in, fades out +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/03-in-and-out/text.md b/site/content/tutorial/10-transitions/03-in-and-out/text.md new file mode 100644 index 0000000000..21cb221342 --- /dev/null +++ b/site/content/tutorial/10-transitions/03-in-and-out/text.md @@ -0,0 +1,13 @@ +--- +title: In and out +--- + +Instead of the `transition` directive, an element can have an `in` or an `out` directive, or both together: + +```html +

+ Flies in, fades out +

+``` + +In this case, the transitions are *not* reversed. \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/04-custom-css-transitions/app-a/App.svelte b/site/content/tutorial/10-transitions/04-custom-css-transitions/app-a/App.svelte new file mode 100644 index 0000000000..d1f044360d --- /dev/null +++ b/site/content/tutorial/10-transitions/04-custom-css-transitions/app-a/App.svelte @@ -0,0 +1,38 @@ + + + + + + +{#if visible} +
+ transitions! +
+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/04-custom-css-transitions/app-b/App.svelte b/site/content/tutorial/10-transitions/04-custom-css-transitions/app-b/App.svelte new file mode 100644 index 0000000000..6e8dfcaf08 --- /dev/null +++ b/site/content/tutorial/10-transitions/04-custom-css-transitions/app-b/App.svelte @@ -0,0 +1,49 @@ + + + + + + +{#if visible} +
+ transitions! +
+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/04-custom-css-transitions/text.md b/site/content/tutorial/10-transitions/04-custom-css-transitions/text.md new file mode 100644 index 0000000000..4bae964c4c --- /dev/null +++ b/site/content/tutorial/10-transitions/04-custom-css-transitions/text.md @@ -0,0 +1,72 @@ +--- +title: Custom CSS transitions +--- + +The `svelte/transition` module has a handful of built-in transitions, but it's very easy to create your own. By way of example, this is the source of the `fade` transition: + +```js +function fade(node, { + delay = 0, + duration = 400 +}) { + const o = +getComputedStyle(node).opacity; + + return { + delay, + duration, + css: t => `opacity: ${t * o}` + }; +} +``` + +The function takes two arguments — the node to which the transition is applied, and any parameters that were passed in — and returns a transition object which can have the following properties: + +* `delay` — milliseconds before the transition begins +* `duration` — length of the transition in milliseconds +* `easing` — a `p => t` easing function (see the chapter on [tweening](tutorial/tweened)) +* `css` — a `(t, u) => css` function, where `u === 1 - t` +* `tick` — a `(t, u) => {...}` function that has some effect on the node + +The `t` value is `0` at the beginning of an intro or the end of an outro, and `1` at the end of an intro or beginning of an outro. + +Most of the time you should return the `css` property and *not* the `tick` property, as CSS animations run off the main thread to prevent jank where possible. Svelte 'simulates' the transition and constructs a CSS animation, then lets it run. + +For example the `fade` transition generates a CSS animation somewhat like this: + +```css +0% { opacity: 0 } +10% { opacity: 0.1 } +20% { opacity: 0.2 } +/* ... */ +100% { opacity: 1 } +``` + +We can get a lot more creative though. Let's make something truly gratuitous: + +```html + +``` + +Remember: with great power comes great responsibility. \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/05-custom-js-transitions/app-a/App.svelte b/site/content/tutorial/10-transitions/05-custom-js-transitions/app-a/App.svelte new file mode 100644 index 0000000000..11a8ec3ef5 --- /dev/null +++ b/site/content/tutorial/10-transitions/05-custom-js-transitions/app-a/App.svelte @@ -0,0 +1,22 @@ + + + + +{#if visible} +

+ The quick brown fox jumps over the lazy dog +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/05-custom-js-transitions/app-b/App.svelte b/site/content/tutorial/10-transitions/05-custom-js-transitions/app-b/App.svelte new file mode 100644 index 0000000000..3b3fb94d1c --- /dev/null +++ b/site/content/tutorial/10-transitions/05-custom-js-transitions/app-b/App.svelte @@ -0,0 +1,36 @@ + + + + +{#if visible} +

+ The quick brown fox jumps over the lazy dog +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/05-custom-js-transitions/text.md b/site/content/tutorial/10-transitions/05-custom-js-transitions/text.md new file mode 100644 index 0000000000..da775bbeb3 --- /dev/null +++ b/site/content/tutorial/10-transitions/05-custom-js-transitions/text.md @@ -0,0 +1,29 @@ +--- +title: Custom JS transitions +--- + +While you should generally use CSS for transitions as much as possible, there are some effects that can't be achieved without JavaScript, such as a typewriter effect: + +```js +function typewriter(node, { speed = 50 }) { + const valid = ( + node.childNodes.length === 1 && + node.childNodes[0].nodeType === 3 + ); + + if (!valid) { + throw new Error(`This transition only works on elements with a single text node child`); + } + + const text = node.textContent; + const duration = text.length * speed; + + return { + duration, + tick: t => { + const i = ~~(text.length * t); + node.textContent = text.slice(0, i); + } + }; +} +``` \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/06-transition-events/app-a/App.svelte b/site/content/tutorial/10-transitions/06-transition-events/app-a/App.svelte new file mode 100644 index 0000000000..3369af077f --- /dev/null +++ b/site/content/tutorial/10-transitions/06-transition-events/app-a/App.svelte @@ -0,0 +1,19 @@ + + +

status: {status}

+ + + +{#if visible} +

+ Flies in and out +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/06-transition-events/app-b/App.svelte b/site/content/tutorial/10-transitions/06-transition-events/app-b/App.svelte new file mode 100644 index 0000000000..da79897365 --- /dev/null +++ b/site/content/tutorial/10-transitions/06-transition-events/app-b/App.svelte @@ -0,0 +1,25 @@ + + +

status: {status}

+ + + +{#if visible} +

+ Flies in and out +

+{/if} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/06-transition-events/text.md b/site/content/tutorial/10-transitions/06-transition-events/text.md new file mode 100644 index 0000000000..5b87149162 --- /dev/null +++ b/site/content/tutorial/10-transitions/06-transition-events/text.md @@ -0,0 +1,17 @@ +--- +title: Transition events +--- + +It can be useful to know when transitions are beginning and ending. Svelte dispatches events that you can listen to like any other DOM event: + +```html +

+ Flies in and out +

+``` \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/07-deferred-transitions/app-a/App.svelte b/site/content/tutorial/10-transitions/07-deferred-transitions/app-a/App.svelte new file mode 100644 index 0000000000..c46096c204 --- /dev/null +++ b/site/content/tutorial/10-transitions/07-deferred-transitions/app-a/App.svelte @@ -0,0 +1,146 @@ + + + + +
+ + +
+

todo

+ {#each todos.filter(t => !t.done) as todo (todo.id)} + + {/each} +
+ +
+

done

+ {#each todos.filter(t => t.done) as todo (todo.id)} + + {/each} +
+
\ No newline at end of file diff --git a/site/content/tutorial/10-transitions/07-deferred-transitions/app-a/crossfade.js b/site/content/tutorial/10-transitions/07-deferred-transitions/app-a/crossfade.js new file mode 100644 index 0000000000..e11e18b60e --- /dev/null +++ b/site/content/tutorial/10-transitions/07-deferred-transitions/app-a/crossfade.js @@ -0,0 +1,65 @@ +import { quintOut } from 'svelte/easing'; + +export default function crossfade({ send, receive, fallback }) { + let requested = new Map(); + let provided = new Map(); + + function crossfade(from, node) { + const to = node.getBoundingClientRect(); + const dx = from.left - to.left; + const dy = from.top - to.top; + + const style = getComputedStyle(node); + const transform = style.transform === 'none' ? '' : style.transform; + + return { + duration: 400, + easing: quintOut, + css: (t, u) => ` + opacity: ${t}; + transform: ${transform} translate(${u * dx}px,${u * dy}px); + ` + }; + } + + return { + send(node, params) { + provided.set(params.key, { + rect: node.getBoundingClientRect() + }); + + return () => { + if (requested.has(params.key)) { + const { rect } = requested.get(params.key); + requested.delete(params.key); + + return crossfade(rect, node); + } + + // if the node is disappearing altogether + // (i.e. wasn't claimed by the other list) + // then we need to supply an outro + provided.delete(params.key); + return fallback(node, params); + }; + }, + + receive(node, params) { + requested.set(params.key, { + rect: node.getBoundingClientRect() + }); + + return () => { + if (provided.has(params.key)) { + const { rect } = provided.get(params.key); + provided.delete(params.key); + + return crossfade(rect, node); + } + + requested.delete(params.key); + return fallback(node, params); + }; + } + }; +} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/07-deferred-transitions/app-b/App.svelte b/site/content/tutorial/10-transitions/07-deferred-transitions/app-b/App.svelte new file mode 100644 index 0000000000..c46096c204 --- /dev/null +++ b/site/content/tutorial/10-transitions/07-deferred-transitions/app-b/App.svelte @@ -0,0 +1,146 @@ + + + + +
+ + +
+

todo

+ {#each todos.filter(t => !t.done) as todo (todo.id)} + + {/each} +
+ +
+

done

+ {#each todos.filter(t => t.done) as todo (todo.id)} + + {/each} +
+
\ No newline at end of file diff --git a/site/content/tutorial/10-transitions/07-deferred-transitions/app-b/crossfade.js b/site/content/tutorial/10-transitions/07-deferred-transitions/app-b/crossfade.js new file mode 100644 index 0000000000..e11e18b60e --- /dev/null +++ b/site/content/tutorial/10-transitions/07-deferred-transitions/app-b/crossfade.js @@ -0,0 +1,65 @@ +import { quintOut } from 'svelte/easing'; + +export default function crossfade({ send, receive, fallback }) { + let requested = new Map(); + let provided = new Map(); + + function crossfade(from, node) { + const to = node.getBoundingClientRect(); + const dx = from.left - to.left; + const dy = from.top - to.top; + + const style = getComputedStyle(node); + const transform = style.transform === 'none' ? '' : style.transform; + + return { + duration: 400, + easing: quintOut, + css: (t, u) => ` + opacity: ${t}; + transform: ${transform} translate(${u * dx}px,${u * dy}px); + ` + }; + } + + return { + send(node, params) { + provided.set(params.key, { + rect: node.getBoundingClientRect() + }); + + return () => { + if (requested.has(params.key)) { + const { rect } = requested.get(params.key); + requested.delete(params.key); + + return crossfade(rect, node); + } + + // if the node is disappearing altogether + // (i.e. wasn't claimed by the other list) + // then we need to supply an outro + provided.delete(params.key); + return fallback(node, params); + }; + }, + + receive(node, params) { + requested.set(params.key, { + rect: node.getBoundingClientRect() + }); + + return () => { + if (provided.has(params.key)) { + const { rect } = provided.get(params.key); + provided.delete(params.key); + + return crossfade(rect, node); + } + + requested.delete(params.key); + return fallback(node, params); + }; + } + }; +} \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/07-deferred-transitions/text.md b/site/content/tutorial/10-transitions/07-deferred-transitions/text.md new file mode 100644 index 0000000000..e649762f57 --- /dev/null +++ b/site/content/tutorial/10-transitions/07-deferred-transitions/text.md @@ -0,0 +1,7 @@ +--- +title: Deferred transitions +--- + +A particularly powerful feature of Svelte's transition engine is the ability to *defer* transitions, so that they can be coordinated between multiple elements. + +TODO https://github.com/sveltejs/svelte/issues/2159 \ No newline at end of file diff --git a/site/content/tutorial/10-transitions/meta.json b/site/content/tutorial/10-transitions/meta.json new file mode 100644 index 0000000000..cb9291d73f --- /dev/null +++ b/site/content/tutorial/10-transitions/meta.json @@ -0,0 +1,3 @@ +{ + "title": "Transitions" +} \ No newline at end of file diff --git a/site/content/tutorial/99-todo/99-todo/text.md b/site/content/tutorial/99-todo/99-todo/text.md index 085bfd5afc..93cbdb6121 100644 --- a/site/content/tutorial/99-todo/99-todo/text.md +++ b/site/content/tutorial/99-todo/99-todo/text.md @@ -102,19 +102,15 @@ Maybe lifecycle should go first, since we're using `onMount` in the `this` demo? * [ ] how lifecycle functions behave in SSR mode? -## Context - -* [ ] `setContext` and `getContext` - - ## Transitions -* [ ] `transition` with built-in transitions -* [ ] Custom CSS transitions -* [ ] Custom JS transitions -* [ ] `in` -* [ ] `out` -* [ ] `on:introstart` etc +* [x] `transition` with built-in transitions +* [x] `in` +* [x] `out` +* [x] Custom CSS transitions +* [x] Custom JS transitions +* [x] Thunk(?) transitions +* [x] `on:introstart` etc ## Animations @@ -139,6 +135,11 @@ Maybe lifecycle should go first, since we're using `onMount` in the `this` demo? * [ ] `` and `let:bar` +## Context + +* [ ] `setContext` and `getContext` + + ## Special elements * [ ] ``