UNPKG

zzy-javascript-devtools

Version:

# 该Npm包已更新重构版本! [地址](https://www.npmjs.com/search?q=%40z-utils) 点击后选择其一即可

1 lines 3.59 kB
function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function _createClass(t,e,n){return e&&_defineProperties(t.prototype,e),n&&_defineProperties(t,n),t}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function _createSuper(n){var o=_isNativeReflectConstruct();return function(){var t,e=_getPrototypeOf(n);return _possibleConstructorReturn(this,o?(t=_getPrototypeOf(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments))}}function _possibleConstructorReturn(t,e){return!e||"object"!==_typeof(e)&&"function"!=typeof e?_assertThisInitialized(t):e}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}import{jsx as _jsx}from"react/jsx-runtime";import{Component}from"react";var ScrollLoadingBar=function(){_inherits(n,Component);var e=_createSuper(n);function n(t){return _classCallCheck(this,n),e.call(this,t)}return _createClass(n,[{key:"componentDidMount",value:function(){this.infinityScrolling(document.querySelector(".scrollLoadingBar"),function(t){t.props.getMoreData()})}},{key:"componentWillUnmount",value:function(){this.infinityScrolling.closeMonitor()}},{key:"infinityScrolling",value:function(t,e){var n,o=this;"IntersectionObserver"in window?new IntersectionObserver(function(t){o.props.getDataBol&&t[0].intersectionRatio&&e(o)}).observe(t):(n=function(n){var o,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:100,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:30,c=null,u=this;return function(){var t=+new Date,e=Array.prototype.slice.call(arguments);clearTimeout(o),i<t-(c=c||t)?(n.apply(u,e),c=t):o=setTimeout(function(){n.apply(u,e)},r)}}(function(){o.props.getDataBol&&(!function(t){var e=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=t.getBoundingClientRect(),o=n.top,r=n.left,i=n.bottom,c=n.right,u=window,n=u.innerHeight,u=u.innerWidth;return e?(0<o&&o<n||0<i&&i<n)&&(0<r&&r<u||0<c&&c<u):0<=o&&0<=r&&i<=n&&c<=u}(t,!0)||e(o))},100),document.addEventListener("scroll",n)),this.infinityScrolling.closeMonitor=function(){"IntersectionObserver"in window||(n.cancel(),document.removeEventListener("scroll",n))}}},{key:"render",value:function(){return _jsx("div",{className:"scrollLoadingBar",style:{opacity:0,width:"1px",height:"1px",zIndex:-1}},void 0)}}]),n}();export{ScrollLoadingBar as default};