source: imaps-frontend/node_modules/react-use/esm/useIntersection.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 866 bytes
RevLine 
[d565449]1import { useEffect, useState } from 'react';
2var useIntersection = function (ref, options) {
3 var _a = useState(null), intersectionObserverEntry = _a[0], setIntersectionObserverEntry = _a[1];
4 useEffect(function () {
5 if (ref.current && typeof IntersectionObserver === 'function') {
6 var handler = function (entries) {
7 setIntersectionObserverEntry(entries[0]);
8 };
9 var observer_1 = new IntersectionObserver(handler, options);
10 observer_1.observe(ref.current);
11 return function () {
12 setIntersectionObserverEntry(null);
13 observer_1.disconnect();
14 };
15 }
16 return function () { };
17 }, [ref.current, options.threshold, options.root, options.rootMargin]);
18 return intersectionObserverEntry;
19};
20export default useIntersection;
Note: See TracBrowser for help on using the repository browser.