Skip to content

Commit cf14f30

Browse files
authored
Merge branch 'working' into advanced/data-fetching.md
2 parents 3abd1e4 + 33d758c commit cf14f30

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

docs/en/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
- [Transitions (En)](advanced/transitions.md)
2222
- [La récupération de données](advanced/data-fetching.md)
2323
- [Les transitions](advanced/transitions.md)
24-
- [Scroll Behavior (En)](advanced/scroll-behavior.md)
24+
- [Comportement du défilement](advanced/scroll-behavior.md)
2525
- [Lazy Loading (En)](advanced/lazy-loading.md)
2626
- Réference de l'API
2727
- [router-link (En)](api/router-link.md)

docs/en/advanced/scroll-behavior.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
# Scroll Behavior (En) <br><br> *Cette page est en cours de traduction française. Revenez une autre fois pour lire une traduction achevée ou [participez à la traduction française ici](https://github.com/vuejs-fr/vue-router).*
1+
# Comportement du défilement
22

3-
When using client-side routing, we may want to scroll to top when navigating to a new route, or preserve the scrolling position of history entries just like real page reload does. `vue-router` allows you to achieve these and even better, allows you to completely customize the scroll behavior on route navigation.
3+
En utilisant le routage côté client, nous pourrions vouloir faire défiler la page jusqu'en haut lorsqu'on navigue vers une nouvelle route, ou alors préserver la position du défilement des entrées de l'historique comme le ferait une page réelle. `vue-router` vous permet de faire cela et, encore mieux, vous permet de changer le comportement du défilement pendant la navigation.
44

5-
**Note: this feature only works in HTML5 history mode.**
5+
**Note : cette fonctionnalité ne fonctionne qu'avec le mode historique HTML5.**
66

7-
When creating the router instance, you can provide the `scrollBehavior` function:
7+
Pendant la création de l'instance du routeur, vous pouvez renseigner la fonction `scrollBehavior` :
88

99
``` js
1010
const router = new VueRouter({
1111
routes: [...],
1212
scrollBehavior (to, from, savedPosition) {
13-
// return desired position
13+
// retourner la position désirée
1414
}
1515
})
1616
```
1717

18-
The `scrollBehavior` function receives the `to` and `from` route objects. The third argument, `savedPosition`, is only available if this is a `popstate` navigation (triggered by the browser's back/forward buttons).
18+
La fonction `scrollBehavior` reçoit les objets de route `to` et `from`. Le troisième argument, `savedPosition`, est disponible uniquement si c'est une navigation `popstate` (déclenchée par les boutons précédent/suivant du navigateur).
1919

20-
The function can return a scroll position object. The object could be in the form of:
20+
La fonction peut retourner un objet décrivant la position du défilement. L'objet peut être de la forme :
2121

22-
- `{ x: number, y: number }`
23-
- `{ selector: string }`
22+
- `{ x: number, y: number }`
23+
- `{ selector: String }`
2424

25-
If a falsy value or an empty object is returned, no scrolling will happen.
25+
Si une valeur équivalente à `false` ou un objet vide est retourné, aucun défilement ne sera produit.
2626

27-
For example:
27+
Par exemple :
2828

2929
``` js
3030
scrollBehavior (to, from, savedPosition) {
3131
return { x: 0, y: 0 }
3232
}
3333
```
3434

35-
This will simply make the page scroll to top for all route navigations.
35+
Cela permettra de défiler au haut de page à chaque navigation à travers les routes.
3636

37-
Returning the `savedPosition` will result in a native-like behavior when navigating with back/forward buttons:
37+
Retourner l'objet `savedPosition` résultera en un comportement quasi-natif en naviguant avec les boutons précédents/suivants :
3838

3939
``` js
4040
scrollBehavior (to, from, savedPosition) {
@@ -46,7 +46,7 @@ scrollBehavior (to, from, savedPosition) {
4646
}
4747
```
4848

49-
If you want to simulate the "scroll to anchor" behavior:
49+
Si vous voulez simuler le comportement « aller à l'ancre » :
5050

5151
``` js
5252
scrollBehavior (to, from, savedPosition) {
@@ -58,4 +58,4 @@ scrollBehavior (to, from, savedPosition) {
5858
}
5959
```
6060

61-
We can also use [route meta fields](meta.md) to implement fine-grained scroll behavior control. Check out a full example [here](https://github.com/vuejs/vue-router/blob/dev/examples/scroll-behavior/app.js).
61+
On peut aussi utiliser les [champs meta de route](meta.md) pour implémenter un contrôle bien précis pour le comportement du défilement. Allez voir un exemple complet [ici](https://github.com/vuejs/vue-router/blob/dev/examples/scroll-behavior/app.js).

0 commit comments

Comments
 (0)