use-in-view

1.0.15 • Public • Published

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

Package Sidebar

Install

npm i use-in-view

Weekly Downloads

61

Version

1.0.15

License

MIT

Unpacked Size

4.94 kB

Total Files

4

Last publish

Collaborators

  • elinadenfina