mirror of
https://github.com/ArthurDanjou/artsite.git
synced 2026-01-31 16:29:33 +01:00
Add smooth scroll
This commit is contained in:
@@ -56,6 +56,13 @@ async function handleLike() {
|
|||||||
await refresh()
|
await refresh()
|
||||||
likeCookie.value = true
|
likeCookie.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollToSection(id: string) {
|
||||||
|
const element = document.getElementById(id)
|
||||||
|
if (element) {
|
||||||
|
element.scrollIntoView({ behavior: 'smooth' })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -134,24 +141,12 @@ async function handleLike() {
|
|||||||
<UButton
|
<UButton
|
||||||
size="lg"
|
size="lg"
|
||||||
:label="link.text"
|
:label="link.text"
|
||||||
:to="`#${link.id}`"
|
|
||||||
variant="link"
|
variant="link"
|
||||||
color="neutral"
|
color="neutral"
|
||||||
:block="true"
|
:block="true"
|
||||||
class="flex justify-start items-start"
|
class="flex justify-start items-start"
|
||||||
|
@click="scrollToSection(link.id)"
|
||||||
/>
|
/>
|
||||||
<ol class="flex flex-col ml-2 list-decimal list-inside">
|
|
||||||
<UButton
|
|
||||||
v-for="child in link.children" :key="child.id"
|
|
||||||
size="sm"
|
|
||||||
:label="child.text"
|
|
||||||
:to="`#${child.id}`"
|
|
||||||
variant="link"
|
|
||||||
color="neutral"
|
|
||||||
:block="true"
|
|
||||||
class="px-4 flex justify-start items-start"
|
|
||||||
/>
|
|
||||||
</ol>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -236,9 +231,17 @@ async function handleLike() {
|
|||||||
@apply no-underline;
|
@apply no-underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.prose img {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.katex-html {
|
.katex-html {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<i18n lang="json">
|
<i18n lang="json">
|
||||||
|
|||||||
Reference in New Issue
Block a user