feat: scroll to status (#127)

Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
patak 2022-11-26 16:38:55 +01:00 committed by GitHub
parent e51ca06f97
commit 5c60497421
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -7,6 +7,13 @@ const main = ref<Component | null>(null)
const status = window.history.state?.status ?? await fetchStatus(id)
const { data: context } = useAsyncData(`context:${id}`, () => masto.statuses.fetchContext(id))
const unsubscribe = watch(context, async (context) => {
if (context) {
const statusElement = document.querySelector(`#status-${id}`)
statusElement?.scrollIntoView()
unsubscribe()
}
}, { flush: 'post' })
</script>
<template>