react-on-screen icon indicating copy to clipboard operation
react-on-screen copied to clipboard

Provide API to check if another component is visible

Open futpib opened this issue 5 years ago • 0 comments

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);
};

futpib avatar Apr 03 '19 13:04 futpib