react-intersection-observer
Advanced tools
Comparing version 6.4.1 to 6.4.2
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],r):r((e=e||self).ReactIntersectionObserver={},e.React)}(this,function(e,c){"use strict";function h(){return(h=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var u=process.env.NODE_ENV,l=function(e,r,t,o,n,i,s,a){if("production"!==u&&void 0===r)throw new Error("invariant requires an error message argument");if(!e){var d;if(void 0===r)d=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[t,o,n,i,s,a],h=0;(d=new Error(r.replace(/%s/g,function(){return c[h++]}))).name="Invariant Violation"}throw d.framesToPop=1,d}},f=new Map,p=new Map;function a(e,r,t,o){void 0===t&&(t={}),l(!f.has(e),"react-intersection-observer: Trying to observe %s, but it's already being observed by another instance.\nMake sure the `ref` is only used by a single <Observer /> instance.\n\n%s",e),t.threshold||(t.threshold=0);var n=t,i=n.root,s=n.rootMargin,a=n.threshold;if(e&&r){var d=s?a.toString()+"_"+s:a.toString();i&&(d=o?o+"_"+d:null);var c=d?p.get(d):null;c||(c=new IntersectionObserver(v,t),d&&p.set(d,c));var h={callback:r,visible:!1,options:t,observerId:d,observer:d?void 0:c};return f.set(e,h),c.observe(e),h}}function d(t){if(t){var e=f.get(t);if(e){var o=e.observerId,r=e.observer,n=o?p.get(o):r;n&&n.unobserve(t);var i=!1;o&&f.forEach(function(e,r){e&&e.observerId===o&&r!==t&&(i=!0)}),n&&!i&&(n.disconnect(),p.delete(o)),f.delete(t)}}}function v(e){e.forEach(function(e){var r=e.isIntersecting,t=e.intersectionRatio,o=e.target,n=f.get(o);if(n&&0<=t){var i=n.options,s=!1;Array.isArray(i.threshold)?s=i.threshold.some(function(e){return n.visible?e<t:e<=t}):void 0!==i.threshold&&(s=n.visible?t>i.threshold:t>=i.threshold),void 0!==r&&(s=s&&r),n.visible=s,n.callback(s,t)}})}var r=function(n){var e,r;function t(){for(var t,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return s(i(i(t=n.call.apply(n,[this].concat(r))||this)),"state",{inView:!1,intersectionRatio:0}),s(i(i(t)),"node",null),s(i(i(t)),"handleNode",function(e){t.node&&d(t.node),t.node=e,t.observeNode()}),s(i(i(t)),"handleChange",function(e,r){t.setState({inView:e,intersectionRatio:r}),t.props.onChange&&t.props.onChange(e,r)}),t}r=n,(e=t).prototype=Object.create(r.prototype),(e.prototype.constructor=e).__proto__=r;var o=t.prototype;return o.componentDidMount=function(){"production"!==process.env.NODE_ENV&&(this.props.hasOwnProperty("render")&&console.warn('react-intersection-observer: "render" is deprecated, and should be replaced with "children"',this.node),l(this.node,'react-intersection-observer: No DOM node found. Make sure you forward "ref" to the root DOM element you want to observe.'))},o.componentDidUpdate=function(e,r){e.rootMargin===this.props.rootMargin&&e.root===this.props.root&&e.threshold===this.props.threshold||(d(this.node),this.observeNode()),r.inView!==this.state.inView&&this.state.inView&&this.props.triggerOnce&&(d(this.node),this.node=null)},o.componentWillUnmount=function(){this.node&&(d(this.node),this.node=null)},o.observeNode=function(){if(this.node){var e=this.props,r=e.threshold,t=e.root,o=e.rootMargin,n=e.rootId;a(this.node,this.handleChange,{threshold:r,root:t,rootMargin:o},n)}},o.render=function(){var e=this.props,r=e.children,t=e.render,o=e.tag,n=(e.triggerOnce,e.threshold,e.root,e.rootId,e.rootMargin,function(e,r){if(null==e)return{};var t,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],0<=r.indexOf(t)||(n[t]=e[t]);return n}(e,["children","render","tag","triggerOnce","threshold","root","rootId","rootMargin"])),i=this.state,s=i.inView,a=i.intersectionRatio,d=r||t;return"function"==typeof d?d({inView:s,intersectionRatio:a,ref:this.handleNode}):c.createElement(o||"div",h({ref:this.handleNode},n),r)},t}(c.Component);s(r,"defaultProps",{threshold:0,triggerOnce:!1}),e.InView=r,e.default=r,e.useInView=function(r,t){void 0===t&&(t={});var e=c.useState(!1),o=e[0],n=e[1];return c.useEffect(function(){return r.current&&a(r.current,function(e){n(e),e&&t.triggerOnce&&d(r.current)},{threshold:t.threshold,root:t.root,rootMargin:t.rootMargin},t.rootId),function(){d(r.current)}},[t.threshold,t.root,t.rootMargin,t.rootId]),o},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactIntersectionObserver={},e.React)}(this,function(e,c){"use strict";function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function i(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var l=function(e,t,r,n,o,i,s,a){if(!e){var d;if(void 0===t)d=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,n,o,i,s,a],h=0;(d=new Error(t.replace(/%s/g,function(){return c[h++]}))).name="Invariant Violation"}throw d.framesToPop=1,d}},u=new Map,f=new Map;function a(e,t,r,n){void 0===r&&(r={}),l(!u.has(e),"react-intersection-observer: Trying to observe %s, but it's already being observed by another instance.\nMake sure the `ref` is only used by a single <Observer /> instance.\n\n%s",e),r.threshold||(r.threshold=0);var o=r,i=o.root,s=o.rootMargin,a=o.threshold;if(e&&t){var d=s?a.toString()+"_"+s:a.toString();i&&(d=n?n+"_"+d:null);var c=d?f.get(d):null;c||(c=new IntersectionObserver(p,r),d&&f.set(d,c));var h={callback:t,visible:!1,options:r,observerId:d,observer:d?void 0:c};return u.set(e,h),c.observe(e),h}}function d(r){if(r){var e=u.get(r);if(e){var n=e.observerId,t=e.observer,o=n?f.get(n):t;o&&o.unobserve(r);var i=!1;n&&u.forEach(function(e,t){e&&e.observerId===n&&t!==r&&(i=!0)}),o&&!i&&(o.disconnect(),f.delete(n)),u.delete(r)}}}function p(e){e.forEach(function(e){var t=e.isIntersecting,r=e.intersectionRatio,n=e.target,o=u.get(n);if(o&&0<=r){var i=o.options,s=!1;Array.isArray(i.threshold)?s=i.threshold.some(function(e){return o.visible?e<r:e<=r}):void 0!==i.threshold&&(s=o.visible?r>i.threshold:r>=i.threshold),void 0!==t&&(s=s&&t),o.visible=s,o.callback(s,r)}})}var t=function(o){var e,t;function r(){for(var r,e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return s(i(i(r=o.call.apply(o,[this].concat(t))||this)),"state",{inView:!1,intersectionRatio:0}),s(i(i(r)),"node",null),s(i(i(r)),"handleNode",function(e){r.node&&d(r.node),r.node=e,r.observeNode()}),s(i(i(r)),"handleChange",function(e,t){r.setState({inView:e,intersectionRatio:t}),r.props.onChange&&r.props.onChange(e,t)}),r}t=o,(e=r).prototype=Object.create(t.prototype),(e.prototype.constructor=e).__proto__=t;var n=r.prototype;return n.componentDidMount=function(){},n.componentDidUpdate=function(e,t){e.rootMargin===this.props.rootMargin&&e.root===this.props.root&&e.threshold===this.props.threshold||(d(this.node),this.observeNode()),t.inView!==this.state.inView&&this.state.inView&&this.props.triggerOnce&&(d(this.node),this.node=null)},n.componentWillUnmount=function(){this.node&&(d(this.node),this.node=null)},n.observeNode=function(){if(this.node){var e=this.props,t=e.threshold,r=e.root,n=e.rootMargin,o=e.rootId;a(this.node,this.handleChange,{threshold:t,root:r,rootMargin:n},o)}},n.render=function(){var e=this.props,t=e.children,r=e.render,n=e.tag,o=(e.triggerOnce,e.threshold,e.root,e.rootId,e.rootMargin,function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],0<=t.indexOf(r)||(o[r]=e[r]);return o}(e,["children","render","tag","triggerOnce","threshold","root","rootId","rootMargin"])),i=this.state,s=i.inView,a=i.intersectionRatio,d=t||r;return"function"==typeof d?d({inView:s,intersectionRatio:a,ref:this.handleNode}):c.createElement(n||"div",h({ref:this.handleNode},o),t)},r}(c.Component);s(t,"defaultProps",{threshold:0,triggerOnce:!1}),e.InView=t,e.default=t,e.useInView=function(t,r){void 0===r&&(r={});var e=c.useState(!1),n=e[0],o=e[1];return c.useEffect(function(){return t.current&&a(t.current,function(e){o(e),e&&r.triggerOnce&&d(t.current)},{threshold:r.threshold,root:r.root,rootMargin:r.rootMargin},r.rootId),function(){d(t.current)}},[r.threshold,r.root,r.rootMargin,r.rootId]),n},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "react-intersection-observer", | ||
"version": "6.4.1", | ||
"version": "6.4.2", | ||
"description": "Monitor if a component is inside the viewport, using IntersectionObserver API", | ||
@@ -120,3 +120,3 @@ "main": "dist/react-intersection-observer.cjs.js", | ||
"eslint-config-insilico": "^6.0.0", | ||
"flow-bin": "^0.89.0", | ||
"flow-bin": "^0.90.0", | ||
"flow-copy-source": "^2.0.2", | ||
@@ -123,0 +123,0 @@ "husky": "^1.3.1", |
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
6
67229
1323