r-intersection-observer
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

r-intersection-observer

Custom React intersection observer component

NPM JavaScript Style Guide

Install

npm install --save r-intersection-observer

Usage

import * as React from 'react'

import Observer from 'r-intersection-observer'

function Example () {
    return (
      <Observer>
        {
          inView => (
             <div>
               Observing Element
             </div>
          )
        }
      </Observer>
    )
 }

 inView returns boolean if element is intersecting or not

Properties

Name Required Type Description Default Value
rootMargin false string define rootMargin option 0px
threshold false number define threshold option 0
root false JSX define root option --
callBack false function callback after intersecting --
onlyCallBack false boolean returns only callBack function false
onlyOnce false boolean intersecting entry only once true
className false string define className for Observer --
style false React.CSSProperties define style object --
function arguments
callBack (isIntersecting: boolean, entry: IntersectionObserverEntry, ref: React.MutableRefObject)

License

MIT © arsengit

Package Sidebar

Install

npm i r-intersection-observer

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

133 kB

Total Files

8

Last publish

Collaborators

  • arsengit