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

369f6a0170667b53ee3a8fe1cf4e8bf34c70c5cb
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}