@owaiswiz/use-in-view

Check if your component is in viewport using this simple hook!

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@owaiswiz/use-in-view
401.0.16a year ago2 years agoMinified + gzip package size for @owaiswiz/use-in-view in KB

Readme

useInView

Check if your component is in viewport using this simple hook!
Build Status code style: prettier GitHub top language npm bundle size (scoped) David
⭐ ⭐ Check out a working demo here ⭐ ⭐

Install

$ yarn add use-in-view

Usage

import useInView from 'use-in-view';

const AnimatedComponent = () => {
	const offset = 30;
	const [ref, inView] = useInView(offset);

	return (
		<div className={`${inView && 'in-view'}`} ref={ref}>
			Animate me!
		</div>
	);
};