UNPKG

twreporter-react

Version:

React-Redux site for The Reporter Foundation in Taiwan

1 lines 6.95 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.LazyLoad=t(require("react"),require("react-dom")):e.LazyLoad=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(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 a=function(){function e(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)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),f=n(6),u=n(7),l=u.findDOMNode,s=f.Children,c=f.Component,d=f.PropTypes,p=n(4),h=p.add,v=p.remove,y=n(1),m=n(5),b=n(3),g=n(2),w=function(e){function t(e){o(this,t);var n=r(this,Object.getPrototypeOf(t).call(this,e));return n.lazyLoadHandler=n.lazyLoadHandler.bind(n),e.throttle>0&&(e.debounce?n.lazyLoadHandler=y(n.lazyLoadHandler,e.throttle):n.lazyLoadHandler=m(n.lazyLoadHandler,e.throttle)),n.state={visible:!1},n}return i(t,e),a(t,[{key:"componentDidMount",value:function(){var e=this.getEventNode();this.lazyLoadHandler(),this.lazyLoadHandler.flush&&this.lazyLoadHandler.flush(),h(window,"resize",this.lazyLoadHandler),h(e,"scroll",this.lazyLoadHandler)}},{key:"componentWillReceiveProps",value:function(){this.state.visible||this.lazyLoadHandler()}},{key:"shouldComponentUpdate",value:function(e,t){return t.visible}},{key:"componentWillUnmount",value:function(){this.lazyLoadHandler.cancel&&this.lazyLoadHandler.cancel(),this.detachListeners()}},{key:"getEventNode",value:function(){return b(l(this))}},{key:"getOffset",value:function(){var e=this.props,t=e.offset,n=e.offsetVertical,o=e.offsetHorizontal,r=e.offsetTop,i=e.offsetBottom,a=e.offsetLeft,f=e.offsetRight,u=e.threshold,l=u||t,s=n||l,c=o||l;return{top:r||s,bottom:i||s,left:a||c,right:f||c}}},{key:"lazyLoadHandler",value:function(){var e=this.getOffset(),t=l(this),n=this.getEventNode();if(g(t,n,e)){var o=this.props.onContentVisible;this.setState({visible:!0}),this.detachListeners(),o&&o()}}},{key:"detachListeners",value:function(){var e=this.getEventNode();v(window,"resize",this.lazyLoadHandler),v(e,"scroll",this.lazyLoadHandler)}},{key:"render",value:function(){var e=this.props,t=e.children,n=e.className,o=e.height,r=e.width,i=this.state.visible,a={height:o,width:r},u="LazyLoad"+(i?" is-visible":"")+(n?" "+n:"");return f.createElement("div",{className:u,style:a},i&&s.only(t))}}]),t}(c);w.propTypes={children:d.node.isRequired,className:d.string,debounce:d.bool,height:d.oneOfType([d.string,d.number]),offset:d.number,offsetBottom:d.number,offsetHorizontal:d.number,offsetLeft:d.number,offsetRight:d.number,offsetTop:d.number,offsetVertical:d.number,threshold:d.number,throttle:d.number,width:d.oneOfType([d.string,d.number]),onContentVisible:d.func},w.defaultProps={debounce:!0,offset:0,offsetBottom:0,offsetHorizontal:0,offsetLeft:0,offsetRight:0,offsetTop:0,offsetVertical:0,throttle:250},e.exports=w},function(e,t){(function(t){function n(e,t,n){function o(){g&&clearTimeout(g),p&&clearTimeout(p),L=0,d=p=y=g=w=void 0}function f(t,n){n&&clearTimeout(n),p=g=w=void 0,t&&(L=b(),h=e.apply(y,d),g||p||(d=y=void 0))}function u(){var e=t-(b()-v);0>=e||e>t?f(w,p):g=setTimeout(u,e)}function l(){return(g&&w||p&&H)&&(h=e.apply(y,d)),o(),h}function s(){f(H,g)}function c(){if(d=arguments,v=b(),y=this,w=H&&(g||!x),z===!1)var n=x&&!g;else{p||x||(L=v);var o=z-(v-L),r=0>=o||o>z;r?(p&&(p=clearTimeout(p)),L=v,h=e.apply(y,d)):p||(p=setTimeout(s,o))}return r&&g?g=clearTimeout(g):g||t===z||(g=setTimeout(u,t)),n&&(r=!0,h=e.apply(y,d)),!r||g||p||(d=y=void 0),h}var d,p,h,v,y,g,w,L=0,x=!1,z=!1,H=!0;if("function"!=typeof e)throw new TypeError(a);return t=i(t)||0,r(n)&&(x=!!n.leading,z="maxWait"in n&&m(i(n.maxWait)||0,t),H="trailing"in n?!!n.trailing:H),c.cancel=o,c.flush=l,c}function o(e){var t=r(e)?y.call(e):"";return t==u||t==l}function r(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function i(e){if(r(e)){var t=o(e.valueOf)?e.valueOf():e;e=r(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(s,"");var n=d.test(e);return n||p.test(e)?h(e.slice(2),n?2:8):c.test(e)?f:+e}var a="Expected a function",f=NaN,u="[object Function]",l="[object GeneratorFunction]",s=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,d=/^0b[01]+$/i,p=/^0o[0-7]+$/i,h=parseInt,v=t.Object.prototype,y=v.toString,m=Math.max,b=Date.now;e.exports=n}).call(t,function(){return this}())},function(e,t){"use strict";var n=function(e){return null===e.offsetParent},o=function(e){var t=e.getBoundingClientRect();return{top:t.top+window.pageYOffset,left:t.left+window.pageXOffset}},r=function(e,t,r){if(n(e))return!1;var i=void 0,a=void 0,f=void 0,u=void 0;if("undefined"==typeof t||t===window)i=window.pageYOffset,a=window.pageXOffset,f=i+window.innerHeight,u=a+window.innerWidth;else{var l=o(t);i=l.top,a=l.left,f=i+t.offsetHeight,u=a+t.offsetWidth}var s=o(e);return i<s.top+r.bottom+e.offsetHeight&&f>s.top-r.top&&a<s.left+r.right+e.offsetWidth&&u>s.left-r.left};e.exports=r},function(e,t){"use strict";var n=function(e,t){return"undefined"!=typeof getComputedStyle?getComputedStyle(e,null).getPropertyValue(t):e.style[t]},o=function(e){return n(e,"overflow")+n(e,"overflow-y")+n(e,"overflow-x")},r=function(e){if(!(e instanceof HTMLElement))return window;for(var t=e;t&&t!==document.body&&t!==document.documentElement&&t.parentNode;){if(/(scroll|auto)/.test(o(t)))return t;t=t.parentNode}return window};e.exports=r},function(e,t,n){var o,r;!function(i,a){o=a,r="function"==typeof o?o.call(t,n,t,e):o,!(void 0!==r&&(e.exports=r))}(this,function(){function e(e,t){return function(n,o,r,i){n[e]?n[e](o,r,i):n[t]&&n[t]("on"+o,r)}}return{add:e("addEventListener","attachEvent"),remove:e("removeEventListener","detachEvent")}})},function(e,t,n){function o(e,t,n){var o=!0,f=!0;if("function"!=typeof e)throw new TypeError(a);return r(n)&&(o="leading"in n?!!n.leading:o,f="trailing"in n?!!n.trailing:f),i(e,t,{leading:o,maxWait:t,trailing:f})}function r(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var i=n(1),a="Expected a function";e.exports=o},function(t,n){t.exports=e},function(e,n){e.exports=t}])});