react-intersection-observer-hook
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,2 +5,5 @@ 'use strict'; | ||
var DEFAULT_ROOT = null; | ||
var DEFAULT_ROOT_MARGIN = '0px'; | ||
var DEFAULT_THRESHOLD = [0]; // For more info: | ||
// https://developers.google.com/web/updates/2016/04/intersectionobserver | ||
@@ -12,7 +15,7 @@ // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API | ||
_ref$root = _ref.root, | ||
root = _ref$root === void 0 ? null : _ref$root, | ||
root = _ref$root === void 0 ? DEFAULT_ROOT : _ref$root, | ||
_ref$rootMargin = _ref.rootMargin, | ||
rootMargin = _ref$rootMargin === void 0 ? '0px' : _ref$rootMargin, | ||
rootMargin = _ref$rootMargin === void 0 ? DEFAULT_ROOT_MARGIN : _ref$rootMargin, | ||
_ref$threshold = _ref.threshold, | ||
threshold = _ref$threshold === void 0 ? [0] : _ref$threshold; | ||
threshold = _ref$threshold === void 0 ? DEFAULT_THRESHOLD : _ref$threshold; | ||
@@ -19,0 +22,0 @@ var observerRef = react.useRef(); |
@@ -1,2 +0,2 @@ | ||
"use strict";var r=require("react");function e(e){var t=void 0===e?{}:e,n=t.root,o=void 0===n?null:n,i=t.rootMargin,s=void 0===i?"0px":i,c=t.threshold,u=void 0===c?[0]:c,a=r.useRef(),v=r.useState(),f=v[0],l=v[1];return r.useEffect((function(){return function(){var r=a.current;r&&r.disconnect()}}),[]),[r.useCallback((function(r){var e=(a.current||(a.current=new IntersectionObserver((function(r){l(r[0])}),{root:o,rootMargin:s,threshold:u})),a.current);e.disconnect(),r&&e.observe(r)}),[o,s,u]),{entry:f}]}exports.useIntersectionObserver=e,exports.useTrackVisibility=function(r){var t=e(r),n=t[1].entry;return[t[0],{isVisible:Boolean(n&&n.isIntersecting)}]}; | ||
"use strict";var r=require("react"),e=null,t="0px",n=[0];function o(o){var i=void 0===o?{}:o,s=i.root,c=void 0===s?e:s,u=i.rootMargin,a=void 0===u?t:u,v=i.threshold,f=void 0===v?n:v,l=r.useRef(),d=r.useState(),b=d[0],h=d[1];return r.useEffect((function(){return function(){var r=l.current;r&&r.disconnect()}}),[]),[r.useCallback((function(r){var e=(l.current||(l.current=new IntersectionObserver((function(r){h(r[0])}),{root:c,rootMargin:a,threshold:f})),l.current);e.disconnect(),r&&e.observe(r)}),[c,a,f]),{entry:b}]}exports.useIntersectionObserver=o,exports.useTrackVisibility=function(r){var e=o(r),t=e[1].entry;return[e[0],{isVisible:Boolean(t&&t.isIntersecting)}]}; | ||
//# sourceMappingURL=react-intersection-observer-hook.cjs.production.min.js.map |
import { useRef, useState, useEffect, useCallback } from 'react'; | ||
var DEFAULT_ROOT = null; | ||
var DEFAULT_ROOT_MARGIN = '0px'; | ||
var DEFAULT_THRESHOLD = [0]; // For more info: | ||
// https://developers.google.com/web/updates/2016/04/intersectionobserver | ||
@@ -9,7 +12,7 @@ // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API | ||
_ref$root = _ref.root, | ||
root = _ref$root === void 0 ? null : _ref$root, | ||
root = _ref$root === void 0 ? DEFAULT_ROOT : _ref$root, | ||
_ref$rootMargin = _ref.rootMargin, | ||
rootMargin = _ref$rootMargin === void 0 ? '0px' : _ref$rootMargin, | ||
rootMargin = _ref$rootMargin === void 0 ? DEFAULT_ROOT_MARGIN : _ref$rootMargin, | ||
_ref$threshold = _ref.threshold, | ||
threshold = _ref$threshold === void 0 ? [0] : _ref$threshold; | ||
threshold = _ref$threshold === void 0 ? DEFAULT_THRESHOLD : _ref$threshold; | ||
@@ -16,0 +19,0 @@ var observerRef = useRef(); |
{ | ||
"name": "react-intersection-observer-hook", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "onderonur", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
22921
15
155
0