0.10.0 • Published 4 years ago

use-intersect v0.10.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

NPM JavaScript Style Guide

Install

npm install --save use-intersect

Usage

import * as React from 'react'

import useIntersect from 'use-intersect'

const option = {
  threshold: 0.8
}

const handleIntersect = (targetElement) ={
  console.log('intersect', targetElement)
}

const Example = () => {

  const targetRef = useIntersect(handleIntersect, {rootOptions: option, once:true})

  return (
    <img ref={targetRef}/>
  )
}

API

useIntersect

PropTypeRequiredDescription
onIntersectFunctionExecute onItersect Function
IntersectOptionsIntersectOptionsIntersect option

IntersectOptions type

nameTypeRequiredDescription
rootOptionsObserverOptionsObserverOptions
oncebooleandefault:true Trigger onItersect once

ObserverOptions type

nameTypeRequiredDescription
rootElement | nullroot Element
rootMarginstringObserver rootMargin
thresholdnumberObserver threshold

[MDN]Reference

License

MIT © :mouse:snyung

0.10.0

4 years ago

0.9.0

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago