Skip to content

Commit c126c45

Browse files
bleucitronRomain Crestey
andcommitted
docs: 03-motion (#24)
* docs: 03-motion * docs: fix link --------- Co-authored-by: Romain Crestey <[email protected]>
1 parent a853ac8 commit c126c45

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

documentation/docs/03-runtime/03-svelte-motion.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
title: 'svelte/motion'
33
---
44

5-
The `svelte/motion` module exports two functions, `tweened` and `spring`, for creating writable stores whose values change over time after `set` and `update`, rather than immediately.
5+
Le module `svelte/motion` exporte deux fonctions, `tweened` et `spring`, pour créer des <span class="vo">[stores](/docs/sveltejs#store)</span> de type `writable` dont les valeurs changent dans le temps après `set` et `update`, plutôt qu'immédiatement.
66

77
## `tweened`
88

99
> EXPORT_SNIPPET: svelte/motion#tweened
1010
11-
Tweened stores update their values over a fixed duration. The following options are available:
11+
Les <span class="vo">[stores](/docs/sveltejs#store)</span> `tweened` mettent à jour leur valeur sur une durée fixe. Les options suivantes sont disponibles:
1212

13-
- `delay` (`number`, default 0) — milliseconds before starting
14-
- `duration` (`number` | `function`, default 400) — milliseconds the tween lasts
15-
- `easing` (`function`, default `t => t`) — an [easing function](/docs/svelte-easing)
16-
- `interpolate` (`function`) — see below
13+
* `delay` (`number`, par défaut 0) - millisecondes avant le démarrage
14+
* `duration` (`number` | `function`, par défaut 400) - durée de la transition en millisecondes
15+
* `easing` (`function`, par défaut `t => t`) - une [fonction de lissage (`easing function`)](/docs/svelte-easing)
16+
* `interpolate` (`function`) - voir ci-dessous
1717

18-
`store.set` and `store.update` can accept a second `options` argument that will override the options passed in upon instantiation.
18+
`store.set` et `store.update` peuvent accepter un second argument `options` qui remplacera les options passées à l'instanciation.
1919

20-
Both functions return a Promise that resolves when the tween completes. If the tween is interrupted, the promise will never resolve.
20+
Les deux fonctions retournent une promesse qui se résout lorsque la transition se termine. Si la transition est interrompue, la promesse ne sera jamais résolue.
2121

22-
Out of the box, Svelte will interpolate between two numbers, two arrays or two objects (as long as the arrays and objects are the same 'shape', and their 'leaf' properties are also numbers).
22+
Sans que vous n'ayez rien à faire, Svelte interpolera entre deux nombres, deux tableaux ou deux objets (tant que les tableaux et les objets ont la même "forme" et que leurs propriétés "feuilles" sont également des nombres).
2323

2424
```svelte
2525
<script>
@@ -32,17 +32,17 @@ Out of the box, Svelte will interpolate between two numbers, two arrays or two o
3232
});
3333
3434
function handleClick() {
35-
// this is equivalent to size.update(n => n + 1)
35+
// équivalent à size.update(n => n + 1)
3636
$size += 1;
3737
}
3838
</script>
3939
4040
<button on:click={handleClick} style="transform: scale({$size}); transform-origin: 0 0">
41-
embiggen
41+
grandir
4242
</button>
4343
```
4444

45-
If the initial value is `undefined` or `null`, the first value change will take effect immediately. This is useful when you have tweened values that are based on props, and don't want any motion when the component first renders.
45+
Si la valeur initiale est `undefined` ou `null`, le premier changement de valeur prendra effet immédiatement. Ceci est utile lorsque vous avez des valeurs d'interpolation qui sont basées sur des propriétés de composant et que vous ne voulez pas qu'il y ait de mouvement lors du premier rendu du composant.
4646

4747
```ts
4848
// @filename: ambient.d.ts
@@ -65,7 +65,7 @@ const size = tweened(undefined, {
6565
$: $size = big ? 100 : 10;
6666
```
6767

68-
The `interpolate` option allows you to tween between _any_ arbitrary values. It must be an `(a, b) => t => value` function, where `a` is the starting value, `b` is the target value, `t` is a number between 0 and 1, and `value` is the result. For example, we can use the [d3-interpolate](https://github.com/d3/d3-interpolate) package to smoothly interpolate between two colours.
68+
L'option `interpolate` vous permet de faire une transition entre _n'importe quelles_ valeurs arbitraires. Cette option doit être une fonction `(a, b) => t => value`, où `a` est la valeur de départ, `b` est la valeur cible, `t` est un nombre entre 0 et 1, et `value` est le résultat. Par exemple, il est possible d'utiliser [d3-interpolate](https://github.com/d3/d3-interpolate) pour interpoler entre deux couleurs.
6969

7070
```svelte
7171
<script>
@@ -93,13 +93,13 @@ The `interpolate` option allows you to tween between _any_ arbitrary values. It
9393

9494
> EXPORT_SNIPPET: svelte/motion#spring
9595
96-
A `spring` store gradually changes to its target value based on its `stiffness` and `damping` parameters. Whereas `tweened` stores change their values over a fixed duration, `spring` stores change over a duration that is determined by their existing velocity, allowing for more natural-seeming motion in many situations. The following options are available:
96+
Un <span class="vo">[store](/docs/sveltejs#store)</span> de type `spring` change progressivement vers sa valeur cible en fonction de ses paramètres `stiffness` (raideur) et `damping` (amortissement). Alors que les stores `tweened` changent leur valeur sur une durée fixe, les stores `spring` changent leur valeur sur une durée qui est déterminée par leur vélocité courante, permettant un mouvement plus naturel dans de nombreuses situations. Les options suivantes sont disponibles :
9797

98-
- `stiffness` (`number`, default `0.15`) — a value between 0 and 1 where higher means a 'tighter' spring
99-
- `damping` (`number`, default `0.8`) — a value between 0 and 1 where lower means a 'springier' spring
100-
- `precision` (`number`, default `0.01`) — determines the threshold at which the spring is considered to have 'settled', where lower means more precise
98+
* `stiffness` (`number`, par défaut `0.15`) - une valeur entre 0 et 1, où une valeur plus grande signifie un ressort plus 'raide'.
99+
* `damping` (`number`, par défaut `0.8`) - une valeur entre 0 et 1, où une valeur plus basse signifie un ressort plus 'élastique'.
100+
* `precision` (`number`, par défaut `0.01`) - détermine le seuil à partir duquel le ressort est considéré comme 'arrêté'. Une valeur plus basse signifie un ressort plus précis.
101101

102-
All of the options above can be changed while the spring is in motion, and will take immediate effect.
102+
Toutes les options ci-dessus peuvent être changées pendant que le ressort est en mouvement, et prendront effet immédiatement.
103103

104104
```js
105105
import { spring } from 'svelte/motion';
@@ -110,17 +110,17 @@ size.damping = 0.4;
110110
size.precision = 0.005;
111111
```
112112

113-
As with [`tweened`](/docs/svelte-motion#tweened) stores, `set` and `update` return a Promise that resolves if the spring settles.
113+
Comme avec les <span class="vo">[stores](/docs/sveltejs#store)</span> [`tweened`](/docs/svelte-motion#tweened), `set` et `update` retournent une promesse qui se résout lorsque le ressort s'arrête.
114114

115-
Both `set` and `update` can take a second argument — an object with `hard` or `soft` properties. `{ hard: true }` sets the target value immediately; `{ soft: n }` preserves existing momentum for `n` seconds before settling. `{ soft: true }` is equivalent to `{ soft: 0.5 }`.
115+
Les deux méthodes `set` et `update` peuvent prendre un second argument - un objet avec les propriétés `hard` ou `soft`. `{ hard: true }` fixe immédiatement la valeur cible ; `{ soft: n }` préserve l'élan actuel pendant `n` secondes avant de s'arrêter. `{ soft: true }` est équivalent à `{ soft: 0.5 }`.
116116

117117
```js
118118
import { spring } from 'svelte/motion';
119119

120120
const coords = spring({ x: 50, y: 50 });
121-
// updates the value immediately
121+
// change la valeur immédiatement
122122
coords.set({ x: 100, y: 200 }, { hard: true });
123-
// preserves existing momentum for 1s
123+
// garde l'élan actuel pendant 1s
124124
coords.update(
125125
(target_coords, coords) => {
126126
return { x: target_coords.x, y: coords.y };
@@ -129,7 +129,7 @@ coords.update(
129129
);
130130
```
131131

132-
[See a full example on the spring tutorial.](https://learn.svelte.dev/tutorial/springs)
132+
[Un exemple complet de store de type `spring` est disponible dans le tutoriel.](https://learn.svelte.dev/tutorial/springs)
133133

134134
```svelte
135135
<script>
@@ -145,7 +145,7 @@ coords.update(
145145
</script>
146146
```
147147

148-
If the initial value is `undefined` or `null`, the first value change will take effect immediately, just as with `tweened` values (see above).
148+
Si la valeur initiale est `undefined` ou `null`, le premier changement de valeur prendra effet immédiatement, comme pour les valeurs `tweened` (voir ci-dessus).
149149

150150
```ts
151151
// @filename: ambient.d.ts

0 commit comments

Comments
 (0)