diff --git a/docs/.vitepress/theme/glare-card/glare-card.vue b/docs/.vitepress/theme/glare-card/glare-card.vue index 99d9c3c5..1da7455f 100644 --- a/docs/.vitepress/theme/glare-card/glare-card.vue +++ b/docs/.vitepress/theme/glare-card/glare-card.vue @@ -30,7 +30,7 @@
import { motion, cubicBezier, AnimatePresence } from 'motion-v' +import { onBeforeUnmount, watch } from 'vue' import Card from './card.vue' -const model = defineModel() +const model = defineModel({ default: false }) -const setCard = (value: boolean) => { - model.value = value - if (model.value) { +watch(model, (value) => { + if (typeof window === 'undefined') return + + if (value) { document.documentElement.classList.add('overflow-hidden') document.body.classList.add('overflow-hidden') } else { document.documentElement.classList.remove('overflow-hidden') document.body.classList.remove('overflow-hidden') } -} +}, { immediate: true }) + +onBeforeUnmount(() => { + if (typeof window === 'undefined') return + + document.documentElement.classList.remove('overflow-hidden') + document.body.classList.remove('overflow-hidden') +})