From c126c453e60bd6d160f7aee76b303490c329fe5e Mon Sep 17 00:00:00 2001 From: Romain l'Ourson Date: Sat, 15 Jul 2023 10:08:06 +0200 Subject: [PATCH] docs: 03-motion (#24) * docs: 03-motion * docs: fix link --------- Co-authored-by: Romain Crestey --- .../docs/03-runtime/03-svelte-motion.md | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/documentation/docs/03-runtime/03-svelte-motion.md b/documentation/docs/03-runtime/03-svelte-motion.md index a0b8d95623..eefd0615a9 100644 --- a/documentation/docs/03-runtime/03-svelte-motion.md +++ b/documentation/docs/03-runtime/03-svelte-motion.md @@ -2,24 +2,24 @@ title: 'svelte/motion' --- -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. +Le module `svelte/motion` exporte deux fonctions, `tweened` et `spring`, pour créer des [stores](/docs/sveltejs#store) de type `writable` dont les valeurs changent dans le temps après `set` et `update`, plutôt qu'immédiatement. ## `tweened` > EXPORT_SNIPPET: svelte/motion#tweened -Tweened stores update their values over a fixed duration. The following options are available: +Les [stores](/docs/sveltejs#store) `tweened` mettent à jour leur valeur sur une durée fixe. Les options suivantes sont disponibles: -- `delay` (`number`, default 0) — milliseconds before starting -- `duration` (`number` | `function`, default 400) — milliseconds the tween lasts -- `easing` (`function`, default `t => t`) — an [easing function](/docs/svelte-easing) -- `interpolate` (`function`) — see below +* `delay` (`number`, par défaut 0) - millisecondes avant le démarrage +* `duration` (`number` | `function`, par défaut 400) - durée de la transition en millisecondes +* `easing` (`function`, par défaut `t => t`) - une [fonction de lissage (`easing function`)](/docs/svelte-easing) +* `interpolate` (`function`) - voir ci-dessous -`store.set` and `store.update` can accept a second `options` argument that will override the options passed in upon instantiation. +`store.set` et `store.update` peuvent accepter un second argument `options` qui remplacera les options passées à l'instanciation. -Both functions return a Promise that resolves when the tween completes. If the tween is interrupted, the promise will never resolve. +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. -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). +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). ```svelte ``` -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. +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. ```ts // @filename: ambient.d.ts @@ -65,7 +65,7 @@ const size = tweened(undefined, { $: $size = big ? 100 : 10; ``` -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. +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. ```svelte ``` -If the initial value is `undefined` or `null`, the first value change will take effect immediately, just as with `tweened` values (see above). +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). ```ts // @filename: ambient.d.ts