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
Setting values and watching the DOM update automatically is cool. Know what's even cooler? Tweening those values. Svelte includes tools to help you build slick user interfaces that use animation to communicate changes.
7
+
値を設定して DOM が自動的に更新されるのを見るのは最高です。もっと最高なのは?それらの値を *トゥイーン* することです。Svelte には、変化を伝えるためにアニメーションを使用するスムーズなユーザーインターフェースを構築するためのツールが含まれています。
8
8
9
-
Let's start by changing the `progress`store to a `tweened`value:
9
+
まず `progress`ストアを `tweened`値に変更してみましょう。
10
10
11
11
```svelte
12
12
<script>
@@ -16,7 +16,7 @@ Let's start by changing the `progress` store to a `tweened` value:
16
16
</script>
17
17
```
18
18
19
-
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:
@@ -30,13 +30,13 @@ Clicking the buttons causes the progress bar to animate to its new value. It's a
30
30
</script>
31
31
```
32
32
33
-
> 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.
-`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
-
-`easing` — a `p => t`function
40
-
-`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.
Waggle your mouse around, and try dragging the sliders to get a feel for how they affect the spring's behaviour. Notice that you can adjust the values while the spring is still in motion.
0 commit comments