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

Commit 6d4306c

Browse files
committed
Add docs for noscroll
1 parent 567863b commit 6d4306c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

site/content/docs/03-client-api.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ sapper.start({
2727
### goto(href, options?)
2828

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

3234
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`.
3335

site/content/docs/08-link-options.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,15 @@ Adding a `rel=external` attribute to a link...
3131
```
3232

3333
...will trigger a browser navigation when the link is clicked.
34+
35+
### sapper-noscroll
36+
37+
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.
38+
39+
In certain cases, you may wish to disable this behaviour. Adding a `sapper-noscroll` attribute to a link...
40+
41+
```html
42+
<a href='path' sapper-noscroll>Path</a>
43+
```
44+
45+
...will prevent scrolling after the link is clicked.

0 commit comments

Comments
 (0)