UNPKG

@ggns/use-fade-in

Version:
13 lines (12 loc) 420 B
const useFadeIn = (duration = 1, delay = 0) => { if (typeof duration !== "number" || typeof delay !== "number") return; const element = useRef(); useEffect(() => { if (element.current) { const { current } = element; current.style.transition = `opacity ${duration}s ease-in-out ${delay}`; current.style.opacity = 1; } }); return { ref: element, style: { opacity: 0 } }; };