Vev Help Center
Search…
useVisible hook
Detect if an element is visible in the viewport.

Usage

1
const isVisible: boolean = useVisible(ref: React.RefObject, object?: IVisibleOptions);
Copied!

IVisibleOptions Interface

1
interface IVisibleOptions {
2
offSetTop? : number | string;
3
offSetBottom?: number | string;
4
}
Copied!

Example

1
import ( useVisible ) from 'vev';
2
​
3
export function() {
4
const elementReference = useRef<HTMLDivElement>(null);
5
const visible = useVisible(elementReference);
6
return <div ref={elementReference} className='fill' />
7
}
Copied!