2.3.0 • Published 8 years ago
viewport-observer v2.3.0
ViewportObserver
React Component that observe changes in the intersection of a target element with viewport using
IntersectionObserver
Install
$ npm install --save viewport-observerThis package depends on IntersectionObserver, so you probably need to polyfill via w3c/IntersectionObserver Polyfill before using this package.
Usage
// you probably need to polyfill
import 'intersection-observer';
import ViewportObserver from 'viewport-observer';
...
<ViewportObserver
onChange={() => console.log('onChange')}
onEnter={() => console.log('onEnter')}
onLeave={() => console.log('onLeave')}>
<div>{/* ... */}</div>
</ViewportObserver>You can call dispose() of ViewportObserver instance to stop observing and dispose IntersectionObserver instance.
Config
| Property | Type | Default Value |
|---|---|---|
| tagName | String | div |
| display | String | '' |
| onChange | Function | () => {} |
| onEnter | Function | () => {} |
| onLeave | Function | () => {} |
| root | Node | null |
| rootMargin | DOMString | 0px |
| threshold | Array<Number> | [0] |
Related
- openfresh/super-image: React component that render a image with object-fit and its fallback
License
MIT © FRESH!
2.3.0
8 years ago
2.2.2
8 years ago
2.2.1
8 years ago
2.2.0
8 years ago
2.1.0
8 years ago
2.0.0
8 years ago
1.1.0
8 years ago
1.0.0
8 years ago
0.7.1
8 years ago
0.7.0
8 years ago
0.6.0
8 years ago
0.5.0
8 years ago
0.4.2
8 years ago
0.4.1
8 years ago
0.4.0
8 years ago
0.3.1
8 years ago
0.3.0
8 years ago
0.2.1
8 years ago
0.2.0
8 years ago
0.1.0
8 years ago
0.0.0
8 years ago