1
0
mirror of synced 2025-11-06 04:20:50 +08:00
Files
cook/app/composables/helper.ts
2025-10-06 18:43:58 +08:00

27 lines
578 B
TypeScript

import type { MaybeComputedElementRef } from '@vueuse/core'
import { isClient, useElementBounding } from '@vueuse/core'
/**
* trigger show invisible element
* @param target
*
* @deprecated use scrollIntoView instead
*/
export function useInvisibleElement(target: MaybeComputedElementRef<HTMLElement>) {
const { top } = useElementBounding(target)
const isVisible = computed(() => {
return isClient ? window.scrollY < top.value : true
})
const show = () => {
if (isClient)
window.scrollTo(0, top.value)
}
return {
isVisible,
show,
}
}