mirror of
https://github.com/cupcakearmy/nicco.io.git
synced 2024-12-22 16:16:24 +00:00
scroll top
This commit is contained in:
parent
29a584f6b9
commit
44714c5c0c
@ -1,15 +1,29 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
|
import { stores } from '@sapper/app'
|
||||||
|
|
||||||
import Nav from '../components/Nav.svelte'
|
import Nav from '../components/Nav.svelte'
|
||||||
|
|
||||||
export let segment
|
export let segment
|
||||||
let wrapper
|
let wrapper
|
||||||
|
let main
|
||||||
|
|
||||||
function resize() {
|
function resize() {
|
||||||
wrapper.style.height = `${window.innerHeight}px`
|
wrapper.style.height = `${window.innerHeight}px`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { page } = stores()
|
||||||
|
let last = ''
|
||||||
|
|
||||||
|
$: {
|
||||||
|
const { host, path } = $page
|
||||||
|
const full = host + path
|
||||||
|
if (last !== full) {
|
||||||
|
last = full
|
||||||
|
if (main) setTimeout(() => (main.scrollTop = 0), 150)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const listener = window.addEventListener('resize', resize)
|
const listener = window.addEventListener('resize', resize)
|
||||||
resize()
|
resize()
|
||||||
@ -45,7 +59,7 @@
|
|||||||
|
|
||||||
<div bind:this={wrapper}>
|
<div bind:this={wrapper}>
|
||||||
<Nav {segment} />
|
<Nav {segment} />
|
||||||
<main>
|
<main bind:this={main}>
|
||||||
<slot />
|
<slot />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user