Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Add docs for noscroll
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayphen committed Jul 16, 2020
1 parent 567863b commit 6d4306c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion site/content/docs/03-client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ sapper.start({
### goto(href, options?)

* `href` — the page to go to
* `options` — can include a `replaceState` property, which determines whether to use `history.pushState` (the default) or `history.replaceState`. Not required
* `options` - not required
* `replaceState` (`boolean`, default `false`) — determines whether to use `history.pushState` (the default) or `history.replaceState`.
* `noscroll` (`boolean`, default `false`) — prevent scroll to top after navigation.

Programmatically navigates to the given `href`. If the destination is a Sapper route, Sapper will handle the navigation, otherwise the page will be reloaded with the new `href`. In other words, the behaviour is as though the user clicked on a link with this `href`.

Expand Down
12 changes: 12 additions & 0 deletions site/content/docs/08-link-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ Adding a `rel=external` attribute to a link...
```

...will trigger a browser navigation when the link is clicked.

### sapper-noscroll

When navigating to internal links, Sapper will change the scroll position to 0,0 so that the user is at the very top left of the page. When a hash is defined, it will scroll to the element with a matching ID.

In certain cases, you may wish to disable this behaviour. Adding a `sapper-noscroll` attribute to a link...

```html
<a href='path' sapper-noscroll>Path</a>
```

...will prevent scrolling after the link is clicked.

0 comments on commit 6d4306c

Please sign in to comment.