mirror of
https://github.com/cupcakearmy/nicco.io.git
synced 2024-12-22 08:06:29 +00:00
scroll top
This commit is contained in:
parent
29a584f6b9
commit
44714c5c0c
@ -1,15 +1,29 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte'
|
||||
import { stores } from '@sapper/app'
|
||||
|
||||
import Nav from '../components/Nav.svelte'
|
||||
|
||||
export let segment
|
||||
let wrapper
|
||||
let main
|
||||
|
||||
function resize() {
|
||||
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(() => {
|
||||
const listener = window.addEventListener('resize', resize)
|
||||
resize()
|
||||
@ -45,7 +59,7 @@
|
||||
|
||||
<div bind:this={wrapper}>
|
||||
<Nav {segment} />
|
||||
<main>
|
||||
<main bind:this={main}>
|
||||
<slot />
|
||||
</main>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user