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: documentation/docs/03-runtime/03-svelte-motion.md
+24-24Lines changed: 24 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -2,24 +2,24 @@
2
2
title: 'svelte/motion'
3
3
---
4
4
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 <spanclass="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.
6
6
7
7
## `tweened`
8
8
9
9
> EXPORT_SNIPPET: svelte/motion#tweened
10
10
11
-
Tweened stores update their values over a fixed duration. The following options are available:
11
+
Les <spanclass="vo">[stores](/docs/sveltejs#store)</span> `tweened` mettent à jour leur valeur sur une durée fixe. Les options suivantes sont disponibles:
12
12
13
-
-`delay` (`number`, default 0) — milliseconds before starting
-`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
17
17
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.
19
19
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.
21
21
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).
23
23
24
24
```svelte
25
25
<script>
@@ -32,17 +32,17 @@ Out of the box, Svelte will interpolate between two numbers, two arrays or two o
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.
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.
69
69
70
70
```svelte
71
71
<script>
@@ -93,13 +93,13 @@ The `interpolate` option allows you to tween between _any_ arbitrary values. It
93
93
94
94
> EXPORT_SNIPPET: svelte/motion#spring
95
95
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 <spanclass="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 :
97
97
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.
101
101
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.
103
103
104
104
```js
105
105
import { spring } from'svelte/motion';
@@ -110,17 +110,17 @@ size.damping = 0.4;
110
110
size.precision=0.005;
111
111
```
112
112
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 <spanclass="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.
114
114
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 }`.
116
116
117
117
```js
118
118
import { spring } from'svelte/motion';
119
119
120
120
constcoords=spring({ x:50, y:50 });
121
-
//updates the value immediately
121
+
//change la valeur immédiatement
122
122
coords.set({ x:100, y:200 }, { hard:true });
123
-
//preserves existing momentum for 1s
123
+
//garde l'élan actuel pendant 1s
124
124
coords.update(
125
125
(target_coords, coords) => {
126
126
return { x:target_coords.x, y:coords.y };
@@ -129,7 +129,7 @@ coords.update(
129
129
);
130
130
```
131
131
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)
133
133
134
134
```svelte
135
135
<script>
@@ -145,7 +145,7 @@ coords.update(
145
145
</script>
146
146
```
147
147
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).
0 commit comments