lazy-react 2.0.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +4 -2
- package/.eslintrc +36 -36
- package/README.md +1 -1
- package/demo/demo.js +39 -56
- package/demo/index.js +219 -5
- package/demo/index.js.LICENSE.txt +32 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +24 -19
- package/src/baseClass.js +65 -61
- package/src/lazyLoadBackgroundImage.js +16 -31
- package/src/lazyLoadComponent.js +20 -28
- package/src/lazyLoadFrame.js +17 -33
- package/src/lazyLoadImage.js +14 -31
- package/webpack.config.demo.js +16 -23
- package/webpack.config.js +70 -39
- package/.npmignore +0 -73
- package/src/indexSingleFile.js +0 -75
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
object-assign
|
|
3
|
+
(c) Sindre Sorhus
|
|
4
|
+
@license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** @license React v0.20.2
|
|
8
|
+
* scheduler.production.min.js
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** @license React v17.0.2
|
|
17
|
+
* react-dom.production.min.js
|
|
18
|
+
*
|
|
19
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
20
|
+
*
|
|
21
|
+
* This source code is licensed under the MIT license found in the
|
|
22
|
+
* LICENSE file in the root directory of this source tree.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** @license React v17.0.2
|
|
26
|
+
* react.production.min.js
|
|
27
|
+
*
|
|
28
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the MIT license found in the
|
|
31
|
+
* LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.LazyReact=t(require("react")):e.LazyReact=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=7)}([function(t,n){t.exports=e},function(e,t,n){"use strict";(function(e){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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}function i(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)}var u=n(0),a=(n.n(u),function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}()),c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(e){var t=e.offset,n=e.top,r=e.left;return window.scrollY+window.innerHeight+t>n&&window.scrollX+window.innerWidth+t>r},l=function(e){var t=e.element.domNode,n=t.getBoundingClientRect(),r=n.top,o=n.left,i=n.right;return c({},e,{top:r,left:o,right:i})},f=function(e){function t(e){r(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={link:"",visible:!1},n.makeItVisible=n.makeItVisible.bind(n),n}return i(t,e),a(t,[{key:"makeItVisible",value:function(){this.setState({link:this.props.link,visible:!0})}},{key:"componentDidMount",value:function(){t.addElement(this)}},{key:"componentWillUnmount",value:function(){t.removeElementFromList(this)}}]),t}(u.Component);f.elements=[],f.eventHandler=function(){0===f.elements.length?f.removeScrollHandler():!function(){for(var e=[],t=0;t<f.elements.length;t++)s(f.elements[t])&&(e.push(t),f.elements[t].element.makeItVisible());e.length>0&&(f.elements=f.elements.filter(function(t,n){return!e.includes(n)})),f.elements=f.elements.map(function(e){return l(e)}),f.isListenerAttached=window.requestAnimationFrame(f.eventHandler)}()},f.addElement=function(e){var t=e.domNode.getBoundingClientRect(),n=t.top,r=t.left,o=t.right;f.elements.push({element:e,top:n,left:r,right:o,offset:e.props.offset||100}),"function"!=typeof f.isListenerAttached&&(f.isListenerAttached=window.requestAnimationFrame(f.eventHandler))},f.removeScrollHandler=function(){window.cancelAnimationFrame(f.isListenerAttached)},f.removeElementFromList=function(e){f.elements=f.elements.filter(function(t){return t.element!==e})},f.isListenerAttached=!1,"production"===!e.NODE_ENV&&(f.propTypes={link:u.PropTypes.string.isRequired}),t.a=f}).call(t,n(6))},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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}function i(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)}var u=n(0),a=n.n(u),c=n(1),s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return i(t,e),l(t,[{key:"render",value:function(){var e=this;return a.a.createElement("div",{className:this.props.className,style:this.style,ref:function(t){return e.domNode=t}})}},{key:"componentWillMount",value:function(){this.style=s({backgroundImage:"url("+this.state.link+")"},this.props.style)}},{key:"componentWillUpdate",value:function(e,t){this.style=s({},this.style,{backgroundImage:"url("+t.link+")"})}}]),t}(c.a);t.a=f,f.defaultProps={className:"",style:{}}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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}function i(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)}var u=n(0),a=n.n(u),c=n(1),s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return i(t,e),s(t,[{key:"render",value:function(){var e=this,t=this.state.visible?this.props.children:a.a.createElement("div",null);return a.a.createElement("div",{style:this.style,className:this.props.className,ref:function(t){return e.domNode=t}},t)}},{key:"componentWillMount",value:function(){this.style=Object.assign({},this.props.style),this.state.link||this.props.className||this.style.height||(this.style.height="300px")}}]),t}(c.a);t.a=l,l.defaultProps={style:{},className:""}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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}function i(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)}var u=n(0),a=n.n(u),c=n(1),s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return i(t,e),l(t,[{key:"render",value:function(){var e=this;return a.a.createElement("iframe",{height:this.props.height,scrolling:this.props.scrolling,src:this.state.link,frameBorder:this.props.frameBorder,allowTransparency:this.props.allowTransparency,allowFullScreen:this.props.allowFullScreen,style:this.style,ref:function(t){return e.domNode=t}})}},{key:"componentWillMount",value:function(){this.style=s({minWidth:"100%"},this.props.style)}}]),t}(c.a);t.a=f,f.defaultProps={height:"500",scrolling:"no",frameBorder:"no",allowTransparency:"true",allowFullScreen:"true"}},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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}function i(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)}var u=n(0),a=n.n(u),c=n(1),s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),f=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return i(t,e),l(t,[{key:"render",value:function(){var e=this;return a.a.createElement("img",{src:this.state.link,alt:this.props.alt,style:this.style,className:this.props.className,ref:function(t){return e.domNode=t}})}},{key:"componentWillMount",value:function(){""===this.props.className&&this.props.preserveAspect===!1&&(this.style=s({minHeight:"300px",minWidth:"300px"},this.props.style))}}]),t}(c.a);t.a=f,f.defaultProps={style:{},className:"",preserveAspect:!0}},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function i(e){if(f===clearTimeout)return clearTimeout(e);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function u(){m&&h&&(m=!1,h.length?y=h.concat(y):b=-1,y.length&&a())}function a(){if(!m){var e=o(u);m=!0;for(var t=y.length;t;){for(h=y,y=[];++b<t;)h&&h[b].run();b=-1,t=y.length}h=null,m=!1,i(e)}}function c(e,t){this.fun=e,this.array=t}function s(){}var l,f,p=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(e){l=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var h,y=[],m=!1,b=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];y.push(new c(e,t)),1!==y.length||m||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=s,p.addListener=s,p.once=s,p.off=s,p.removeListener=s,p.removeAllListeners=s,p.emit=s,p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),o=n(5),i=n(4),u=n(3);n.d(t,"LazyBackgroundImage",function(){return r.a}),n.d(t,"LazyImage",function(){return o.a}),n.d(t,"LazyFrame",function(){return i.a}),n.d(t,"LazyComponent",function(){return u.a})}])});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.LazyReact=t(require("react")):e.LazyReact=t(e.React)}(self,(function(e){return(()=>{"use strict";var t={787:t=>{t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var l=r[e]={exports:{}};return t[e](l,l.exports,n),l.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{LazyBackgroundImage:()=>u,LazyComponent:()=>f,LazyFrame:()=>s,LazyImage:()=>c});var e=n(787),t=n.n(e);function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function l(t,n){var o,l,a=(o=(0,e.useState)({link:"",visible:!1}),l=2,function(e){if(Array.isArray(e))return e}(o)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,l=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(l.push(n.value),!t||l.length!==t);i=!0);}catch(e){a=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw o}}return l}}(o,l)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(o,l)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=a[0],c=a[1];function s(){c({visible:!0,link:n.link})}return(0,e.useEffect)((function(){return void 0!==t.current&&i.addElement({element:t.current,props:n,makeItVisible:s}),function(){return i.removeElementFromList({element:t.current,props:n,makeItVisible:s})}}),[]),u}var i={elements:[]};function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(r){var n,o,i=(0,e.useRef)(),u=l(i,r),c=(n=(0,e.useState)(Object.assign({backgroundImage:"url(".concat(u.link,")")},r.style)),o=2,function(e){if(Array.isArray(e))return e}(n)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,l=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(l.push(n.value),!t||l.length!==t);i=!0);}catch(e){a=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw o}}return l}}(n,o)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(n,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=c[0],f=c[1];return(0,e.useEffect)((function(){f(Object.assign({backgroundImage:"url(".concat(u.link,")")},r.style))}),[u]),t().createElement("div",{className:r.className,style:s,ref:i})}function c(r){var n=(0,e.useRef)(),o=l(n,r);return t().createElement("img",{src:o.link,alt:r.alt,style:r.style,className:r.className,ref:n})}function s(r){var n=(0,e.useRef)(),o=l(n,r);return t().createElement("iframe",{height:r.height||"500",scrolling:r.scrolling||"no",src:o.link,frameBorder:r.frameBorder||"no",allowtransparency:r.allowTransparency||"true",allowFullScreen:r.allowFullScreen||!0,style:r.style||{},ref:n})}function f(r){var n=(0,e.useRef)(),o=l(n,r),i=t().createElement("div",{style:r.style?r.style:{heigt:"300px",width:"300px"}});return t().createElement("div",{ref:n},o.visible?r.children:i)}i.isInViewPort=function(e){var t=e.offset,r=e.top,n=e.left;return window.scrollY+window.innerHeight+t>r&&window.scrollX+window.innerWidth+t>n},i.calculateNewPosition=function(e){var t=e.element.getBoundingClientRect(),r=t.top,n=t.left,o=t.right;return Object.assign({},e,{top:r,left:n,right:o})},i.addElement=function(e){var t=e.element,r=e.props,n=e.makeItVisible,o=t.getBoundingClientRect(),l=o.top,a=o.left,u=o.right;i.elements.push({element:t,top:l,left:a,right:u,offset:r.offset||100,makeItVisible:n}),"function"!=typeof i.isListenerAttached&&(i.isListenerAttached=window.requestAnimationFrame(i.eventHandler))},i.eventHandler=function(){if(0===i.elements.length)i.removeScrollHandler();else{for(var e=[],t=0;t<i.elements.length;t++)i.isInViewPort(i.elements[t])&&(e.push(t),i.elements[t].makeItVisible());e.length>0&&(i.elements=i.elements.filter((function(t,r){return!e.includes(r)}))),i.elements=i.elements.map((function(e){return i.calculateNewPosition(e)})),i.isListenerAttached=window.requestAnimationFrame(i.eventHandler)}},i.removeScrollHandler=function(){window.cancelAnimationFrame(i.isListenerAttached)},i.removeElementFromList=function(e){i.elements=i.elements.filter((function(t){return t!==e}))},i.isListenerAttached=!1})(),o})()}));
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///dist/index.js","webpack:///webpack/bootstrap 72955e84d166bbff5def","webpack:///./src/index.js","webpack:///external {\"root\":\"React\",\"commonjs2\":\"react\",\"commonjs\":\"react\",\"amd\":\"react\"}","webpack:///./src/baseClass.js","webpack:///./src/lazyLoadBackgroundImage.js","webpack:///./src/lazyLoadFrame.js","webpack:///./src/lazyLoadImage.js","webpack:///external {\"root\":\"ReactDOM\",\"commonjs2\":\"react-dom\",\"commonjs\":\"react-dom\",\"amd\":\"react-dom\"}"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","__WEBPACK_EXTERNAL_MODULE_6__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_interopRequireDefault","obj","__esModule","default","_lazyLoadBackgroundImage","_lazyLoadBackgroundImage2","_lazyLoadImage","_lazyLoadImage2","_lazyLoadFrame","_lazyLoadFrame2","LazyBackgroundImage","LazyImage","LazyFrame","_classCallCheck","instance","Constructor","TypeError","_possibleConstructorReturn","self","ReferenceError","_inherits","subClass","superClass","prototype","Object","create","constructor","value","enumerable","writable","configurable","setPrototypeOf","__proto__","defineProperty","_createClass","defineProperties","target","props","i","length","descriptor","key","protoProps","staticProps","_react","_reactDom","CheckIfRender","_Component","_this","getPrototypeOf","state","link","listener","bind","removeListener","isInViewPort","_this2","requestAnimationFrame","setState","offset","verticalViewPort","window","scrollY","innerHeight","top","orizzontalViewPort","scrollX","innerWidth","left","removeEventListener","element","findDOMNode","_element$getBoundingC","getBoundingClientRect","Component","propTypes","PropTypes","string","isRequired","_react2","_baseClass","_baseClass2","_CheckIfRender","style","assign","backgroundImage","createElement","className","defaultProps","width","height","scrolling","src","frameBorder","allowTransparency","allowFullScreen","alt"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,SAAAA,QAAA,cACA,kBAAAC,gBAAAC,IACAD,QAAA,qBAAAJ,GACA,gBAAAC,SACAA,QAAA,UAAAD,EAAAG,QAAA,SAAAA,QAAA,cAEAJ,EAAA,UAAAC,EAAAD,EAAA,MAAAA,EAAA,WACCO,KAAA,SAAAC,EAAAC,GACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAV,OAGA,IAAAC,GAAAU,EAAAD,IACAV,WACAY,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAb,EAAAD,QAAAC,IAAAD,QAAAS,GAGAR,EAAAY,QAAA,EAGAZ,EAAAD,QAvBA,GAAAW,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAASR,EAAQD,EAASS,GAE/B,YAcA,SAASS,GAAuBC,GAAO,MAAOA,IAAOA,EAAIC,WAAaD,GAAQE,QAASF,GEtExF,GAAAG,GAAAb,EAAA,GF4DKc,EAA4BL,EAAuBI,GE3DxDE,EAAAf,EAAA,GF+DKgB,EAAkB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E,QAAAmF,cAAA,OAAKM,IAAKzG,KAAK+D,MAAMC,KAAM6C,IAAK7G,KAAKkD,MAAM2D,IAAKb,MAAOhG,KAAKkD,MAAM8C,YP+VlExE,GACNsE,EAAY9E,QAEdrB,GAAQqB,QOvWYQ,GP2Wf,SAAS5B,EAAQD,GQ9WvBC,EAAAD,QAAAO","file":"./dist/index.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"react-dom\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"react-dom\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"LazyReact\"] = factory(require(\"react\"), require(\"react-dom\"));\n\telse\n\t\troot[\"LazyReact\"] = factory(root[\"React\"], root[\"ReactDOM\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_6__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"react-dom\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"react-dom\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"LazyReact\"] = factory(require(\"react\"), require(\"react-dom\"));\n\telse\n\t\troot[\"LazyReact\"] = factory(root[\"React\"], root[\"ReactDOM\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_6__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar _lazyLoadBackgroundImage = __webpack_require__(3);\n\t\n\tvar _lazyLoadBackgroundImage2 = _interopRequireDefault(_lazyLoadBackgroundImage);\n\t\n\tvar _lazyLoadImage = __webpack_require__(5);\n\t\n\tvar _lazyLoadImage2 = _interopRequireDefault(_lazyLoadImage);\n\t\n\tvar _lazyLoadFrame = __webpack_require__(4);\n\t\n\tvar _lazyLoadFrame2 = _interopRequireDefault(_lazyLoadFrame);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tmodule.exports = {\n\t\tLazyBackgroundImage: _lazyLoadBackgroundImage2.default,\n\t\tLazyImage: _lazyLoadImage2.default,\n\t\tLazyFrame: _lazyLoadFrame2.default\n\t};\n\n/***/ },\n/* 1 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t\tvalue: true\n\t});\n\t\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\t\n\tvar _react = __webpack_require__(1);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tvar _reactDom = __webpack_require__(6);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\t\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\t\n\tvar CheckIfRender = function (_Component) {\n\t\t_inherits(CheckIfRender, _Component);\n\t\n\t\tfunction CheckIfRender(props) {\n\t\t\t_classCallCheck(this, CheckIfRender);\n\t\n\t\t\t//initialize to an empty link to stop loading the resource\n\t\t\tvar _this = _possibleConstructorReturn(this, (CheckIfRender.__proto__ || Object.getPrototypeOf(CheckIfRender)).call(this, props));\n\t\n\t\t\t_this.state = {\n\t\t\t\tlink: ''\n\t\t\t};\n\t\t\t//binding everything to 'this'\n\t\t\t_this.listener = _this.listener.bind(_this);\n\t\t\t_this.removeListener = _this.removeListener.bind(_this);\n\t\t\t_this.isInViewPort = _this.isInViewPort.bind(_this);\n\t\t\treturn _this;\n\t\t}\n\t\n\t\t_createClass(CheckIfRender, [{\n\t\t\tkey: 'listener',\n\t\t\tvalue: function listener() {\n\t\t\t\tvar _this2 = this;\n\t\n\t\t\t\t//check if the element is vertically visible\n\t\t\t\trequestAnimationFrame(function () {\n\t\t\t\t\tif (_this2.isInViewPort()) {\n\t\t\t\t\t\t//if it's visible update the state with the link provided in the props\n\t\t\t\t\t\t_this2.setState({ link: _this2.props.link });\n\t\t\t\t\t\t//remove the event listener\n\t\t\t\t\t\t_this2.removeListener();\n\t\t\t\t\t} else {\n\t\t\t\t\t\trequestAnimationFrame(function () {\n\t\t\t\t\t\t\t_this2.listener();\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}, {\n\t\t\tkey: 'isInViewPort',\n\t\t\tvalue: function isInViewPort() {\n\t\t\t\t//checks if the element is in both orizzontal and vertial viewport\n\t\t\t\tvar offset = this.props.offset || 100;\n\t\t\t\tvar verticalViewPort = window.scrollY + window.innerHeight + offset > this.state.top;\n\t\t\t\tvar orizzontalViewPort = window.scrollX + window.innerWidth + offset > this.state.left;\n\t\t\t\treturn verticalViewPort && orizzontalViewPort;\n\t\t\t}\n\t\t}, {\n\t\t\tkey: 'removeListener',\n\t\t\tvalue: function removeListener() {\n\t\t\t\twindow.removeEventListener('scroll', this.listener);\n\t\t\t}\n\t\t}, {\n\t\t\tkey: 'componentDidMount',\n\t\t\tvalue: function componentDidMount() {\n\t\t\t\tvar element = (0, _reactDom.findDOMNode)(this);\n\t\t\t\t//the distance from the pixel 0,0 and the top of the element\n\t\n\t\t\t\tvar _element$getBoundingC = element.getBoundingClientRect(),\n\t\t\t\t top = _element$getBoundingC.top,\n\t\t\t\t left = _element$getBoundingC.left;\n\t\n\t\t\t\tthis.setState({ top: top, left: left });\n\t\t\t\tthis.listener();\n\t\t\t\t//window.addEventListener('scroll',this.listener);\n\t\t\t}\n\t\t}, {\n\t\t\tkey: 'componentWillUnmount',\n\t\t\tvalue: function componentWillUnmount() {\n\t\t\t\tthis.removeListener();\n\t\t\t}\n\t\t}]);\n\t\n\t\treturn CheckIfRender;\n\t}(_react.Component);\n\t\n\tCheckIfRender.propTypes = {\n\t\tlink: _react.PropTypes.string.isRequired\n\t};\n\t\n\texports.default = CheckIfRender;\n\n/***/ },\n/* 3 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t\tvalue: true\n\t});\n\t\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\t\n\tvar _react = __webpack_require__(1);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tvar _baseClass = __webpack_require__(2);\n\t\n\tvar _baseClass2 = _interopRequireDefault(_baseClass);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\t\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\t\n\tvar LazyBackgroundImage = function (_CheckIfRender) {\n\t\t_inherits(LazyBackgroundImage, _CheckIfRender);\n\t\n\t\tfunction LazyBackgroundImage(props) {\n\t\t\t_classCallCheck(this, LazyBackgroundImage);\n\t\n\t\t\treturn _possibleConstructorReturn(this, (LazyBackgroundImage.__proto__ || Object.getPrototypeOf(LazyBackgroundImage)).call(this, props));\n\t\t}\n\t\n\t\t_createClass(LazyBackgroundImage, [{\n\t\t\tkey: 'render',\n\t\t\tvalue: function render() {\n\t\t\t\tvar style = Object.assign({}, this.props.style, {\n\t\t\t\t\tbackgroundImage: 'url(' + this.state.link + ')'\n\t\t\t\t});\n\t\t\t\treturn _react2.default.createElement('div', { className: this.props.className, style: style });\n\t\t\t}\n\t\t}]);\n\t\n\t\treturn LazyBackgroundImage;\n\t}(_baseClass2.default);\n\t\n\tLazyBackgroundImage.defaultProps = {\n\t\tclassName: '',\n\t\tstyle: {}\n\t};\n\t\n\texports.default = LazyBackgroundImage;\n\n/***/ },\n/* 4 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t\tvalue: true\n\t});\n\t\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\t\n\tvar _react = __webpack_require__(1);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tvar _baseClass = __webpack_require__(2);\n\t\n\tvar _baseClass2 = _interopRequireDefault(_baseClass);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\t\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\t\n\tvar LazyFrame = function (_CheckIfRender) {\n\t\t_inherits(LazyFrame, _CheckIfRender);\n\t\n\t\tfunction LazyFrame(props) {\n\t\t\t_classCallCheck(this, LazyFrame);\n\t\n\t\t\treturn _possibleConstructorReturn(this, (LazyFrame.__proto__ || Object.getPrototypeOf(LazyFrame)).call(this, props));\n\t\t}\n\t\n\t\t_createClass(LazyFrame, [{\n\t\t\tkey: 'render',\n\t\t\tvalue: function render() {\n\t\t\t\tvar style = Object.assign({}, {\n\t\t\t\t\twidth: '100%'\n\t\t\t\t}, this.props.style);\n\t\t\t\treturn _react2.default.createElement('iframe', { height: this.props.height,\n\t\t\t\t\tscrolling: this.props.scrolling,\n\t\t\t\t\tsrc: this.state.link,\n\t\t\t\t\tframeBorder: this.props.frameBorder,\n\t\t\t\t\tallowTransparency: this.props.allowTransparency,\n\t\t\t\t\tallowFullScreen: this.props.allowFullScreen,\n\t\t\t\t\tstyle: style });\n\t\t\t}\n\t\t}]);\n\t\n\t\treturn LazyFrame;\n\t}(_baseClass2.default);\n\t\n\tLazyFrame.defaultProps = {\n\t\theight: '500',\n\t\tscrolling: 'no',\n\t\tframeBorder: 'no',\n\t\tallowTransparency: 'true',\n\t\tallowFullScreen: 'true'\n\t};\n\t\n\texports.default = LazyFrame;\n\n/***/ },\n/* 5 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t\tvalue: true\n\t});\n\t\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\t\n\tvar _react = __webpack_require__(1);\n\t\n\tvar _react2 = _interopRequireDefault(_react);\n\t\n\tvar _baseClass = __webpack_require__(2);\n\t\n\tvar _baseClass2 = _interopRequireDefault(_baseClass);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\tfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\t\n\tfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\t\n\tvar LazyImage = function (_CheckIfRender) {\n\t\t_inherits(LazyImage, _CheckIfRender);\n\t\n\t\tfunction LazyImage(props) {\n\t\t\t_classCallCheck(this, LazyImage);\n\t\n\t\t\treturn _possibleConstructorReturn(this, (LazyImage.__proto__ || Object.getPrototypeOf(LazyImage)).call(this, props));\n\t\t}\n\t\n\t\t_createClass(LazyImage, [{\n\t\t\tkey: 'render',\n\t\t\tvalue: function render() {\n\t\t\t\treturn _react2.default.createElement('img', { src: this.state.link, alt: this.props.alt, style: this.props.style });\n\t\t\t}\n\t\t}]);\n\t\n\t\treturn LazyImage;\n\t}(_baseClass2.default);\n\t\n\texports.default = LazyImage;\n\n/***/ },\n/* 6 */\n/***/ function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_6__;\n\n/***/ }\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// dist/index.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 72955e84d166bbff5def","import LazyBackgroundImage from './lazyLoadBackgroundImage'\nimport LazyImage from './lazyLoadImage'\nimport LazyFrame from './lazyLoadFrame'\n\nmodule.exports = {\n\tLazyBackgroundImage,\n\tLazyImage,\n\tLazyFrame\n}\n\n\n// WEBPACK FOOTER //\n// ./src/index.js","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"React\",\"commonjs2\":\"react\",\"commonjs\":\"react\",\"amd\":\"react\"}\n// module id = 1\n// module chunks = 0","import React,{Component,PropTypes} from 'react'\nimport {findDOMNode} from 'react-dom'\n\nclass CheckIfRender extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\t\t//initialize to an empty link to stop loading the resource\n\t\tthis.state = {\n\t\t\tlink:''\n\t\t}\n\t\t//binding everything to 'this'\n\t\tthis.listener = this.listener.bind(this)\n\t\tthis.removeListener = this.removeListener.bind(this)\n\t\tthis.isInViewPort = this.isInViewPort.bind(this)\n\t}\n\tlistener() {\n\t\t//check if the element is vertically visible\n\t\trequestAnimationFrame(()=>{\n\t\t\tif(this.isInViewPort()) {\n\t\t\t\t//if it's visible update the state with the link provided in the props\n\t\t\t\tthis.setState({link:this.props.link})\n\t\t\t\t//remove the event listener\n\t\t\t\tthis.removeListener()\n\t\t\t} else {\n\t\t\t\trequestAnimationFrame(()=>{\n\t\t\t\t\tthis.listener()\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\t}\n\tisInViewPort() {\n\t\t//checks if the element is in both orizzontal and vertial viewport\n\t\tlet offset = this.props.offset || 100\n\t\tlet verticalViewPort = window.scrollY + window.innerHeight + offset > this.state.top\n\t\tlet orizzontalViewPort = window.scrollX + window.innerWidth + offset > this.state.left\n\t\treturn verticalViewPort && orizzontalViewPort\n\t}\n\tremoveListener() {\n\t\twindow.removeEventListener('scroll',this.listener)\n\t}\n\tcomponentDidMount() {\n\t\tconst element = findDOMNode(this);\n\t\t//the distance from the pixel 0,0 and the top of the element\n\t\tconst {top,left} = element.getBoundingClientRect();\n\t\tthis.setState({top,left})\n\t\tthis.listener()\n\t\t//window.addEventListener('scroll',this.listener);\n\t}\n\tcomponentWillUnmount() {\n\t\tthis.removeListener()\n\t}\n}\n\nCheckIfRender.propTypes = {\n\tlink: PropTypes.string.isRequired\n}\n\nexport default CheckIfRender\n\n\n// WEBPACK FOOTER //\n// ./src/baseClass.js","import React from 'react'\nimport CheckIfRender from './baseClass'\n\nclass LazyBackgroundImage extends CheckIfRender {\n\tconstructor(props) {\n\t\tsuper(props)\n\t}\n\trender() {\n\t\tlet style = Object.assign({}, this.props.style, {\n\t\t\tbackgroundImage:`url(${this.state.link})`\n\t\t})\n\t\treturn <div className={this.props.className} style={style}></div>\n\t}\n}\n\nLazyBackgroundImage.defaultProps = {\n\tclassName:'',\n\tstyle:{}\n}\n\nexport default LazyBackgroundImage\n\n\n// WEBPACK FOOTER //\n// ./src/lazyLoadBackgroundImage.js","import React from 'react'\nimport CheckIfRender from './baseClass'\n\nclass LazyFrame extends CheckIfRender {\n\tconstructor(props) {\n\t\tsuper(props)\n\t}\n\trender() {\n\t\tlet style = Object.assign({}, {\n\t\t\twidth:'100%'\n\t\t}, this.props.style)\n\t\treturn <iframe height={this.props.height}\n\t\t\tscrolling={this.props.scrolling}\n\t\t\tsrc={this.state.link}\n\t\t\tframeBorder={this.props.frameBorder}\n\t\t\tallowTransparency={this.props.allowTransparency}\n\t\t\tallowFullScreen={this.props.allowFullScreen}\n\t\t\tstyle={style} >\n\t\t</iframe>\n\t}\n}\n\nLazyFrame.defaultProps = {\n\theight:'500',\n\tscrolling:'no',\n\tframeBorder:'no',\n\tallowTransparency:'true',\n\tallowFullScreen:'true'\n}\n\nexport default LazyFrame\n\n\n// WEBPACK FOOTER //\n// ./src/lazyLoadFrame.js","import React from 'react'\nimport CheckIfRender from './baseClass'\n\nexport default class LazyImage extends CheckIfRender {\n\tconstructor(props) {\n\t\tsuper(props)\n\t}\n\trender(){\n\t\treturn <img src={this.state.link} alt={this.props.alt} style={this.props.style}></img>\n\t}\n}\n\n\n// WEBPACK FOOTER //\n// ./src/lazyLoadImage.js","module.exports = __WEBPACK_EXTERNAL_MODULE_6__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"ReactDOM\",\"commonjs2\":\"react-dom\",\"commonjs\":\"react-dom\",\"amd\":\"react-dom\"}\n// module id = 6\n// module chunks = 0"],"sourceRoot":""}
|
|
1
|
+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AAGA,EAAIhD,EAAcG,SAAS0C,OAAQG,IAC7ChD,EAAc4B,aAAa5B,EAAcG,SAAS6C,MACpDD,EAAYN,KAAKO,GAEjBhD,EAAcG,SAAS6C,GAAGnD,iBAI1BkD,EAAYF,OAAS,IACvB7C,EAAcG,SAAWH,EAAcG,SAAS8C,QAC9C,SAACX,EAAMY,GAAP,OAAkBH,EAAYI,SAASD,OAG3ClD,EAAcG,SAAWH,EAAcG,SAASiD,KAAI,SAACd,GAAD,OAClDtC,EAAcqC,qBAAqBC,MAErCtC,EAAc0C,mBAAqBV,OAAOW,sBACxC3C,EAAc4C,gBAKpB5C,EAAc8C,oBAAsB,WAClCd,OAAOqB,qBAAqBrD,EAAc0C,qBAI5C1C,EAAcE,sBAAwB,SAAUoD,GAC9CtD,EAAcG,SAAWH,EAAcG,SAAS8C,QAC9C,SAACX,GAAD,OAAUA,IAASgB,MAIvBtD,EAAc0C,oBAAqB,G","sources":["webpack://LazyReact/webpack/universalModuleDefinition","webpack://LazyReact/external umd {\"root\":\"React\",\"commonjs2\":\"react\",\"commonjs\":\"react\",\"amd\":\"react\"}","webpack://LazyReact/webpack/bootstrap","webpack://LazyReact/webpack/runtime/compat get default export","webpack://LazyReact/webpack/runtime/define property getters","webpack://LazyReact/webpack/runtime/hasOwnProperty shorthand","webpack://LazyReact/webpack/runtime/make namespace object","webpack://LazyReact/./src/baseClass.js","webpack://LazyReact/./src/lazyLoadBackgroundImage.js","webpack://LazyReact/./src/lazyLoadImage.js","webpack://LazyReact/./src/lazyLoadFrame.js","webpack://LazyReact/./src/lazyLoadComponent.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"LazyReact\"] = factory(require(\"react\"));\n\telse\n\t\troot[\"LazyReact\"] = factory(root[\"React\"]);\n})(self, function(__WEBPACK_EXTERNAL_MODULE__787__) {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__787__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import React, { useState, useEffect } from 'react' // eslint-disable-line no-unused-vars\n\nexport default function useRenderIfInViewPort(element, props) {\n const [state, setState] = useState({\n link: '',\n visible: false,\n })\n\n function makeItVisible() {\n setState({\n visible: true,\n link: props.link,\n })\n }\n\n useEffect(() => {\n if (element.current !== undefined)\n CheckIfRender.addElement({\n element: element.current,\n props,\n makeItVisible,\n })\n return () =>\n CheckIfRender.removeElementFromList({\n element: element.current,\n props,\n makeItVisible,\n })\n }, [])\n\n return state\n}\n\nconst CheckIfRender = {\n elements: [],\n}\n\nCheckIfRender.isInViewPort = ({ offset, top, left }) =>\n window.scrollY + window.innerHeight + offset > top &&\n window.scrollX + window.innerWidth + offset > left\n\nCheckIfRender.calculateNewPosition = (elem) => {\n const reference = elem.element\n const { top, left, right } = reference.getBoundingClientRect()\n return {\n ...elem,\n top,\n left,\n right,\n }\n}\n\nCheckIfRender.addElement = function ({ element, props, makeItVisible }) {\n //the distance from the pixel 0,0 and the top of the element\n const { top, left, right } = element.getBoundingClientRect()\n CheckIfRender.elements.push({\n element,\n top,\n left,\n right,\n offset: props.offset || 100,\n makeItVisible,\n })\n //check if has already been started the rAF cycle\n if (typeof CheckIfRender.isListenerAttached !== 'function') {\n CheckIfRender.isListenerAttached = window.requestAnimationFrame(\n CheckIfRender.eventHandler\n )\n }\n}\n\nCheckIfRender.eventHandler = function () {\n //if there is no more element to lazy load just remove the listeners/rAF\n if (CheckIfRender.elements.length === 0) {\n CheckIfRender.removeScrollHandler()\n } else {\n //save every index of elements that has been loaded\n let savedIndexs = []\n for (let i = 0; i < CheckIfRender.elements.length; i++) {\n if (CheckIfRender.isInViewPort(CheckIfRender.elements[i])) {\n savedIndexs.push(i)\n //make the element visible\n CheckIfRender.elements[i].makeItVisible()\n }\n }\n //remove elements that has already been loaded from the list of the elements\n if (savedIndexs.length > 0)\n CheckIfRender.elements = CheckIfRender.elements.filter(\n (elem, index) => !savedIndexs.includes(index)\n )\n //update the coordinates of the elements\n CheckIfRender.elements = CheckIfRender.elements.map((elem) =>\n CheckIfRender.calculateNewPosition(elem)\n )\n CheckIfRender.isListenerAttached = window.requestAnimationFrame(\n CheckIfRender.eventHandler\n )\n }\n}\n\nCheckIfRender.removeScrollHandler = function () {\n window.cancelAnimationFrame(CheckIfRender.isListenerAttached)\n}\n\n//When an element is unloaded remove it from the list of elements that are waiting to be lazy-loaded\nCheckIfRender.removeElementFromList = function (toRemove) {\n CheckIfRender.elements = CheckIfRender.elements.filter(\n (elem) => elem !== toRemove\n )\n}\n\nCheckIfRender.isListenerAttached = false\n\nexport { CheckIfRender }\n","import React, { useState, useEffect, useRef } from 'react' // eslint-disable-line no-unused-vars\nimport useIsInViewPort from './baseClass'\n\nexport default function LazyBackgroundImage(props) {\n const ref = useRef()\n let isViewable = useIsInViewPort(ref, props)\n const [style, setStyle] = useState({\n backgroundImage: `url(${isViewable.link})`,\n ...props.style,\n })\n\n useEffect(() => {\n setStyle({\n backgroundImage: `url(${isViewable.link})`,\n ...props.style,\n })\n }, [isViewable])\n\n return <div className={props.className} style={style} ref={ref} />\n}\n","import React, { useRef } from 'react' // eslint-disable-line no-unused-vars\nimport useIsInViewPort from './baseClass'\n\nexport default function LazyImage(props) {\n const ref = useRef()\n const isViewable = useIsInViewPort(ref, props)\n\n return (\n <img\n src={isViewable.link}\n alt={props.alt}\n style={props.style}\n className={props.className}\n ref={ref}\n />\n )\n}\n","import React, { useRef } from 'react' // eslint-disable-line no-unused-vars\nimport useIsInViewPort from './baseClass'\n\nexport default function LazyFrame(props) {\n const ref = useRef()\n let isViewable = useIsInViewPort(ref, props)\n\n return (\n <iframe\n height={props.height || '500'}\n scrolling={props.scrolling || 'no'}\n src={isViewable.link}\n frameBorder={props.frameBorder || 'no'}\n allowtransparency={props.allowTransparency || 'true'}\n allowFullScreen={props.allowFullScreen || true}\n style={props.style || {}}\n ref={ref}\n />\n )\n}\n","import React, { useRef } from 'react' // eslint-disable-line no-unused-vars\nimport useIsInViewPort from './baseClass'\n\nexport default function LazyComponent(props) {\n const ref = useRef()\n let isViewable = useIsInViewPort(ref, props)\n\n const placeHolder = (\n <div\n style={\n props.style\n ? props.style\n : {\n heigt: '300px',\n width: '300px',\n }\n }\n />\n )\n\n return (\n <div ref={ref}>{isViewable.visible ? props.children : placeHolder}</div>\n )\n}\n"],"names":["root","factory","exports","module","require","define","amd","self","__WEBPACK_EXTERNAL_MODULE__787__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","useRenderIfInViewPort","element","props","useState","link","visible","state","setState","makeItVisible","useEffect","current","CheckIfRender","addElement","removeElementFromList","elements","LazyBackgroundImage","ref","useRef","isViewable","useIsInViewPort","backgroundImage","style","setStyle","className","LazyImage","src","alt","LazyFrame","height","scrolling","frameBorder","allowtransparency","allowTransparency","allowFullScreen","LazyComponent","placeHolder","heigt","width","children","isInViewPort","offset","top","left","window","scrollY","innerHeight","scrollX","innerWidth","calculateNewPosition","elem","getBoundingClientRect","right","push","isListenerAttached","requestAnimationFrame","eventHandler","length","removeScrollHandler","savedIndexs","i","filter","index","includes","map","cancelAnimationFrame","toRemove"],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lazy-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "components to lazy load iframes, images and images as backgrounds",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
"lint": "eslint src/*",
|
|
11
11
|
"lint:fix": "eslint --fix src/*",
|
|
12
12
|
"prettify": "prettier --write --single-quote --no-semi ./src/*.js",
|
|
13
|
-
"precommit": "lint-staged"
|
|
13
|
+
"precommit": "lint-staged",
|
|
14
|
+
"test": "jest"
|
|
14
15
|
},
|
|
15
16
|
"lint-staged": {
|
|
16
|
-
"
|
|
17
|
+
"src/*.js": [
|
|
17
18
|
"prettier --write --single-quote --no-semi",
|
|
18
19
|
"git add"
|
|
19
20
|
]
|
|
@@ -29,25 +30,29 @@
|
|
|
29
30
|
"url": "https://github.com/jonathanobino/react-lazy"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"babel
|
|
33
|
-
"babel-
|
|
34
|
-
"babel-
|
|
35
|
-
"babel-
|
|
36
|
-
"
|
|
37
|
-
"babel-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
33
|
+
"@babel/core": "^7.11.6",
|
|
34
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
|
|
35
|
+
"@babel/preset-env": "^7.11.5",
|
|
36
|
+
"@babel/preset-react": "^7.10.4",
|
|
37
|
+
"@types/jest": "^27.4.0",
|
|
38
|
+
"babel-cli": "^6.26.0",
|
|
39
|
+
"babel-loader": "^8.1.0",
|
|
40
|
+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
|
41
|
+
"eslint": "^7.10.0",
|
|
42
|
+
"eslint-plugin-react": "^7.21.3",
|
|
43
|
+
"husky": "^4.3.0",
|
|
44
|
+
"jest": "^27.5.1",
|
|
45
|
+
"lint-staged": "^10.4.0",
|
|
46
|
+
"prettier": "^2.1.2",
|
|
47
|
+
"webpack": "^5.66.0",
|
|
48
|
+
"webpack-cli": "^4.9.1"
|
|
44
49
|
},
|
|
45
50
|
"dependencies": {
|
|
46
|
-
"react": "^
|
|
47
|
-
"react-dom": "^
|
|
51
|
+
"react": "^17.0.2",
|
|
52
|
+
"react-dom": "^17.0.2"
|
|
48
53
|
},
|
|
49
54
|
"peerDependencies": {
|
|
50
|
-
"react": "^
|
|
51
|
-
"react-dom": "^
|
|
55
|
+
"react": "^17.0.2",
|
|
56
|
+
"react-dom": "^17.0.2"
|
|
52
57
|
}
|
|
53
58
|
}
|
package/src/baseClass.js
CHANGED
|
@@ -1,47 +1,75 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState, useEffect } from 'react' // eslint-disable-line no-unused-vars
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default function useRenderIfInViewPort(element, props) {
|
|
4
|
+
const [state, setState] = useState({
|
|
5
|
+
link: '',
|
|
6
|
+
visible: false,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
function makeItVisible() {
|
|
10
|
+
setState({
|
|
11
|
+
visible: true,
|
|
12
|
+
link: props.link,
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (element.current !== undefined)
|
|
18
|
+
CheckIfRender.addElement({
|
|
19
|
+
element: element.current,
|
|
20
|
+
props,
|
|
21
|
+
makeItVisible,
|
|
22
|
+
})
|
|
23
|
+
return () =>
|
|
24
|
+
CheckIfRender.removeElementFromList({
|
|
25
|
+
element: element.current,
|
|
26
|
+
props,
|
|
27
|
+
makeItVisible,
|
|
28
|
+
})
|
|
29
|
+
}, [])
|
|
30
|
+
|
|
31
|
+
return state
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const CheckIfRender = {
|
|
35
|
+
elements: [],
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
CheckIfRender.isInViewPort = ({ offset, top, left }) =>
|
|
4
39
|
window.scrollY + window.innerHeight + offset > top &&
|
|
5
40
|
window.scrollX + window.innerWidth + offset > left
|
|
6
41
|
|
|
7
|
-
|
|
8
|
-
const reference = elem.element
|
|
42
|
+
CheckIfRender.calculateNewPosition = (elem) => {
|
|
43
|
+
const reference = elem.element
|
|
9
44
|
const { top, left, right } = reference.getBoundingClientRect()
|
|
10
45
|
return {
|
|
11
46
|
...elem,
|
|
12
47
|
top,
|
|
13
48
|
left,
|
|
14
|
-
right
|
|
49
|
+
right,
|
|
15
50
|
}
|
|
16
51
|
}
|
|
17
52
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
componentDidMount() {
|
|
35
|
-
CheckIfRender.addElement(this)
|
|
36
|
-
}
|
|
37
|
-
componentWillUnmount() {
|
|
38
|
-
CheckIfRender.removeElementFromList(this)
|
|
53
|
+
CheckIfRender.addElement = function ({ element, props, makeItVisible }) {
|
|
54
|
+
//the distance from the pixel 0,0 and the top of the element
|
|
55
|
+
const { top, left, right } = element.getBoundingClientRect()
|
|
56
|
+
CheckIfRender.elements.push({
|
|
57
|
+
element,
|
|
58
|
+
top,
|
|
59
|
+
left,
|
|
60
|
+
right,
|
|
61
|
+
offset: props.offset || 100,
|
|
62
|
+
makeItVisible,
|
|
63
|
+
})
|
|
64
|
+
//check if has already been started the rAF cycle
|
|
65
|
+
if (typeof CheckIfRender.isListenerAttached !== 'function') {
|
|
66
|
+
CheckIfRender.isListenerAttached = window.requestAnimationFrame(
|
|
67
|
+
CheckIfRender.eventHandler
|
|
68
|
+
)
|
|
39
69
|
}
|
|
40
70
|
}
|
|
41
71
|
|
|
42
|
-
CheckIfRender.
|
|
43
|
-
|
|
44
|
-
CheckIfRender.eventHandler = function() {
|
|
72
|
+
CheckIfRender.eventHandler = function () {
|
|
45
73
|
//if there is no more element to lazy load just remove the listeners/rAF
|
|
46
74
|
if (CheckIfRender.elements.length === 0) {
|
|
47
75
|
CheckIfRender.removeScrollHandler()
|
|
@@ -49,10 +77,10 @@ CheckIfRender.eventHandler = function() {
|
|
|
49
77
|
//save every index of elements that has been loaded
|
|
50
78
|
let savedIndexs = []
|
|
51
79
|
for (let i = 0; i < CheckIfRender.elements.length; i++) {
|
|
52
|
-
if (isInViewPort(CheckIfRender.elements[i])) {
|
|
80
|
+
if (CheckIfRender.isInViewPort(CheckIfRender.elements[i])) {
|
|
53
81
|
savedIndexs.push(i)
|
|
54
82
|
//make the element visible
|
|
55
|
-
CheckIfRender.elements[i].
|
|
83
|
+
CheckIfRender.elements[i].makeItVisible()
|
|
56
84
|
}
|
|
57
85
|
}
|
|
58
86
|
//remove elements that has already been loaded from the list of the elements
|
|
@@ -61,8 +89,8 @@ CheckIfRender.eventHandler = function() {
|
|
|
61
89
|
(elem, index) => !savedIndexs.includes(index)
|
|
62
90
|
)
|
|
63
91
|
//update the coordinates of the elements
|
|
64
|
-
CheckIfRender.elements = CheckIfRender.elements.map(elem =>
|
|
65
|
-
calculateNewPosition(elem)
|
|
92
|
+
CheckIfRender.elements = CheckIfRender.elements.map((elem) =>
|
|
93
|
+
CheckIfRender.calculateNewPosition(elem)
|
|
66
94
|
)
|
|
67
95
|
CheckIfRender.isListenerAttached = window.requestAnimationFrame(
|
|
68
96
|
CheckIfRender.eventHandler
|
|
@@ -70,41 +98,17 @@ CheckIfRender.eventHandler = function() {
|
|
|
70
98
|
}
|
|
71
99
|
}
|
|
72
100
|
|
|
73
|
-
CheckIfRender.
|
|
74
|
-
//the distance from the pixel 0,0 and the top of the element
|
|
75
|
-
const { top, left, right } = element.domNode.getBoundingClientRect()
|
|
76
|
-
CheckIfRender.elements.push({
|
|
77
|
-
element,
|
|
78
|
-
top,
|
|
79
|
-
left,
|
|
80
|
-
right,
|
|
81
|
-
offset: element.props.offset || 100
|
|
82
|
-
})
|
|
83
|
-
//check if has already been started the rAF cycle
|
|
84
|
-
if (typeof CheckIfRender.isListenerAttached !== 'function') {
|
|
85
|
-
CheckIfRender.isListenerAttached = window.requestAnimationFrame(
|
|
86
|
-
CheckIfRender.eventHandler
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
CheckIfRender.removeScrollHandler = function() {
|
|
101
|
+
CheckIfRender.removeScrollHandler = function () {
|
|
92
102
|
window.cancelAnimationFrame(CheckIfRender.isListenerAttached)
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
//When an element is unloaded remove it from the list of elements that are waiting to be lazy-loaded
|
|
96
|
-
CheckIfRender.removeElementFromList = function(toRemove) {
|
|
106
|
+
CheckIfRender.removeElementFromList = function (toRemove) {
|
|
97
107
|
CheckIfRender.elements = CheckIfRender.elements.filter(
|
|
98
|
-
elem => elem
|
|
108
|
+
(elem) => elem !== toRemove
|
|
99
109
|
)
|
|
100
110
|
}
|
|
101
111
|
|
|
102
112
|
CheckIfRender.isListenerAttached = false
|
|
103
113
|
|
|
104
|
-
|
|
105
|
-
CheckIfRender.propTypes = {
|
|
106
|
-
link: PropTypes.string.isRequired
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export default CheckIfRender
|
|
114
|
+
export { CheckIfRender }
|
|
@@ -1,35 +1,20 @@
|
|
|
1
|
-
import React from 'react' // eslint-disable-line no-unused-vars
|
|
2
|
-
import
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react' // eslint-disable-line no-unused-vars
|
|
2
|
+
import useIsInViewPort from './baseClass'
|
|
3
3
|
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
className={this.props.className}
|
|
12
|
-
style={this.style}
|
|
13
|
-
ref={node => (this.domNode = node)}
|
|
14
|
-
/>
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
componentWillMount() {
|
|
18
|
-
this.style = {
|
|
19
|
-
backgroundImage: `url(${this.state.link})`,
|
|
20
|
-
...this.props.style
|
|
21
|
-
}
|
|
22
|
-
}
|
|
4
|
+
export default function LazyBackgroundImage(props) {
|
|
5
|
+
const ref = useRef()
|
|
6
|
+
let isViewable = useIsInViewPort(ref, props)
|
|
7
|
+
const [style, setStyle] = useState({
|
|
8
|
+
backgroundImage: `url(${isViewable.link})`,
|
|
9
|
+
...props.style,
|
|
10
|
+
})
|
|
23
11
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setStyle({
|
|
14
|
+
backgroundImage: `url(${isViewable.link})`,
|
|
15
|
+
...props.style,
|
|
16
|
+
})
|
|
17
|
+
}, [isViewable])
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
className: '',
|
|
34
|
-
style: {}
|
|
19
|
+
return <div className={props.className} style={style} ref={ref} />
|
|
35
20
|
}
|
package/src/lazyLoadComponent.js
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
import React from 'react' // eslint-disable-line no-unused-vars
|
|
2
|
-
import
|
|
1
|
+
import React, { useRef } from 'react' // eslint-disable-line no-unused-vars
|
|
2
|
+
import useIsInViewPort from './baseClass'
|
|
3
3
|
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
render() {
|
|
9
|
-
let toRender = this.state.visible ? this.props.children : <div />
|
|
4
|
+
export default function LazyComponent(props) {
|
|
5
|
+
const ref = useRef()
|
|
6
|
+
let isViewable = useIsInViewPort(ref, props)
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
const placeHolder = (
|
|
9
|
+
<div
|
|
10
|
+
style={
|
|
11
|
+
props.style
|
|
12
|
+
? props.style
|
|
13
|
+
: {
|
|
14
|
+
heigt: '300px',
|
|
15
|
+
width: '300px',
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.style.height = '300px'
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
LazyComponent.defaultProps = {
|
|
30
|
-
style: {},
|
|
31
|
-
className: ''
|
|
21
|
+
return (
|
|
22
|
+
<div ref={ref}>{isViewable.visible ? props.children : placeHolder}</div>
|
|
23
|
+
)
|
|
32
24
|
}
|
package/src/lazyLoadFrame.js
CHANGED
|
@@ -1,36 +1,20 @@
|
|
|
1
|
-
import React from 'react' // eslint-disable-line no-unused-vars
|
|
2
|
-
import
|
|
1
|
+
import React, { useRef } from 'react' // eslint-disable-line no-unused-vars
|
|
2
|
+
import useIsInViewPort from './baseClass'
|
|
3
3
|
|
|
4
|
-
export default
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
render() {
|
|
9
|
-
return (
|
|
10
|
-
<iframe
|
|
11
|
-
height={this.props.height}
|
|
12
|
-
scrolling={this.props.scrolling}
|
|
13
|
-
src={this.state.link}
|
|
14
|
-
frameBorder={this.props.frameBorder}
|
|
15
|
-
allowTransparency={this.props.allowTransparency}
|
|
16
|
-
allowFullScreen={this.props.allowFullScreen}
|
|
17
|
-
style={this.style}
|
|
18
|
-
ref={node => (this.domNode = node)}
|
|
19
|
-
/>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
componentWillMount() {
|
|
23
|
-
this.style = {
|
|
24
|
-
minWidth: '100%',
|
|
25
|
-
...this.props.style
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
4
|
+
export default function LazyFrame(props) {
|
|
5
|
+
const ref = useRef()
|
|
6
|
+
let isViewable = useIsInViewPort(ref, props)
|
|
29
7
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
8
|
+
return (
|
|
9
|
+
<iframe
|
|
10
|
+
height={props.height || '500'}
|
|
11
|
+
scrolling={props.scrolling || 'no'}
|
|
12
|
+
src={isViewable.link}
|
|
13
|
+
frameBorder={props.frameBorder || 'no'}
|
|
14
|
+
allowtransparency={props.allowTransparency || 'true'}
|
|
15
|
+
allowFullScreen={props.allowFullScreen || true}
|
|
16
|
+
style={props.style || {}}
|
|
17
|
+
ref={ref}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
36
20
|
}
|