Skip to content

Commit

Permalink
docs: add behavior option to scrollBehavior
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Nov 4, 2020
1 parent eafdcee commit da34ccd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/guide/advanced/scroll-behavior.md
Expand Up @@ -80,3 +80,18 @@ scrollBehavior (to, from, savedPosition) {
```

It's possible to hook this up with events from a page-level transition component to make the scroll behavior play nicely with your page transitions, but due to the possible variance and complexity in use cases, we simply provide this primitive to enable specific userland implementations.

## Smooth Scrolling

You can enable native smooth scrolling for [browsers supporting it](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions/behavior) by simply adding the `behavior` option to the object returned inside `scrollBehavior`:

```js
scrollBehavior (to, from, savedPosition) {
if (to.hash) {
return {
selector: to.hash
behavior: 'smooth',
}
}
}
```

0 comments on commit da34ccd

Please sign in to comment.