fix: scroll not working
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 7s
This commit is contained in:
parent
d16428002d
commit
696ece1c5b
1 changed files with 9 additions and 5 deletions
|
|
@ -25,13 +25,13 @@ const md = new MarkdownIt()
|
||||||
.use(mditHighlight, { hljs })
|
.use(mditHighlight, { hljs })
|
||||||
.use(mditFigureWithPCaption, { figcaption: 'alt' });
|
.use(mditFigureWithPCaption, { figcaption: 'alt' });
|
||||||
|
|
||||||
|
const wrapper = ref<HTMLDivElement>();
|
||||||
const category = ref('');
|
const category = ref('');
|
||||||
const page = ref('');
|
const page = ref('');
|
||||||
const content = ref('');
|
const content = ref('');
|
||||||
const contentParsed = ref<ReturnType<typeof md.parse>>();
|
const contentParsed = ref<ReturnType<typeof md.parse>>();
|
||||||
const active = ref('');
|
const active = ref('');
|
||||||
const toc = ref(true);
|
const toc = ref(true);
|
||||||
const ts = ref(Date.now());
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (typeof ROUTE.params['category'] === 'string') {
|
if (typeof ROUTE.params['category'] === 'string') {
|
||||||
|
|
@ -93,19 +93,23 @@ async function scrollTo(id: string) {
|
||||||
await nextTick(() => {
|
await nextTick(() => {
|
||||||
if (window.innerWidth < 1024) toc.value = false;
|
if (window.innerWidth < 1024) toc.value = false;
|
||||||
});
|
});
|
||||||
if (pos)
|
if (pos) {
|
||||||
window.scrollTo({
|
wrapper.value?.scrollTo({
|
||||||
top: pos,
|
top: pos,
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main class="row full-height q-gutter-sm">
|
<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
|
<div
|
||||||
:key="ts"
|
|
||||||
style="
|
style="
|
||||||
width: 100%;
|
width: 100%;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue