docs/.vitepress/theme/composables/animation.ts

bf4e6c02d380dedad485d4e45fef49de3aed8b5c
wotaku/docs/.vitepress/theme/composables/animation.ts history · blame · raw

23 lines · 602 bytes

 1import { useDebounceFn, useMounted } from '@vueuse/core'
 2
 3export function useLayoutAppearanceChangeAnimation() {
 4  const mounted = useMounted()
 5
 6  return {
 7    trigger: (animateElement: HTMLElement) => {
 8      animateElement.classList.add(
 9        'VPNolebaseEnhancedReadabilitiesLayoutSwitchAnimated'
10      )
11
12      const removeAnimatedClassName = useDebounceFn(() => {
13        if (!(mounted.value && animateElement)) return
14
15        animateElement.classList.remove(
16          'VPNolebaseEnhancedReadabilitiesLayoutSwitchAnimated'
17        )
18      }, 5000)
19
20      removeAnimatedClassName()
21    }
22  }
23}