reduce dependencies, and stop blocking

This commit is contained in:
Zoe
2024-09-25 03:13:40 -05:00
parent d85b6e7fe8
commit d0fb293c76
16 changed files with 414 additions and 14221 deletions

View File

@@ -1,5 +1,4 @@
<script setup lang="ts">
import { watchDebounced } from '@vueuse/core'
import type { Ref } from 'vue';
const props = withDefaults(defineProps<{ doc: any, activeTocId: string | null }>(), {})
@@ -23,22 +22,24 @@ const onClick = (id: string) => {
const tocHeader = ref();
const tocIsClosed = ref(false);
watchDebounced(
watch(
() => props.activeTocId,
(newActiveTocId) => {
const h2Link = tocLinksH2.value.find((el: HTMLElement) => el.id === `toc-${newActiveTocId}`)
const h3Link = tocLinksH3.value.find((el: HTMLElement) => el.id === `toc-${newActiveTocId}`)
if (import.meta.client) {
const h2Link = tocLinksH2.value.find((el: HTMLElement) => el.id === `toc-${newActiveTocId}`)
const h3Link = tocLinksH3.value.find((el: HTMLElement) => el.id === `toc-${newActiveTocId}`)
// TODO: dont hard code these offsets
if (h2Link) {
sliderHeight.value = h2Link.offsetHeight
sliderTop.value = h2Link.offsetTop - 24
} else if (h3Link) {
sliderHeight.value = h3Link.offsetHeight
sliderTop.value = h3Link.offsetTop - 24
// TODO: dont hard code these offsets
if (h2Link) {
sliderHeight.value = h2Link.offsetHeight
sliderTop.value = h2Link.offsetTop - 24
} else if (h3Link) {
sliderHeight.value = h3Link.offsetHeight
sliderTop.value = h3Link.offsetTop - 24
}
}
},
{ debounce: 0, immediate: true }
{ immediate: true }
)
</script>