visibl

1.1.2 • Public • Published

visibl

In-viewport detection via React HOC.

Usage

import React from 'react'
import { render } from 'react-dom'
import visibl from 'visibl'
 
const Component = React.forwardRef((props, ref) => {
  return (
    <h1 ref={ref}>I am {props.visible ? 'visible :)' : 'not visible :('}</h1>
  )
})
 
const TrackedComponent = visibl(Component)
 
function App () {
  return (
    <TrackedComponent />
  )
}
 
render(<App />, document.body)

Adjusting Threshold

A fraction of the viewport height. Positive values makes image load sooner, negative values makes image load later.

<TrackedComponent threshold={0.2} />

License

MIT License © Eric Bailey

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.24latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.24
1.1.10
1.1.00
1.0.10
1.0.00
0.0.11

Package Sidebar

Install

npm i visibl

Weekly Downloads

3

Version

1.1.2

License

MIT

Unpacked Size

22 kB

Total Files

8

Last publish

Collaborators

  • estrattonbailey