mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-20 08:02:12 +00:00
fix(web): scroll to top on navigate
This commit is contained in:
parent
0af1a464a5
commit
fb1630511a
1 changed files with 5 additions and 0 deletions
|
|
@ -6,6 +6,7 @@
|
|||
import { setContext } from 'svelte'
|
||||
import { writable } from 'simple-store-svelte'
|
||||
import VideoModal from '$lib/components/VideoModal.svelte'
|
||||
import { afterNavigate } from '$app/navigation'
|
||||
|
||||
setContext('video-modal', writable(false))
|
||||
|
||||
|
|
@ -56,6 +57,10 @@
|
|||
|
||||
t.addEventListener('scrollend', throttle(() => { scrollTop = updateScrollPosition() }, 1000))
|
||||
|
||||
afterNavigate(() => {
|
||||
t.scrollTop = pos = scrollTop = 0
|
||||
})
|
||||
|
||||
function update () {
|
||||
const delta = pos - scrollTop === smooth * 2 ? 0 : ((pos - scrollTop) / smooth) * getDeltaTime()
|
||||
scrollTop += delta
|
||||
|
|
|
|||
Loading…
Reference in a new issue