UNPKG

react-delightful-scroller

Version:

Delightful, virtualized modern infinite scroller 🎉

3 lines (2 loc) • 36.8 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e=e||self).ReactDelightfulScroller=t(e.React)}(this,function(e){"use strict";var t="default"in e?e.default:e;function n(){return(n=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}).apply(this,arguments)}function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=e[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function o(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}let{useState:i,useEffect:a}=t;function c(){return{innerHeight:window.innerHeight,innerWidth:window.innerWidth,outerHeight:window.outerHeight,outerWidth:window.outerWidth}}var s=function(){let[e,t]=i(c());function n(){t(c())}return a(()=>(window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n)}),[]),e},u=t.useState,f=t.useCallback,l=t.useLayoutEffect;function d(e){return e?{width:e.offsetWidth,height:e.offsetHeight}:{width:0,height:0}}var p=function(e){var t=u(d(e?e.current:{})),n=t[0],r=t[1],o=f(function(){e.current&&r(d(e.current))},[e]);return l(function(){if(e.current){if(o(),"function"==typeof ResizeObserver){var t=new ResizeObserver(function(){o()});return t.observe(e.current),function(){t.disconnect(e.current),t=null}}return window.addEventListener("resize",o),function(){window.removeEventListener("resize",o)}}},[e.current]),n},h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function v(e,t){return e(t={exports:{}},t.exports),t.exports}var y=v(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&Symbol.for,r=n?Symbol.for("react.element"):60103,o=n?Symbol.for("react.portal"):60106,i=n?Symbol.for("react.fragment"):60107,a=n?Symbol.for("react.strict_mode"):60108,c=n?Symbol.for("react.profiler"):60114,s=n?Symbol.for("react.provider"):60109,u=n?Symbol.for("react.context"):60110,f=n?Symbol.for("react.async_mode"):60111,l=n?Symbol.for("react.concurrent_mode"):60111,d=n?Symbol.for("react.forward_ref"):60112,p=n?Symbol.for("react.suspense"):60113,h=n?Symbol.for("react.memo"):60115,m=n?Symbol.for("react.lazy"):60116;function v(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case f:case l:case i:case c:case a:case p:return e;default:switch(e=e&&e.$$typeof){case u:case d:case s:return e;default:return t}}case m:case h:case o:return t}}}function y(e){return v(e)===l}t.typeOf=v,t.AsyncMode=f,t.ConcurrentMode=l,t.ContextConsumer=u,t.ContextProvider=s,t.Element=r,t.ForwardRef=d,t.Fragment=i,t.Lazy=m,t.Memo=h,t.Portal=o,t.Profiler=c,t.StrictMode=a,t.Suspense=p,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===i||e===l||e===c||e===a||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===h||e.$$typeof===s||e.$$typeof===u||e.$$typeof===d)},t.isAsyncMode=function(e){return y(e)||v(e)===f},t.isConcurrentMode=y,t.isContextConsumer=function(e){return v(e)===u},t.isContextProvider=function(e){return v(e)===s},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return v(e)===d},t.isFragment=function(e){return v(e)===i},t.isLazy=function(e){return v(e)===m},t.isMemo=function(e){return v(e)===h},t.isPortal=function(e){return v(e)===o},t.isProfiler=function(e){return v(e)===c},t.isStrictMode=function(e){return v(e)===a},t.isSuspense=function(e){return v(e)===p}});m(y);y.typeOf,y.AsyncMode,y.ConcurrentMode,y.ContextConsumer,y.ContextProvider,y.Element,y.ForwardRef,y.Fragment,y.Lazy,y.Memo,y.Portal,y.Profiler,y.StrictMode,y.Suspense,y.isValidElementType,y.isAsyncMode,y.isConcurrentMode,y.isContextConsumer,y.isContextProvider,y.isElement,y.isForwardRef,y.isFragment,y.isLazy,y.isMemo,y.isPortal,y.isProfiler,y.isStrictMode,y.isSuspense;var b=v(function(e,t){"production"!==process.env.NODE_ENV&&function(){Object.defineProperty(t,"__esModule",{value:!0});var e="function"==typeof Symbol&&Symbol.for,n=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,c=e?Symbol.for("react.provider"):60109,s=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,f=e?Symbol.for("react.concurrent_mode"):60111,l=e?Symbol.for("react.forward_ref"):60112,d=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.memo"):60115,h=e?Symbol.for("react.lazy"):60116;var m=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=0,i="Warning: "+e.replace(/%s/g,function(){return n[o++]});"undefined"!=typeof console&&console.warn(i);try{throw new Error(i)}catch(e){}},v=function(e,t){if(void 0===t)throw new Error("`lowPriorityWarning(condition, format, ...args)` requires a warning message argument");if(!e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];m.apply(void 0,[t].concat(r))}};function y(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case n:var m=e.type;switch(m){case u:case f:case o:case a:case i:case d:return m;default:var v=m&&m.$$typeof;switch(v){case s:case l:case c:return v;default:return t}}case h:case p:case r:return t}}}var b=u,g=f,w=s,_=c,O=n,E=l,S=o,x=h,R=p,M=r,j=a,T=i,C=d,z=!1;function I(e){return y(e)===f}t.typeOf=y,t.AsyncMode=b,t.ConcurrentMode=g,t.ContextConsumer=w,t.ContextProvider=_,t.Element=O,t.ForwardRef=E,t.Fragment=S,t.Lazy=x,t.Memo=R,t.Portal=M,t.Profiler=j,t.StrictMode=T,t.Suspense=C,t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===f||e===a||e===i||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===h||e.$$typeof===p||e.$$typeof===c||e.$$typeof===s||e.$$typeof===l)},t.isAsyncMode=function(e){return z||(z=!0,v(!1,"The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),I(e)||y(e)===u},t.isConcurrentMode=I,t.isContextConsumer=function(e){return y(e)===s},t.isContextProvider=function(e){return y(e)===c},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===n},t.isForwardRef=function(e){return y(e)===l},t.isFragment=function(e){return y(e)===o},t.isLazy=function(e){return y(e)===h},t.isMemo=function(e){return y(e)===p},t.isPortal=function(e){return y(e)===r},t.isProfiler=function(e){return y(e)===a},t.isStrictMode=function(e){return y(e)===i},t.isSuspense=function(e){return y(e)===d}}()});m(b);b.typeOf,b.AsyncMode,b.ConcurrentMode,b.ContextConsumer,b.ContextProvider,b.Element,b.ForwardRef,b.Fragment,b.Lazy,b.Memo,b.Portal,b.Profiler,b.StrictMode,b.Suspense,b.isValidElementType,b.isAsyncMode,b.isConcurrentMode,b.isContextConsumer,b.isContextProvider,b.isElement,b.isForwardRef,b.isFragment,b.isLazy,b.isMemo,b.isPortal,b.isProfiler,b.isStrictMode,b.isSuspense;var g=v(function(e){"production"===process.env.NODE_ENV?e.exports=y:e.exports=b}),w=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;function E(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}var S=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,r,o=E(e),i=1;i<arguments.length;i++){for(var a in n=Object(arguments[i]))_.call(n,a)&&(o[a]=n[a]);if(w){r=w(n);for(var c=0;c<r.length;c++)O.call(n,r[c])&&(o[r[c]]=n[r[c]])}}return o},x="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",R=function(){};if("production"!==process.env.NODE_ENV){var M=x,j={},T=Function.call.bind(Object.prototype.hasOwnProperty);R=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function C(e,t,n,r,o){if("production"!==process.env.NODE_ENV)for(var i in e)if(T(e,i)){var a;try{if("function"!=typeof e[i]){var c=Error((r||"React class")+": "+n+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.");throw c.name="Invariant Violation",c}a=e[i](t,i,r,n,null,M)}catch(e){a=e}if(!a||a instanceof Error||R((r||"React class")+": type specification of "+n+" `"+i+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof a+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),a instanceof Error&&!(a.message in j)){j[a.message]=!0;var s=o?o():"";R("Failed "+n+" type: "+a.message+(null!=s?s:""))}}}C.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(j={})};var z=C,I=Function.call.bind(Object.prototype.hasOwnProperty),P=function(){};function A(){return null}"production"!==process.env.NODE_ENV&&(P=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}});var D=function(e,t){var n="function"==typeof Symbol&&Symbol.iterator,r="@@iterator";var o="<<anonymous>>",i={array:u("array"),bool:u("boolean"),func:u("function"),number:u("number"),object:u("object"),string:u("string"),symbol:u("symbol"),any:s(A),arrayOf:function(e){return s(function(t,n,r,o,i){if("function"!=typeof e)return new c("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=t[n];if(!Array.isArray(a)){var s=l(a);return new c("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected an array.")}for(var u=0;u<a.length;u++){var f=e(a,u,r,o,i+"["+u+"]",x);if(f instanceof Error)return f}return null})},element:s(function(t,n,r,o,i){var a=t[n];if(!e(a)){var s=l(a);return new c("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected a single ReactElement.")}return null}),elementType:s(function(e,t,n,r,o){var i=e[t];if(!g.isValidElementType(i)){var a=l(i);return new c("Invalid "+r+" `"+o+"` of type `"+a+"` supplied to `"+n+"`, expected a single ReactElement type.")}return null}),instanceOf:function(e){return s(function(t,n,r,i,a){if(!(t[n]instanceof e)){var s=e.name||o,u=function(e){if(!e.constructor||!e.constructor.name)return o;return e.constructor.name}(t[n]);return new c("Invalid "+i+" `"+a+"` of type `"+u+"` supplied to `"+r+"`, expected instance of `"+s+"`.")}return null})},node:s(function(e,t,n,r,o){return f(e[t])?null:new c("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}),objectOf:function(e){return s(function(t,n,r,o,i){if("function"!=typeof e)return new c("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=t[n],s=l(a);if("object"!==s)return new c("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected an object.");for(var u in a)if(I(a,u)){var f=e(a,u,r,o,i+"."+u,x);if(f instanceof Error)return f}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&(arguments.length>1?P("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):P("Invalid argument supplied to oneOf, expected an array.")),A;return s(function(t,n,r,o,i){for(var s=t[n],u=0;u<e.length;u++)if(a(s,e[u]))return null;var f=JSON.stringify(e,function(e,t){var n=d(t);return"symbol"===n?String(t):t});return new c("Invalid "+o+" `"+i+"` of value `"+String(s)+"` supplied to `"+r+"`, expected one of "+f+".")})},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&P("Invalid argument supplied to oneOfType, expected an instance of array."),A;for(var t=0;t<e.length;t++){var n=e[t];if("function"!=typeof n)return P("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+p(n)+" at index "+t+"."),A}return s(function(t,n,r,o,i){for(var a=0;a<e.length;a++){var s=e[a];if(null==s(t,n,r,o,i,x))return null}return new c("Invalid "+o+" `"+i+"` supplied to `"+r+"`.")})},shape:function(e){return s(function(t,n,r,o,i){var a=t[n],s=l(a);if("object"!==s)return new c("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected `object`.");for(var u in e){var f=e[u];if(f){var d=f(a,u,r,o,i+"."+u,x);if(d)return d}}return null})},exact:function(e){return s(function(t,n,r,o,i){var a=t[n],s=l(a);if("object"!==s)return new c("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected `object`.");var u=S({},t[n],e);for(var f in u){var d=e[f];if(!d)return new c("Invalid "+o+" `"+i+"` key `"+f+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(t[n],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var p=d(a,f,r,o,i+"."+f,x);if(p)return p}return null})}};function a(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function c(e){this.message=e,this.stack=""}function s(e){if("production"!==process.env.NODE_ENV)var n={},r=0;function i(i,a,s,u,f,l,d){if(u=u||o,l=l||s,d!==x){if(t){var p=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 p.name="Invariant Violation",p}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var h=u+":"+s;!n[h]&&r<3&&(P("You are manually calling a React.PropTypes validation function for the `"+l+"` prop on `"+u+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),n[h]=!0,r++)}}return null==a[s]?i?null===a[s]?new c("The "+f+" `"+l+"` is marked as required in `"+u+"`, but its value is `null`."):new c("The "+f+" `"+l+"` is marked as required in `"+u+"`, but its value is `undefined`."):null:e(a,s,u,f,l)}var a=i.bind(null,!1);return a.isRequired=i.bind(null,!0),a}function u(e){return s(function(t,n,r,o,i,a){var s=t[n];return l(s)!==e?new c("Invalid "+o+" `"+i+"` of type `"+d(s)+"` supplied to `"+r+"`, expected `"+e+"`."):null})}function f(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(f);if(null===t||e(t))return!0;var o=function(e){var t=e&&(n&&e[n]||e[r]);if("function"==typeof t)return t}(t);if(!o)return!1;var i,a=o.call(t);if(o!==t.entries){for(;!(i=a.next()).done;)if(!f(i.value))return!1}else for(;!(i=a.next()).done;){var c=i.value;if(c&&!f(c[1]))return!1}return!0;default:return!1}}function l(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function d(e){if(null==e)return""+e;var t=l(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function p(e){var t=d(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return c.prototype=Error.prototype,i.checkPropTypes=z,i.resetWarningCache=z.resetWarningCache,i.PropTypes=i,i};function F(){}function N(){}N.resetWarningCache=F;var H=v(function(e){if("production"!==process.env.NODE_ENV){var t=g;e.exports=D(t.isElement,!0)}else e.exports=function(){function e(e,t,n,r,o,i){if(i!==x){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 n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:N,resetWarningCache:F};return n.PropTypes=n,n}()});function k(){return(k=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}).apply(this,arguments)}var $=function(){if("undefined"!=typeof Map)return Map;function e(e,t){var n=-1;return e.some(function(e,r){return e[0]===t&&(n=r,!0)}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),r=this.__entries__[n];return r&&r[1]},t.prototype.set=function(t,n){var r=e(this.__entries__,t);~r?this.__entries__[r][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,r=e(n,t);~r&&n.splice(r,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n=0,r=this.__entries__;n<r.length;n++){var o=r[n];e.call(t,o[1],o[0])}},t}()}(),L="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,W="undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),V="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(W):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)},B=2;var q=20,G=["top","right","bottom","left","width","height","size","weight"],K="undefined"!=typeof MutationObserver,U=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(e,t){var n=!1,r=!1,o=0;function i(){n&&(n=!1,e()),r&&c()}function a(){V(i)}function c(){var e=Date.now();if(n){if(e-o<B)return;r=!0}else n=!0,r=!1,setTimeout(a,t);o=e}return c}(this.refresh.bind(this),q)}return e.prototype.addObserver=function(e){~this.observers_.indexOf(e)||this.observers_.push(e),this.connected_||this.connect_()},e.prototype.removeObserver=function(e){var t=this.observers_,n=t.indexOf(e);~n&&t.splice(n,1),!t.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},e.prototype.updateObservers_=function(){var e=this.observers_.filter(function(e){return e.gatherActive(),e.hasActive()});return e.forEach(function(e){return e.broadcastActive()}),e.length>0},e.prototype.connect_=function(){L&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),K?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){L&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t;G.some(function(e){return!!~n.indexOf(e)})&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),Y=function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var o=r[n];Object.defineProperty(e,o,{value:t[o],enumerable:!1,writable:!1,configurable:!0})}return e},J=function(e){return e&&e.ownerDocument&&e.ownerDocument.defaultView||W},Q=re(0,0,0,0);function X(e){return parseFloat(e)||0}function Z(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(t,n){return t+X(e["border-"+n+"-width"])},0)}function ee(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return Q;var r=J(e).getComputedStyle(e),o=function(e){for(var t={},n=0,r=["top","right","bottom","left"];n<r.length;n++){var o=r[n],i=e["padding-"+o];t[o]=X(i)}return t}(r),i=o.left+o.right,a=o.top+o.bottom,c=X(r.width),s=X(r.height);if("border-box"===r.boxSizing&&(Math.round(c+i)!==t&&(c-=Z(r,"left","right")+i),Math.round(s+a)!==n&&(s-=Z(r,"top","bottom")+a)),!function(e){return e===J(e).document.documentElement}(e)){var u=Math.round(c+i)-t,f=Math.round(s+a)-n;1!==Math.abs(u)&&(c-=u),1!==Math.abs(f)&&(s-=f)}return re(o.left,o.top,c,s)}var te="undefined"!=typeof SVGGraphicsElement?function(e){return e instanceof J(e).SVGGraphicsElement}:function(e){return e instanceof J(e).SVGElement&&"function"==typeof e.getBBox};function ne(e){return L?te(e)?function(e){var t=e.getBBox();return re(0,0,t.width,t.height)}(e):ee(e):Q}function re(e,t,n,r){return{x:e,y:t,width:n,height:r}}var oe=function(){function e(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=re(0,0,0,0),this.target=e}return e.prototype.isActive=function(){var e=ne(this.target);return this.contentRect_=e,e.width!==this.broadcastWidth||e.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var e=this.contentRect_;return this.broadcastWidth=e.width,this.broadcastHeight=e.height,e},e}(),ie=function(e,t){var n,r,o,i,a,c,s,u=(r=(n=t).x,o=n.y,i=n.width,a=n.height,c="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,s=Object.create(c.prototype),Y(s,{x:r,y:o,width:i,height:a,top:o,right:r+i,bottom:a+o,left:r}),s);Y(this,{target:e,contentRect:u})},ae=function(){function e(e,t,n){if(this.activeObservations_=[],this.observations_=new $,"function"!=typeof e)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=t,this.callbackCtx_=n}return e.prototype.observe=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof J(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)||(t.set(e,new oe(e)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof J(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)&&(t.delete(e),t.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var e=this;this.clearActive(),this.observations_.forEach(function(t){t.isActive()&&e.activeObservations_.push(t)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var e=this.callbackCtx_,t=this.activeObservations_.map(function(e){return new ie(e.target,e.broadcastRect())});this.callback_.call(e,t,e),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),ce="undefined"!=typeof WeakMap?new WeakMap:new $,se=function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=U.getInstance(),r=new ae(t,n,this);ce.set(this,r)};["observe","unobserve","disconnect"].forEach(function(e){se.prototype[e]=function(){var t;return(t=ce.get(this))[e].apply(t,arguments)}});var ue=void 0!==W.ResizeObserver?W.ResizeObserver:se,fe=["client","offset","scroll","bounds","margin"];function le(e){var t=[];return fe.forEach(function(n){e[n]&&t.push(n)}),t}function de(e,t){var n={};if(t.indexOf("client")>-1&&(n.client={top:e.clientTop,left:e.clientLeft,width:e.clientWidth,height:e.clientHeight}),t.indexOf("offset")>-1&&(n.offset={top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight}),t.indexOf("scroll")>-1&&(n.scroll={top:e.scrollTop,left:e.scrollLeft,width:e.scrollWidth,height:e.scrollHeight}),t.indexOf("bounds")>-1){var r=e.getBoundingClientRect();n.bounds={top:r.top,right:r.right,bottom:r.bottom,left:r.left,width:r.width,height:r.height}}if(t.indexOf("margin")>-1){var o=getComputedStyle(e);n.margin={top:o?parseInt(o.marginTop):0,right:o?parseInt(o.marginRight):0,bottom:o?parseInt(o.marginBottom):0,left:o?parseInt(o.marginLeft):0}}return n}var pe=function(t){return function(n){var r,o;return o=r=function(r){var o,i;function a(){for(var e,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return(e=r.call.apply(r,[this].concat(o))||this).state={contentRect:{entry:{},client:{},offset:{},scroll:{},bounds:{},margin:{}}},e._animationFrameID=null,e._resizeObserver=null,e._node=null,e.measure=function(n){var r=de(e._node,t||le(e.props));n&&(r.entry=n[0].contentRect),e._animationFrameID=window.requestAnimationFrame(function(){null!==e._resizeObserver&&(e.setState({contentRect:r}),"function"==typeof e.props.onResize&&e.props.onResize(r))})},e._handleRef=function(t){null!==e._resizeObserver&&null!==e._node&&e._resizeObserver.unobserve(e._node),e._node=t,null!==e._resizeObserver&&null!==e._node&&e._resizeObserver.observe(e._node);var n=e.props.innerRef;n&&("function"==typeof n?n(e._node):n.current=e._node)},e}i=r,(o=a).prototype=Object.create(i.prototype),o.prototype.constructor=o,o.__proto__=i;var c=a.prototype;return c.componentDidMount=function(){this._resizeObserver=new ue(this.measure),null!==this._node&&(this._resizeObserver.observe(this._node),"function"==typeof this.props.onResize&&this.props.onResize(de(this._node,t||le(this.props))))},c.componentWillUnmount=function(){null!==this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),window.cancelAnimationFrame(this._animationFrameID)},c.render=function(){var t=this.props,r=(t.innerRef,t.onResize,function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(t,["innerRef","onResize"]));return e.createElement(n,k({},r,{measureRef:this._handleRef,measure:this.measure,contentRect:this.state.contentRect}))},a}(e.Component),r.propTypes={client:H.bool,offset:H.bool,scroll:H.bool,bounds:H.bool,margin:H.bool,innerRef:H.oneOfType([H.object,H.func]),onResize:H.func},o}}()(function(e){var t=e.measure,n=e.measureRef,r=e.contentRect;return(0,e.children)({measure:t,measureRef:n,contentRect:r})});pe.displayName="Measure",pe.propTypes.children=H.func;var he=t.forwardRef(function(e,n){var r=e.as,o=void 0===r?"div":r,i=e.style,a=e.children;return t.createElement(o,{ref:n,style:i},a)});he.displayName="Wrapper";var me=t.memo(function(e){var n=e.item,r=e.index,o=e.RenderItem;return t.createElement(o,{item:n,index:r})});me.displayName="RenderItemWrapper";var ve=t.memo(function(e){var n=e.batch,r=e.index,o=e.getItemKey,i=e.batchSize,a=e.wrapperElement,c=e.removeFromDOM,s=e.dimensions,u=e.setDimension,f=e.RenderItem,l=e.visible,d=!!e.itemHeight,p=null;if(l||!c){var h=n.map(function(e,n){var a=i*r+n,c=o(e,a);return t.createElement(me,{key:c,item:e,index:a,RenderItem:f})}),m=t.createElement(he,{"data-iscroller-batch":r,as:a,style:c?{}:{visibility:l?"visible":"hidden"}},h);p=d?m:t.createElement(pe,{scroll:!0,onResize:function(e){u(r,e)}},function(e){var n=e.measureRef;return t.cloneElement(m,{ref:n})})}else p=t.createElement("div",{style:{height:s.height}});return p});ve.displayName="BatchRenderer";var ye=t.memo(function(e){return t.createElement(ve,e)},function(e,t){var n=e.batch,r=e.visible,o=t.batch,i=t.visible;return!!t.removeFromDOM||n.length===o.length&&n.every(function(e,t){return e===o[t]})&&r===i&&!1===r&&!1===i});ye.displayName="NoRemoveFromDOMBatcher";var be="Expected a function",ge=NaN,we="[object Symbol]",_e=/^\s+|\s+$/g,Oe=/^[-+]0x[0-9a-f]+$/i,Ee=/^0b[01]+$/i,Se=/^0o[0-7]+$/i,xe=parseInt,Re="object"==typeof h&&h&&h.Object===Object&&h,Me="object"==typeof self&&self&&self.Object===Object&&self,je=Re||Me||Function("return this")(),Te=Object.prototype.toString,Ce=Math.max,ze=Math.min,Ie=function(){return je.Date.now()};function Pe(e,t,n){var r,o,i,a,c,s,u=0,f=!1,l=!1,d=!0;if("function"!=typeof e)throw new TypeError(be);function p(t){var n=r,i=o;return r=o=void 0,u=t,a=e.apply(i,n)}function h(e){var n=e-s;return void 0===s||n>=t||n<0||l&&e-u>=i}function m(){var e=Ie();if(h(e))return v(e);c=setTimeout(m,function(e){var n=t-(e-s);return l?ze(n,i-(e-u)):n}(e))}function v(e){return c=void 0,d&&r?p(e):(r=o=void 0,a)}function y(){var e=Ie(),n=h(e);if(r=arguments,o=this,s=e,n){if(void 0===c)return function(e){return u=e,c=setTimeout(m,t),f?p(e):a}(s);if(l)return c=setTimeout(m,t),p(s)}return void 0===c&&(c=setTimeout(m,t)),a}return t=De(t)||0,Ae(n)&&(f=!!n.leading,i=(l="maxWait"in n)?Ce(De(n.maxWait)||0,t):i,d="trailing"in n?!!n.trailing:d),y.cancel=function(){void 0!==c&&clearTimeout(c),u=0,r=s=o=c=void 0},y.flush=function(){return void 0===c?a:v(Ie())},y}function Ae(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function De(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&Te.call(e)==we}(e))return ge;if(Ae(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ae(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(_e,"");var n=Ee.test(e);return n||Se.test(e)?xe(e.slice(2),n?2:8):Oe.test(e)?ge:+e}var Fe=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new TypeError(be);return Ae(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),Pe(e,t,{leading:r,maxWait:t,trailing:o})};var Ne=function(t){var n=t.root,i=t.axis,a=t.containerHeight,c=t.itemsCount,s=t.itemHeight,u=t.averageItemHeight,f=t.batchSize,l=t.batchBufferDistance,d=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=e.useState(t),i=r(n,2),a=i[0],c=i[1],s=e.useRef(null),u=function(e,t){var n=o(s&&s.current||a),r=t.scroll,i=r.width,u=r.height;n[e]={width:i,height:u},s.current=n,c(n)};return[a,u]}(function(e){var t=e.axis,n=e.itemHeight,r=e.averageItemHeight,o=e.batchSize,i=e.itemsCount;return function(){for(var e=Math.ceil(i/o),a="y"===t?Math.ceil((n||r)*o):0,c=[],s=0;s<e;s+=1)c[s]={height:a,width:null};return c}}({itemsCount:c,axis:i,itemHeight:s,averageItemHeight:u,batchSize:f})),p=r(d,2),h=p[0],m=p[1],v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=r(e.useState(t),2),o=n[0],i=n[1];return[o,function(e){i(e)}]}(function(e){var t=e.axis,n=e.containerHeight,r=e.itemHeight,o=e.averageItemHeight,i=e.batchSize,a=e.itemsCount;return function(){for(var e=Math.ceil(a/i),c="y"===t?Math.ceil(n/((r||o)*i)):0,s=[],u=0;u<e;u+=1)s[u]=u<c;return s}}({itemsCount:c,axis:i,containerHeight:a,itemHeight:s,averageItemHeight:u,batchSize:f})),y=r(v,2),b=y[0],g=y[1],w=function(t){var n=t.root,o=t.axis,i=e.useRef(null),a=r(e.useState(0),2),c=a[0],s=a[1];return e.useEffect(function(){var e=n?n():window,t=Fe(function(){i.current&&window.cancelAnimationFrame(i.current),i.current=window.requestAnimationFrame(function(){return s(function(e,t){var n=e.scrollTop,r=e.scrollY;return"y"===t?void 0!==n?n:r:0}(e,o))})},100);return e.addEventListener("scroll",t,{capture:!1,passive:!0}),function(){t.cancel&&t.cancel(),window.cancelAnimationFrame(i.current),e.removeEventListener("scroll",t)}},[o,n]),c}({root:n,axis:i});return e.useEffect(function(){for(var e,t,n=[w-l,w+a+l],r=Math.ceil(c/f),o=0,i=[],s=0;s<r;s+=1){var u=o,d=o+h[s].height;i[s]=(t=[u,d])[0]<(e=n)[0]?t[1]>e[0]:t[0]<e[1],o=d}i.some(function(e,t){return e!==b[t]})&&g(i)},[f,a,g,h,c,w,b,l]),[h,b,m]},He=function(n){var o=n.fetchMoreBufferDistance,i=n.onFetchMore,a=n.RenderLoader,c=n.wrapperElement,s=n.items,u=n.itemsCount,f=n.batchSize,l=n.root,d=n.axis,p=e.useRef(null);return e.useEffect(function(){var e=p.current,t={root:l?l():null,rootMargin:"y"===d?"0px 0px ".concat(o,"px 0px"):"0px",threshold:0},n=new IntersectionObserver(function(e){r(e,1)[0].isIntersecting&&i({size:s.length,itemsCount:u,batchSize:f})},t);return e&&n.observe(e),function(){n.disconnect()}},[d,o,f,s,i,l,u]),t.createElement(c,{ref:p},t.createElement(a,{size:s.length,itemsCount:u,batchSize:f}))},ke=function(e){var n=e.children,r=e.forwardRef;return t.createElement("div",{ref:r},n)};ke.displayName="DefaultRenderContainer";var $e=function(e){var t=e.item;e.index;return t};$e.displayName="DefaultRenderItem";var Le=function(e){e.items,e.itemsCount,e.batchSize;return null};Le.displayName="DefaultRenderLoader";var We=function(e){var n,o,i=e.containerHeight,a=e.items,c=e.RenderItem,s=e.getItemKey,u=e.wrapperElement,f=e.forwardRef,l=e.RenderContainer,d=e.removeFromDOM,p=e.root,h=e.batch,m=e.batchSize,v=e.axis,y=e.averageItemHeight,b=e.itemHeight,g=e.itemsCount,w=e.batchBufferDistance,_=e.onFetchMore,O=e.RenderLoader,E=e.fetchMoreBufferDistance,S=r(Ne({root:p,axis:v,containerHeight:i,itemsCount:g,itemHeight:b,averageItemHeight:y,batchSize:m,batchBufferDistance:w}),3),x=S[0],R=S[1],M=S[2],j=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=[],r=0;r<e.length;r+=t){var o=e.slice(r,r+t);n.push(o)}return n}(a,m),T=d?ve:ye,C=j,z=[],I=[];if(d&&h){var P=r(function(e){for(var t,n,r=0;r<e.length;r+=1){var o=e[r];if(void 0!==t&&void 0!==n&&!o)break;void 0===t&&o&&(t=r),void 0!==t&&o&&(n=r)}return[t,n]}(R),2),A=P[0],D=P[1];z=j.slice(0,A),C=j.slice(A,D+1),I=j.slice(D+1,j.length),n=z.reduce(function(e,t,n){return e+x[n].height},0),o=I.reduce(function(e,t,n){var r=z.length+C.length+n;return e+x[r].height},0)}var F=C.map(function(e,n){var r=z.length+n;return t.createElement(T,{key:"".concat(r),batch:e,index:r,getItemKey:s,batchSize:m,wrapperElement:u,removeFromDOM:d,setDimension:M,RenderItem:c,dimensions:x[r],visible:R[r],itemHeight:b})});return t.createElement(l,{forwardRef:f},n?t.createElement("div",{style:{height:n,visibility:"hidden"}}):null,F,o?t.createElement("div",{style:{height:o,visibility:"hidden"}}):null,"y"===v&&a.length<g?t.createElement(He,{onFetchMore:_,fetchMoreBufferDistance:E,RenderLoader:O,wrapperElement:u,items:a,itemsCount:g,batchSize:m,root:p,axis:v}):null)};We.displayName="BaseRenderer";var Ve=function(e){var r=s(),o=r.innerWidth,i=r.innerHeight;return t.createElement(We,n({},e,{containerWidth:o,containerHeight:i}))},Be=function(e){var r=e.root,o=p({current:r()}),i=o.width,a=o.height;return t.createElement(We,n({},e,{containerWidth:i,containerHeight:a}))},qe=e.memo(t.forwardRef(function(o,i){var a=r(e.useState(!o.root),2),c=a[0],s=a[1];return e.useEffect(function(){c||s(!0)},[]),c?o.root?t.createElement(Be,n({},o,{forwardRef:i})):t.createElement(Ve,n({},o,{forwardRef:i})):null}));return qe.defaultProps={items:[],itemsCount:0,RenderItem:$e,getItemKey:function(e,t){return"string"==typeof e?e:t},wrapperElement:"div",RenderContainer:ke,removeFromDOM:!0,root:null,averageItemHeight:10,itemHeight:null,axis:"y",batch:!0,batchSize:10,batchBufferDistance:500,fetchMoreBufferDistance:500,RenderLoader:Le,onFetchMore:function(e){e.items,e.itemsCount,e.batchSize}},qe.propTypes={items:H.arrayOf(H.any),itemsCount:H.number,RenderItem:H.elementType,getItemKey:H.func,wrapperElement:H.string,RenderContainer:H.elementType,removeFromDOM:H.bool,root:H.func,averageItemHeight:H.number,itemHeight:H.number,axis:H.oneOf(["y"]),batch:H.bool,batchSize:H.number,batchBufferDistance:H.number,fetchMoreBufferDistance:H.number,RenderLoader:H.elementType,onFetchMore:H.func},qe.displayName="DelightfulScroller",qe}); //# sourceMappingURL=react-delightful-scroller.umd.js.map