react-on-screen
react-on-screen copied to clipboard
Provide API to check if another component is visible
I'd like to scroll to a component only when it is not visible. I wish this module provided a way to perform a check for component without wrapping it.
import TrackVisibility from 'react-on-screen';
export const scrollTo = (component) => {
if (TrackVisibility.isComponentOnScreen(component)) {
return;
}
scrollToComponent(component);
};