react-hooks
useVisibleElement
usage
export default function Component() {
const { ref, activeKey, activeElement } = useVisibleElement({
activeClass: 'active',
});
console.log('activeKey', activeKey);
console.log('activeElement', activeElement);
return (
<div ref={ref}>
<section>
<p>section 1</p>
</section>
<section>
<p>section 2</p>
</section>
<section>
<p>section 3</p>
</section>
<section>
<p>section 4</p>
</section>
</div>
);
}
useWindowScroll
usage
export default function Component() {
comst {lockScroll, unlockScroll} = useScrollLock();
useEffect(() => {
lockScroll();
return () => {
unlockScroll();
}
}, [])
return (<>...</>)
}