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

25151c7627700b94b1cc0e482055bbca7e1e1ba1
wotaku/docs/.vitepress/theme/composables/animation.ts

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}