2 lines
3.3 KiB
JavaScript
2 lines
3.3 KiB
JavaScript
|
this.primereact=this.primereact||{},this.primereact.deferredcontent=function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=n(t);function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}function l(e){return l="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},l(e)}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e,t){if(t&&("object"===l(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function d(){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(e){return!1}}var p,y,h,b=function(e){c(y,e);var t,n,u,l,a,p=(t=y,n=d(),function(){var e,o=s(t);if(n){var r=s(this).constructor;e=Reflect.construct(o,arguments,r)}else e=o.apply(this,arguments);return f(this,e)});function y(e){var t;return r(this,y),(t=p.call(this,e)).state={loaded:!1},t}return u=y,(l=[{key:"componentDidMount",value:function(){this.state.loaded||(this.shouldLoad()?this.load():this.bindScrollListener())}},{key:"bindScrollListener",value:function(){var e=this;this.documentScrollListener=function(){e.shouldLoad()&&(e.load(),e.unbindScrollListener())},window.addEventListener("scroll",this.documentScrollListener)}},{key:"unbindScrollListener",value:function(){this.documentScrollListener&&(window.removeEventListener("scroll",this.documentScrollListener),this.documentScrollListener=null)}},{key:"shouldLoad",value:function(){if(this.state.loaded)return!1;var e=this.container.getBoundingClientRect();return document.documentElement.clientHeight>=e.top}},{key:"load",value:function(e){this.setState({loaded:!0}),this.props.onLoad&&this.props.onLoad(e)}},{key:"componentWillUnmount",value:function(){this.unbindScrollListener()}},{key:"render",value:function(){var e=this;return o.default.createElement("div",{ref:function(t){return e.container=t}},this.state.loaded?this.props.children:null)}}])&&i(u.prototype,l),a&&i(u,a),Object.defineProperty(u,"prototype",{writable:!1}),y}(t.Component);return h={onload:null},(y="defaultProps")in(p=b)?Object.defineProperty(p,y,{value:h,enumerable:!0,configurable:!0,writable:!0}):p[y]=h,e.DeferredContent=b,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React);
|