You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/svelte.dev/content/tutorial/02-advanced-svelte/01-advanced-reactivity/05-stores/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: Introducing stores
2
+
title: Stores
3
3
---
4
4
5
5
Prior to the introduction of runes in Svelte 5, stores were the idiomatic way to handle reactive state outside components. That's no longer the case, but you'll still encounter stores when using Svelte (including in SvelteKit, for now), so it's worth knowing how to use them.
Clicking the buttons causes the progress bar to animate to its new value. It's a bit robotic and unsatisfying though. We need to add an easing function:
19
44
20
45
```svelte
21
46
/// file: App.svelte
22
47
<script>
23
-
import { tweened } from 'svelte/motion';
48
+
import { Tween } from 'svelte/motion';
24
49
+++import { cubicOut } from 'svelte/easing';+++
25
50
26
-
const progress = tweened(0, +++{
51
+
let progress = new Tween(0, +++{
27
52
duration: 400,
28
53
easing: cubicOut
29
54
}+++);
@@ -32,11 +57,11 @@ Clicking the buttons causes the progress bar to animate to its new value. It's a
32
57
33
58
> [!NOTE] The `svelte/easing` module contains the [Penner easing equations](https://web.archive.org/web/20190805215728/http://robertpenner.com/easing/), or you can supply your own `p => t` function where `p` and `t` are both values between 0 and 1.
34
59
35
-
The full set of options available to `tweened`:
60
+
The full set of options available to `Tween`:
36
61
37
62
-`delay` — milliseconds before the tween starts
38
63
-`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
39
64
-`easing` — a `p => t` function
40
65
-`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
41
66
42
-
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.
67
+
You can also call `progress.set(value, options)` instead of assigning directly to `progress.target`, in which case `options` will override the defaults. The `set`method returns a promise that resolves when the tween completes.
0 commit comments