fix(web): scroll to top on navigate

This commit is contained in:
ThaUnknown 2024-01-11 12:44:05 +01:00
parent 0af1a464a5
commit fb1630511a

View file

@ -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