fix: scroll not working
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s

This commit is contained in:
Methapon2001 2025-03-17 16:40:29 +07:00
parent d16428002d
commit 696ece1c5b

View file

@ -25,13 +25,13 @@ const md = new MarkdownIt()
.use(mditHighlight, { hljs })
.use(mditFigureWithPCaption, { figcaption: 'alt' });
const wrapper = ref<HTMLDivElement>();
const category = ref('');
const page = ref('');
const content = ref('');
const contentParsed = ref<ReturnType<typeof md.parse>>();
const active = ref('');
const toc = ref(true);
const ts = ref(Date.now());
onMounted(async () => {
if (typeof ROUTE.params['category'] === 'string') {
@ -93,19 +93,23 @@ async function scrollTo(id: string) {
await nextTick(() => {
if (window.innerWidth < 1024) toc.value = false;
});
if (pos)
window.scrollTo({
if (pos) {
wrapper.value?.scrollTo({
top: pos,
behavior: 'smooth',
});
}
}
</script>
<template>
<main class="row full-height q-gutter-sm">
<section v-if="content" class="markdown col scroll full-height rounded">
<section
ref="wrapper"
v-if="content"
class="markdown col scroll full-height rounded"
>
<div
:key="ts"
style="
width: 100%;
flex: 1;