Detect if an element is visible in the viewport.

Usage

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

IVisibleOptions Interface

interface IVisibleOptions {
offSetTop? : number | string;
offSetBottom?: number | string;
}

Example

import ( useVisible ) from 'vev';

export function() {
const elementReference = useRef<HTMLDivElement>(null);
const visible = useVisible(elementReference);
return <div ref={elementReference} className='fill' />
}
Did this answer your question?