react-visibility-sensor
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -158,4 +158,2 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
_this.displayName = 'VisibilitySensor'; | ||
_this.getContainer = function () { | ||
@@ -162,0 +160,0 @@ return _this.props.containment || window; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],t):"object"==typeof exports?exports["react-visibility-sensor"]=t(require("react"),require("react-dom")):e["react-visibility-sensor"]=t(e.React,e.ReactDOM)}(window,function(e,t){return function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=function(){function e(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,o,n){return o&&e(t.prototype,o),n&&e(t,n),t}}(),i=c(o(1)),l=c(o(2)),a=c(o(3)),u=c(o(6));function c(e){return e&&e.__esModule?e:{default:e}}var f=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.displayName="VisibilitySensor",o.getContainer=function(){return o.props.containment||window},o.addEventListener=function(e,t,n,r){o.debounceCheck||(o.debounceCheck={});var i=void 0,l=function(){i=null,o.check()},a={target:e,fn:r>-1?function(){i||(i=setTimeout(l,r||0))}:function(){clearTimeout(i),i=setTimeout(l,n||0)},getLastTimeout:function(){return i}};e.addEventListener(t,a.fn),o.debounceCheck[t]=a},o.startWatching=function(){o.debounceCheck||o.interval||(o.props.intervalCheck&&(o.interval=setInterval(o.check,o.props.intervalDelay)),o.props.scrollCheck&&o.addEventListener(o.getContainer(),"scroll",o.props.scrollDelay,o.props.scrollThrottle),o.props.resizeCheck&&o.addEventListener(window,"resize",o.props.resizeDelay,o.props.resizeThrottle),!o.props.delayedCall&&o.check())},o.stopWatching=function(){if(o.debounceCheck)for(var e in o.debounceCheck)if(o.debounceCheck.hasOwnProperty(e)){var t=o.debounceCheck[e];clearTimeout(t.getLastTimeout()),t.target.removeEventListener(e,t.fn),o.debounceCheck[e]=null}o.debounceCheck=null,o.interval&&(o.interval=clearInterval(o.interval))},o.check=function(){var e,t=o.node,r=void 0;if(!t)return o.state;if(e=function(e){return void 0===e.width&&(e.width=e.right-e.left),void 0===e.height&&(e.height=e.bottom-e.top),e}(o.roundRectDown(t.getBoundingClientRect())),o.props.containment){var i=o.props.containment.getBoundingClientRect();r={top:i.top,left:i.left,bottom:i.bottom,right:i.right}}else r={top:0,left:0,bottom:window.innerHeight||document.documentElement.clientHeight,right:window.innerWidth||document.documentElement.clientWidth};var l=o.props.offset||{};"object"===(void 0===l?"undefined":n(l))&&(r.top+=l.top||0,r.left+=l.left||0,r.bottom-=l.bottom||0,r.right-=l.right||0);var a={top:e.top>=r.top,left:e.left>=r.left,bottom:e.bottom<=r.bottom,right:e.right<=r.right},c=e.height>0&&e.width>0,f=c&&a.top&&a.left&&a.bottom&&a.right;if(c&&o.props.partialVisibility){var s=e.top<=r.bottom&&e.bottom>=r.top&&e.left<=r.right&&e.right>=r.left;"string"==typeof o.props.partialVisibility&&(s=a[o.props.partialVisibility]),f=o.props.minTopValue?s&&e.top<=r.bottom-o.props.minTopValue:s}"string"==typeof l.direction&&"number"==typeof l.value&&(console.warn("[notice] offset.direction and offset.value have been deprecated. They still work for now, but will be removed in next major version. Please upgrade to the new syntax: { %s: %d }",l.direction,l.value),f=(0,u.default)(l,e,r));var p=o.state;return o.state.isVisible!==f&&(p={isVisible:f,visibilityRect:a},o.setState(p),o.props.onChange&&o.props.onChange(f)),p},o.state={isVisible:null,visibilityRect:{}},o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.default.Component),r(t,[{key:"componentDidMount",value:function(){this.node=l.default.findDOMNode(this),this.props.active&&this.startWatching()}},{key:"componentWillUnmount",value:function(){this.stopWatching()}},{key:"componentDidUpdate",value:function(e){this.node=l.default.findDOMNode(this),this.props.active&&!e.active?(this.setState({isVisible:null,visibilityRect:{}}),this.startWatching()):this.props.active||this.stopWatching()}},{key:"roundRectDown",value:function(e){return{top:Math.floor(e.top),left:Math.floor(e.left),bottom:Math.floor(e.bottom),right:Math.floor(e.right)}}},{key:"render",value:function(){return this.props.children instanceof Function?this.props.children({isVisible:this.state.isVisible,visibilityRect:this.state.visibilityRect}):i.default.Children.only(this.props.children)}}]),t}();f.defaultProps={active:!0,partialVisibility:!1,minTopValue:0,scrollCheck:!1,scrollDelay:250,scrollThrottle:-1,resizeCheck:!1,resizeDelay:250,resizeThrottle:-1,intervalCheck:!0,intervalDelay:100,delayedCall:!1,offset:{},containment:null,children:i.default.createElement("span",null)},f.propTypes={onChange:a.default.func,active:a.default.bool,partialVisibility:a.default.oneOfType([a.default.bool,a.default.oneOf(["top","right","bottom","left"])]),delayedCall:a.default.bool,offset:a.default.oneOfType([a.default.shape({top:a.default.number,left:a.default.number,bottom:a.default.number,right:a.default.number}),a.default.shape({direction:a.default.oneOf(["top","right","bottom","left"]),value:a.default.number})]),scrollCheck:a.default.bool,scrollDelay:a.default.number,scrollThrottle:a.default.number,resizeCheck:a.default.bool,resizeDelay:a.default.number,resizeThrottle:a.default.number,intervalCheck:a.default.bool,intervalDelay:a.default.number,containment:"undefined"!=typeof window?a.default.instanceOf(window.Element):a.default.any,children:a.default.oneOfType([a.default.element,a.default.func]),minTopValue:a.default.number},t.default=f},function(t,o){t.exports=e},function(e,o){e.exports=t},function(e,t,o){e.exports=o(4)()},function(e,t,o){"use strict";var n=o(5);function r(){}e.exports=function(){function e(e,t,o,r,i,l){if(l!==n){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var o={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return o.checkPropTypes=r,o.PropTypes=o,o}},function(e,t,o){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,o){"use strict";e.exports=function(e,t,o){var n=e.direction,r=e.value;switch(n){case"top":return o.top+r<t.top&&o.bottom>t.bottom&&o.left<t.left&&o.right>t.right;case"left":return o.left+r<t.left&&o.bottom>t.bottom&&o.top<t.top&&o.right>t.right;case"bottom":return o.bottom-r>t.bottom&&o.left<t.left&&o.right>t.right&&o.top<t.top;case"right":return o.right-r>t.right&&o.left<t.left&&o.top<t.top&&o.bottom>t.bottom}}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["React","ReactDOM"],t):"object"==typeof exports?exports["react-visibility-sensor"]=t(require("react"),require("react-dom")):e["react-visibility-sensor"]=t(e.React,e.ReactDOM)}(window,function(o,n){return function(o){var n={};function r(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return o[e].call(t.exports,t,t.exports,r),t.l=!0,t.exports}return r.m=o,r.c=n,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=function(){function n(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}}(),r=a(o(1)),i=a(o(2)),l=a(o(3)),d=a(o(6));function a(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var s=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return s.getContainer=function(){return s.props.containment||window},s.addEventListener=function(e,t,o,n){s.debounceCheck||(s.debounceCheck={});var r=void 0,i=function(){r=null,s.check()},l={target:e,fn:-1<n?function(){r||(r=setTimeout(i,n||0))}:function(){clearTimeout(r),r=setTimeout(i,o||0)},getLastTimeout:function(){return r}};e.addEventListener(t,l.fn),s.debounceCheck[t]=l},s.startWatching=function(){s.debounceCheck||s.interval||(s.props.intervalCheck&&(s.interval=setInterval(s.check,s.props.intervalDelay)),s.props.scrollCheck&&s.addEventListener(s.getContainer(),"scroll",s.props.scrollDelay,s.props.scrollThrottle),s.props.resizeCheck&&s.addEventListener(window,"resize",s.props.resizeDelay,s.props.resizeThrottle),!s.props.delayedCall&&s.check())},s.stopWatching=function(){if(s.debounceCheck)for(var e in s.debounceCheck)if(s.debounceCheck.hasOwnProperty(e)){var t=s.debounceCheck[e];clearTimeout(t.getLastTimeout()),t.target.removeEventListener(e,t.fn),s.debounceCheck[e]=null}s.debounceCheck=null,s.interval&&(s.interval=clearInterval(s.interval))},s.check=function(){var e,t=s.node,o=void 0,n=void 0;if(!t)return s.state;if(void 0===(e=s.roundRectDown(t.getBoundingClientRect())).width&&(e.width=e.right-e.left),void 0===e.height&&(e.height=e.bottom-e.top),o=e,s.props.containment){var r=s.props.containment.getBoundingClientRect();n={top:r.top,left:r.left,bottom:r.bottom,right:r.right}}else n={top:0,left:0,bottom:window.innerHeight||document.documentElement.clientHeight,right:window.innerWidth||document.documentElement.clientWidth};var i=s.props.offset||{};"object"===(void 0===i?"undefined":p(i))&&(n.top+=i.top||0,n.left+=i.left||0,n.bottom-=i.bottom||0,n.right-=i.right||0);var l={top:o.top>=n.top,left:o.left>=n.left,bottom:o.bottom<=n.bottom,right:o.right<=n.right},a=0<o.height&&0<o.width,u=a&&l.top&&l.left&&l.bottom&&l.right;if(a&&s.props.partialVisibility){var c=o.top<=n.bottom&&o.bottom>=n.top&&o.left<=n.right&&o.right>=n.left;"string"==typeof s.props.partialVisibility&&(c=l[s.props.partialVisibility]),u=s.props.minTopValue?c&&o.top<=n.bottom-s.props.minTopValue:c}"string"==typeof i.direction&&"number"==typeof i.value&&(console.warn("[notice] offset.direction and offset.value have been deprecated. They still work for now, but will be removed in next major version. Please upgrade to the new syntax: { %s: %d }",i.direction,i.value),u=(0,d.default)(i,o,n));var f=s.state;return s.state.isVisible!==u&&(f={isVisible:u,visibilityRect:l},s.setState(f),s.props.onChange&&s.props.onChange(u)),f},s.state={isVisible:null,visibilityRect:{}},s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,r.default.Component),n(t,[{key:"componentDidMount",value:function(){this.node=i.default.findDOMNode(this),this.props.active&&this.startWatching()}},{key:"componentWillUnmount",value:function(){this.stopWatching()}},{key:"componentDidUpdate",value:function(e){this.node=i.default.findDOMNode(this),this.props.active&&!e.active?(this.setState({isVisible:null,visibilityRect:{}}),this.startWatching()):this.props.active||this.stopWatching()}},{key:"roundRectDown",value:function(e){return{top:Math.floor(e.top),left:Math.floor(e.left),bottom:Math.floor(e.bottom),right:Math.floor(e.right)}}},{key:"render",value:function(){return this.props.children instanceof Function?this.props.children({isVisible:this.state.isVisible,visibilityRect:this.state.visibilityRect}):r.default.Children.only(this.props.children)}}]),t}();u.defaultProps={active:!0,partialVisibility:!1,minTopValue:0,scrollCheck:!1,scrollDelay:250,scrollThrottle:-1,resizeCheck:!1,resizeDelay:250,resizeThrottle:-1,intervalCheck:!0,intervalDelay:100,delayedCall:!1,offset:{},containment:null,children:r.default.createElement("span",null)},u.propTypes={onChange:l.default.func,active:l.default.bool,partialVisibility:l.default.oneOfType([l.default.bool,l.default.oneOf(["top","right","bottom","left"])]),delayedCall:l.default.bool,offset:l.default.oneOfType([l.default.shape({top:l.default.number,left:l.default.number,bottom:l.default.number,right:l.default.number}),l.default.shape({direction:l.default.oneOf(["top","right","bottom","left"]),value:l.default.number})]),scrollCheck:l.default.bool,scrollDelay:l.default.number,scrollThrottle:l.default.number,resizeCheck:l.default.bool,resizeDelay:l.default.number,resizeThrottle:l.default.number,intervalCheck:l.default.bool,intervalDelay:l.default.number,containment:"undefined"!=typeof window?l.default.instanceOf(window.Element):l.default.any,children:l.default.oneOfType([l.default.element,l.default.func]),minTopValue:l.default.number},t.default=u},function(e,t){e.exports=o},function(e,t){e.exports=n},function(e,t,o){e.exports=o(4)()},function(e,t,o){"use strict";var a=o(5);function n(){}e.exports=function(){function e(e,t,o,n,r,i){if(i!==a){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}var o={array:e.isRequired=e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return o.checkPropTypes=n,o.PropTypes=o}},function(e,t,o){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,o){"use strict";e.exports=function(e,t,o){var n=e.direction,r=e.value;switch(n){case"top":return o.top+r<t.top&&o.bottom>t.bottom&&o.left<t.left&&o.right>t.right;case"left":return o.left+r<t.left&&o.bottom>t.bottom&&o.top<t.top&&o.right>t.right;case"bottom":return o.bottom-r>t.bottom&&o.left<t.left&&o.right>t.right&&o.top<t.top;case"right":return o.right-r>t.right&&o.left<t.left&&o.top<t.top&&o.bottom>t.bottom}}}])}); |
{ | ||
"name": "react-visibility-sensor", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "Sensor component for React that notifies you when it goes in or out of the window viewport.", | ||
"main": "visibility-sensor.js", | ||
"main": "dist/visibility-sensor.js", | ||
"scripts": { | ||
@@ -33,4 +33,4 @@ "clean": "rm -rf dist && mkdir dist", | ||
"babel-preset-react": "^6.24.1", | ||
"gh-pages": "^1.2.0", | ||
"karma": "^2.0.5", | ||
"gh-pages": "^2.0.1", | ||
"karma": "^3.0.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
@@ -43,3 +43,3 @@ "karma-mocha": "^1.3.0", | ||
"uglify-js": "^3.4.6", | ||
"uglifyjs-webpack-plugin": "^1.2.7", | ||
"uglifyjs-webpack-plugin": "^2.0.1", | ||
"webpack": "^4.16.4", | ||
@@ -53,5 +53,4 @@ "webpack-cli": "^3.1.0" | ||
"dependencies": { | ||
"create-react-class": "^15.6.3", | ||
"prop-types": "^15.6.2" | ||
} | ||
} |
@@ -23,4 +23,2 @@ 'use strict'; | ||
export default class VisibilitySensor extends React.Component { | ||
displayName = 'VisibilitySensor'; | ||
static defaultProps = { | ||
@@ -27,0 +25,0 @@ active: true, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3
0
379389
5033
- Removedcreate-react-class@^15.6.3
- Removedcreate-react-class@15.7.0(transitive)