Skip to content

Commit

Permalink
fix #16
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxNB committed Aug 14, 2020
1 parent be3a6d4 commit 4414f8c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The tinro is highly declarative, very tiny ([~4.5 Kb (1.9 Kb gzipped)](https://g
- [Lazy loading](#lazy-loading-components)
- [Transitions](#transitions)
- [Guarded routes](#guarded-routes)
- [Scroll on top](#scroll-on-top)


## Install
Expand Down Expand Up @@ -246,7 +247,8 @@ There are two ways to get parameters in nested component:
<!-- Hello.svelte-->
<script>
import {router} from 'tinro';
let params = router.params();
let params = router.params();
// OR to force reactivity - $: params = router.params($router);
</script>

<h1>Hello, {params.name}!</h1>
Expand Down Expand Up @@ -397,3 +399,13 @@ You may protect routes from being loaded just using Svelte's logic like `{#if}`
```

Also you can create special guard component as shown in [this example](https://svelte.dev/repl/5673ff403af14411b0cd1785be3d996f).


### Scroll on top

Tinro doesn't control scroll of the your app. Sometimes you need to scroll on top of the page when navigating between pages. Just add the `router` store subscription in your root component(ex. `App.svelte`). Using this way you can run any actions(not only a scroll), every time when `URL` changes.

```javascript
import {router} from `tinro`;
router.subscribe( _ => window.scrollTo(0, 0));
```

0 comments on commit 4414f8c

Please sign in to comment.