Comparing version 3.3.9 to 3.3.10
@@ -5,2 +5,8 @@ # Changelog | ||
### [3.3.10](https://github.com/jaredLunde/masonic/compare/v3.3.9...v3.3.10) (2020-09-11) | ||
### Bug Fixes | ||
- **use-masonry:** fix onRender type ([1f0af01](https://github.com/jaredLunde/masonic/commit/1f0af0141c055ab9dc86d37e1c8f25e993d17f99)), closes [#43](https://github.com/jaredLunde/masonic/issues/43) | ||
### [3.3.9](https://github.com/jaredLunde/masonic/compare/v3.3.8...v3.3.9) (2020-09-11) | ||
@@ -7,0 +13,0 @@ |
@@ -61,3 +61,3 @@ "use strict"; | ||
let startIndex = 0; | ||
let stopIndex = void 0; | ||
let stopIndex; | ||
const forceUpdate = (0, _useForceUpdate.useForceUpdate)(); | ||
@@ -64,0 +64,0 @@ const setItemRef = getRefSetter(positioner, resizeObserver); |
@@ -43,3 +43,3 @@ import * as React from 'react'; | ||
let startIndex = 0; | ||
let stopIndex = void 0; | ||
let stopIndex; | ||
const forceUpdate = useForceUpdate(); | ||
@@ -46,0 +46,0 @@ const setItemRef = getRefSetter(positioner, resizeObserver); |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t=t||self).Masonic={},t.React)}(this,(function(t,e){"use strict";function n(){return(n=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function r(t,e,n,r){function o(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];u.current.apply(this,e)}void 0===r&&(r=i);var u=ct(n),s=ct(r);ft((function(){var n=t&&"current"in t?t.current:t;if(n){var r=o;n.addEventListener(e,r);var i=s.current;return function(){n.removeEventListener(e,r),i()}}}),[t,e])}function i(){}function o(t,n,r){function i(){s.current=0,a()}void 0===n&&(n=30),void 0===r&&(r=0);var o=ct(t),u=1e3/n,s=e.useRef(0),c=e.useRef(),a=function(){return c.current&&clearTimeout(c.current)},f=[n,r,o];return e.useEffect((function(){return i}),f),e.useCallback((function(){var t=arguments,e=pt(),n=function(){s.current=e,a(),o.current.apply(null,t)},i=s.current;if(r&&0===i)return n();if(e-i>u){if(i>0)return n();s.current=e}a(),c.current=setTimeout((function(){n(),s.current=0}),u)}),f)}function u(){}function s(t,n){function r(){a(0)}void 0===t&&(t=0),void 0===n&&(n=12);var i=function(t){void 0===t&&(t=30);var n=function(t,n){var r=e.useState(t);return[r[0],o(r[1],n,1)]}("undefined"==typeof window?0:gt,t);return function(t,e,r,i){function o(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];s.current.apply(this,e)}void 0===i&&(i=u);var s=ct((function(){return n[1](gt())})),c=ct(i);ft((function(){var e=t&&"current"in t?t.current:t;if(e){var n=o;e.addEventListener("scroll",n);var r=c.current;return function(){e.removeEventListener("scroll",n),r()}}}),[t,"scroll"])}(mt),n[0]}(n),s=e.useState(0),c=s[0],a=s[1],f=e.useRef(0);return e.useEffect((function(){1===f.current&&a(1);var t,e,i,o,u=(t=r,e=40+1e3/n,i=_t(),(o={}).v=Ct((function n(){_t()-i<e?o.v=Ct(n):t.call(null)})),o);return f.current=1,function(){return function(t){Et(t.v||-1)}(u)}}),[n,i]),{scrollTop:Math.max(0,i-t),isScrolling:c}}function c(){var t=e.useState(Wt)[1];return e.useRef((function(){return t({})})).current}function a(t){var r=t.positioner,i=t.resizeObserver,o=t.items,u=t.as,s=void 0===u?"div":u,a=t.id,d=t.className,h=t.style,l=t.role,v=void 0===l?"grid":l,p=t.tabIndex,m=void 0===p?0:p,g=t.containerRef,y=t.itemAs,b=void 0===y?"div":y,w=t.itemStyle,_=t.itemHeightEstimate,P=void 0===_?300:_,x=t.itemKey,R=void 0===x?f:x,C=t.overscanBy,E=void 0===C?2:C,M=t.scrollTop,L=t.isScrolling,O=t.height,T=t.render,z=t.onRender,A=0,S=void 0,W=c(),k=Ft(r,i),I=o.length,H=r.columnWidth,j=r.columnCount,D=r.range,q=r.estimateHeight,B=r.size,F=r.shortestColumn,G=B(),N=F(),V=[],Y=v+"item",K=ct(z),J=M+(E*=O),Q=J>N&&I>G;if(D(Math.max(0,M-E/2),J,(function(t,e,r){var i=o[t],u=R(i,t),s={top:r,left:e,width:H,writingMode:"horizontal-tb",position:"absolute"};V.push(kt(b,{key:u,ref:k(t),role:Y,style:"object"==typeof w&&null!==w?n({},s,w):s},Ht(T,t,i,H))),void 0===S?(A=t,S=t):(A=Math.min(A,t),S=Math.max(S,t))})),Q)for(var U=Math.min(I-G,Math.ceil((M+E-N)/P*j)),X=G,Z=Bt(H);G+U>X;X++){var $=o[X],tt=R($,X);V.push(kt(b,{key:tt,ref:k(X),role:Y,style:"object"==typeof w?n({},Z,w):Z},Ht(T,X,$,H)))}e.useEffect((function(){"function"==typeof K.current&&void 0!==S&&K.current(A,S,o),It="1"}),[A,S,o,K]),e.useEffect((function(){Q&&W()}),[Q]);var et=jt(L,q(I,P));return kt(s,{ref:g,key:It,id:a,role:v,className:d,tabIndex:m,style:"object"==typeof h?qt(et,h):et,children:V})}function f(t,e){return e}function d(t){var e=s(t.offset,t.scrollFps);return a({scrollTop:e.scrollTop,isScrolling:e.isScrolling,positioner:t.positioner,resizeObserver:t.resizeObserver,items:t.items,onRender:t.onRender,as:t.as,id:t.id,className:t.className,style:t.style,role:t.role,tabIndex:t.tabIndex,containerRef:t.containerRef,itemAs:t.itemAs,itemStyle:t.itemStyle,itemHeightEstimate:t.itemHeightEstimate,itemKey:t.itemKey,overscanBy:t.overscanBy,height:t.height,render:t.render})}function h(t,n){void 0===n&&(n=Gt);var r=e.useState({offset:0,width:0}),i=r[0],o=r[1];return ft((function(){var e=t.current;if(null!==e){var n=0,r=e;do{n+=r.offsetTop||0,r=r.offsetParent}while(r);n===i.offset&&e.offsetWidth===i.width||o({offset:n,width:e.offsetWidth})}}),n),i}function l(t,e){var n=-1;return t.some((function(t,r){return t[0]===e?(n=r,1):0})),n}function v(){this.__entries__=[]}function p(){return this.__entries__.length}function m(t){var e=l(this.__entries__,t),n=this.__entries__[e];return n&&n[1]}function g(t,e){var n=l(this.__entries__,t);~n?this.__entries__[n][1]=e:this.__entries__.push([t,e])}function y(t){var e=this.__entries__,n=l(e,t);~n&&e.splice(n,1)}function b(t){return!!~l(this.__entries__,t)}function w(){this.__entries__.splice(0)}function _(t,e){void 0===e&&(e=null);for(var n=0,r=this.__entries__;n<r.length;n++){var i=r[n];t.call(e,i[1],i[0])}}function P(t){return setTimeout((function(){return t(Date.now())}),1e3/60)}function x(){this.connected_=0,this.mutationEventsAdded_=0,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(t){function e(){i&&(i=0,t()),o&&r()}function n(){Kt(e)}function r(){var t=Date.now();if(i){if(2>t-u)return;o=1}else i=1,o=0,setTimeout(n,20);u=t}var i=0,o=0,u=0;return r}(this.refresh.bind(this))}function R(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()}function C(t){var e=this.observers_,n=e.indexOf(t);~n&&e.splice(n,1),!e.length&&this.connected_&&this.disconnect_()}function E(){this.updateObservers_()&&this.refresh()}function M(t){return t.gatherActive(),t.hasActive()}function L(t){return t.broadcastActive()}function O(){var t=this.observers_.filter(M);return t.forEach(L),t.length>0}function T(){Vt&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),Qt?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:1,childList:1,characterData:1,subtree:1})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=1),this.connected_=1)}function z(){Vt&&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_=0,this.connected_=0)}function A(t){var e=t.propertyName,n=void 0===e?"":e;Jt.some((function(t){return!!~n.indexOf(t)}))&&this.refresh()}function S(){return this.instance_||(this.instance_=new x),this.instance_}function W(t){return parseFloat(t)||0}function k(t){for(var e=[],n=1;arguments.length>n;n++)e[n-1]=arguments[n];return e.reduce((function(e,n){return e+W(t["border-"+n+"-width"])}),0)}function I(t){return t instanceof Zt(t).SVGGraphicsElement}function H(t){return t instanceof Zt(t).SVGElement&&"function"==typeof t.getBBox}function j(t){return Vt?te(t)?function(t){var e=t.getBBox();return D(0,0,e.width,e.height)}(t):function(t){var e=t.clientWidth,n=t.clientHeight;if(!e&&!n)return $t;var r=Zt(t).getComputedStyle(t),i=function(t){for(var e={},n=0,r=["top","right","bottom","left"];r.length>n;n++){var i=r[n],o=t["padding-"+i];e[i]=W(o)}return e}(r),o=i.left+i.right,u=i.top+i.bottom,s=W(r.width),c=W(r.height);if("border-box"===r.boxSizing&&(Math.round(s+o)!==e&&(s-=k(r,"left","right")+o),Math.round(c+u)!==n&&(c-=k(r,"top","bottom")+u)),!function(t){return t===Zt(t).document.documentElement}(t)){var a=Math.round(s+o)-e,f=Math.round(c+u)-n;1!==Math.abs(a)&&(s-=a),1!==Math.abs(f)&&(c-=f)}return D(i.left,i.top,s,c)}(t):$t}function D(t,e,n,r){return{x:t,y:e,width:n,height:r}}function q(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=D(0,0,0,0),this.target=t}function B(){var t=j(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight}function F(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t}function G(t,e){var n,r,i,o,u,s,c,a=(r=(n=e).x,i=n.y,o=n.width,u=n.height,s="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,c=Object.create(s.prototype),Xt(c,{x:r,y:i,width:o,height:u,top:i,right:r+o,bottom:u+i,left:r}),c);Xt(this,{target:t,contentRect:a})}function N(t,e,n){if(this.activeObservations_=[],this.observations_=new Nt,"function"!=typeof t)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=e,this.callbackCtx_=n}function V(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof Zt(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)||(e.set(t,new ee(t)),this.controller_.addObserver(this),this.controller_.refresh())}}function Y(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof Zt(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)&&(e.delete(t),e.size||this.controller_.removeObserver(this))}}function K(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)}function J(){var t=this;this.clearActive(),this.observations_.forEach((function(e){e.isActive()&&t.activeObservations_.push(e)}))}function Q(t){return new ne(t.target,t.broadcastRect())}function U(){if(this.hasActive()){var t=this.callbackCtx_,e=this.activeObservations_.map(Q);this.callback_.call(t,e,t),this.clearActive()}}function X(){this.activeObservations_.splice(0)}function Z(){return this.activeObservations_.length>0}function $(t){function n(){return i.disconnect()}var r=c(),i=se(t,r);return e.useEffect((function(){return n}),[i]),i}function tt(t){var e=t.high;t.L===ce&&t.R===ce?t.max=e:t.L===ce?t.max=Math.max(t.R.max,e):t.R===ce?t.max=Math.max(t.L.max,e):t.max=Math.max(Math.max(t.L.max,t.R.max),e)}function et(t){for(var e=t;e.P!==ce;)tt(e.P),e=e.P}function nt(t,e){if(e.R!==ce){var n=e.R;e.R=n.L,n.L!==ce&&(n.L.P=e),n.P=e.P,e.P===ce?t.root=n:e===e.P.L?e.P.L=n:e.P.R=n,n.L=e,e.P=n,tt(e),tt(n)}}function rt(t,e){if(e.L!==ce){var n=e.L;e.L=n.R,n.R!==ce&&(n.R.P=e),n.P=e.P,e.P===ce?t.root=n:e===e.P.R?e.P.R=n:e.P.L=n,n.R=e,e.P=n,tt(e),tt(n)}}function it(t,e,n){e.P===ce?t.root=n:e===e.P.L?e.P.L=n:e.P.R=n,n.P=e.P}function ot(t,n){var r=t.width,i=t.columnWidth,o=void 0===i?200:i,u=t.columnGutter,s=void 0===u?0:u,c=t.columnCount;void 0===n&&(n=he);var a=function(){var t=de(r,o,s,c),e=t[0],n=t[1];return ae(n,e,s)},f=e.useRef();void 0===f.current&&(f.current=a());var d=e.useRef(n),h=[r,o,s,c],l=e.useRef(h),v=!h.every((function(t,e){return l.current[e]===t}));if(v||!n.every((function(t,e){return d.current[e]===t}))){var p=f.current,m=a();if(d.current=n,l.current=h,v)for(var g=p.size(),y=0;g>y;y++){var b=p.get(y);m.set(y,void 0!==b?b.height:0)}f.current=m}return f.current}function ut(t,n){var r,i,u,s,c=n.align,a=void 0===c?"top":c,f=n.element,d=void 0===f?"undefined"!=typeof window&&window:f,h=n.offset,l=void 0===h?0:h,v=n.height,p=void 0===v?"undefined"!=typeof window?window.innerHeight:0:v,m=ct({positioner:t,element:d,align:a,offset:l,height:p}),g=e.useRef((function(){var t=m.current.element;return t&&"current"in t?t.current:t})).current,y=e.useReducer((function(t,e){var n,r={position:t.position,index:t.index,prevTop:t.prevTop};if("scrollToIndex"===e.type)return{position:m.current.positioner.get(null!==(n=e.value)&&void 0!==n?n:-1),index:e.value,prevTop:void 0};if("setPosition"===e.type)r.position=e.value;else if("setPrevTop"===e.type)r.prevTop=e.value;else if("reset"===e.type)return le;return r}),le),b=y[0],w=y[1],_=o(w,15);i=g(),u=ct((function(){if(!b.position&&b.index){var t=m.current.positioner.get(b.index);t&&w({type:"setPosition",value:t})}})),s=ct(void 0),ft((function(){function t(){if(!n){for(var t=arguments.length,e=new Array(t),r=0;t>r;r++)e[r]=arguments[r];u.current.apply(this,e)}}var e=i&&"current"in i?i.current:i;if(e){var n=0;e.addEventListener("scroll",t);var r=s.current;return function(){n=1,e.removeEventListener("scroll",t),r&&r()}}}),[i,"scroll"]);var P=void 0!==b.index&&(null===(r=m.current.positioner.get(b.index))||void 0===r?void 0:r.top);return e.useEffect((function(){var t=g();if(t){var e=m.current,n=e.height,r=e.align,i=e.offset,o=e.positioner;if(b.position){var u=b.position.top;"bottom"===r?u=u-n+b.position.height:"center"===r&&(u-=(n-b.position.height)/2),t.scrollTo(0,Math.max(0,u+=i));var s=0,c=setTimeout((function(){return!s&&w({type:"reset"})}),400);return function(){s=1,clearTimeout(c)}}if(void 0!==b.index){var a=o.shortestColumn()/o.size()*b.index;b.prevTop&&(a=Math.max(a,b.prevTop+n)),t.scrollTo(0,a),_({type:"setPrevTop",value:a})}}}),[P,b,m,g,_]),e.useRef((function(t){w({type:"scrollToIndex",value:t})})).current}function st(t){var i=e.useRef(null),o=function(t){void 0===t&&(t=dt);var n=t,i=n.wait,o=n.leading,u=n.initialWidth,s=void 0===u?0:u,c=n.initialHeight,a=function(t,n,r){var i=e.useState(t);return[i[0],at(i[1],n,r)]}("undefined"==typeof document?[s,void 0===c?0:c]:lt,i,o),f=a[0],d=a[1],h=function(){return d(lt)};return r(ht,"resize",h),r(ht,"orientationchange",h),f}({initialWidth:t.ssrWidth,initialHeight:t.ssrHeight}),u=h(i,o),s=n({offset:u.offset,width:u.width||o[0],height:o[1],containerRef:i},t);s.positioner=ot(s),s.resizeObserver=$(s.positioner);var c=ut(s.positioner,{height:s.height,offset:u.offset,align:"object"==typeof t.scrollToIndex?t.scrollToIndex.align:void 0}),a=t.scrollToIndex&&("number"==typeof t.scrollToIndex?t.scrollToIndex:t.scrollToIndex.index);return e.useEffect((function(){void 0!==a&&c(a)}),[a,c]),ve(d,s)}var ct=function(t){var n=e.useRef(t);return n.current=t,n},at=function(t,n,r){function i(){s.current&&clearTimeout(s.current),s.current=void 0}function o(){s.current=void 0}void 0===n&&(n=100),void 0===r&&(r=0);var u=ct(t),s=e.useRef(),c=[n,r,u];return e.useEffect((function(){return i}),c),e.useCallback((function(){var t=arguments,e=s.current;if(void 0===e&&r)return s.current=setTimeout(o,n),u.current.apply(null,t);e&&clearTimeout(e),s.current=setTimeout((function(){s.current=void 0,u.current.apply(null,t)}),n)}),c)},ft=e["undefined"!=typeof document&&void 0!==document.createElement?"useLayoutEffect":"useEffect"],dt={},ht="undefined"==typeof window?null:window,lt=function(){return[document.documentElement.clientWidth,document.documentElement.clientHeight]},vt="undefined"!=typeof performance?performance:Date,pt=function(){return vt.now()},mt="undefined"==typeof window?null:window,gt=function(){return void 0!==mt.scrollY?mt.scrollY:void 0===mt.pageYOffset?0:mt.pageYOffset},yt="undefined",bt=typeof window!==yt?window:{},wt=typeof performance!==yt?performance:Date,_t=function(){return wt.now()},Pt="AnimationFrame",xt="cancel"+Pt,Rt="request"+Pt,Ct=bt[Rt]&&bt[Rt].bind(bt),Et=bt[xt]&&bt[xt].bind(bt);if(!Ct||!Et){var Mt=0;Ct=function(t){var e=_t(),n=Math.max(Mt+1e3/60,e);return setTimeout((function(){t(Mt=n)}),n-e)},Et=function(t){return clearTimeout(t)}}var Lt=function(t){try{return new t}catch(t){var e={};return{set:function(t,n){e[t]=n},get:function(t){return e[t]}}}},Ot=function(t,e){var n,r,i,o,u,s,c,a,f,d=(c=(r=t).length,a=Lt(r[0]),f=1===c,3>c?{g:function(t){return void 0===(i=a.get(t[0]))||f?i:i.get(t[1])},s:function(t,e){return f?a.set(t[0],e):void 0===(i=a.get(t[0]))?((o=Lt(r[1])).set(t[1],e),a.set(t[0],o)):i.set(t[1],e),e}}:{g:function(t){for(s=a,u=0;c>u;u++)if(void 0===(s=s.get(t[u])))return;return s},s:function(t,e){for(s=a,u=0;c-1>u;u++)void 0===(o=s.get(t[u]))?(o=Lt(r[u+1]),s.set(t[u],o),s=o):s=o;return s.set(t[c-1],e),e}}),h=d.g,l=d.s;return function(){return void 0===(n=h(arguments))?l(arguments,e.apply(null,arguments)):n}},Tt=function(){var t,e;this.set=void 0,this.get=void 0,this.get=function(n){return n===t?e:void 0},this.set=function(n,r){t=n,e=r}},zt=function(t,e){var n,r,i=e||At;return function(){return n&&i(arguments,n)?r:r=t.apply(null,n=arguments)}},At=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},St=new WeakMap,Wt={},kt=e.createElement,It="0",Ht=Ot([Tt,{},WeakMap,Tt],(function(t,e,n,r){return kt(t,{index:e,data:n,width:r})})),jt=zt((function(t,e){return{position:"relative",width:"100%",maxWidth:"100%",height:Math.ceil(e),maxHeight:Math.ceil(e),willChange:t?"contents":void 0,pointerEvents:t?"none":void 0}})),Dt=function(t,e){return t[0]===e[0]&&t[1]===e[1]},qt=zt((function(t,e){return n({},t,e)}),Dt),Bt=zt((function(t){return{width:t,zIndex:-1e3,visibility:"hidden",position:"absolute",writingMode:"horizontal-tb"}}),(function(t,e){return t[0]===e[0]})),Ft=zt((function(t,e){return function(n){return function(r){null!==r&&(e&&(e.observe(r),St.set(r,n)),void 0===t.get(n)&&t.set(n,r.offsetHeight))}}}),Dt),Gt=[],Nt=function(){return"undefined"!=typeof Map?Map:(Object.defineProperty(v.prototype,"size",{get:p,enumerable:1,configurable:1}),v.prototype.get=m,v.prototype.set=g,v.prototype.delete=y,v.prototype.has=b,v.prototype.clear=w,v.prototype.forEach=_,v)}(),Vt="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,Yt=function(){return"undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")()}(),Kt=function(){return"function"==typeof requestAnimationFrame?requestAnimationFrame.bind(Yt):P}(),Jt=["top","right","bottom","left","width","height","size","weight"],Qt="undefined"!=typeof MutationObserver,Ut=function(){return x.prototype.addObserver=R,x.prototype.removeObserver=C,x.prototype.refresh=E,x.prototype.updateObservers_=O,x.prototype.connect_=T,x.prototype.disconnect_=z,x.prototype.onTransitionEnd_=A,x.getInstance=S,x.instance_=null,x}(),Xt=function(t,e){for(var n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];Object.defineProperty(t,i,{value:e[i],enumerable:0,writable:0,configurable:1})}return t},Zt=function(t){return t&&t.ownerDocument&&t.ownerDocument.defaultView||Yt},$t=D(0,0,0,0),te=function(){return"undefined"!=typeof SVGGraphicsElement?I:H}(),ee=function(){return q.prototype.isActive=B,q.prototype.broadcastRect=F,q}(),ne=function(){return G}(),re=function(){return N.prototype.observe=V,N.prototype.unobserve=Y,N.prototype.disconnect=K,N.prototype.gatherActive=J,N.prototype.broadcastActive=U,N.prototype.clearActive=X,N.prototype.hasActive=Z,N}(),ie="undefined"!=typeof WeakMap?new WeakMap:new Nt,oe=function(){return function t(e){if(!(this instanceof t))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=Ut.getInstance(),r=new re(e,n,this);ie.set(this,r)}}();["observe","unobserve","disconnect"].forEach((function(t){oe.prototype[t]=function(){var e;return(e=ie.get(this))[t].apply(e,arguments)}}));var ue=function(){return void 0!==Yt.ResizeObserver?Yt.ResizeObserver:oe}(),se=Ot([WeakMap],(function(t,e){var n=function(t){function e(){r=null,t.apply(void 0,n)}var n=[],r=null,i=function(){for(var t=arguments.length,i=new Array(t),o=0;t>o;o++)i[o]=arguments[o];n=i,r||(r=requestAnimationFrame(e))};return i.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},i}((function(n){for(var r=[],i=0;i<n.length;i++){var o=n[i],u=o.target.offsetHeight;if(u>0){var s=St.get(o.target);if(void 0!==s){var c=t.get(s);void 0!==c&&u!==c.height&&r.push(s,u)}}}r.length>0&&(t.update(r),e(r))})),r=new ue(n),i=r.disconnect.bind(r);return r.disconnect=function(){i(),n.cancel()},r})),ce={low:0,max:0,high:0,C:2,P:void 0,R:void 0,L:void 0,list:void 0};ce.P=ce,ce.L=ce,ce.R=ce;var ae=function(t,e,n){void 0===n&&(n=0);for(var r=function(){var t={root:ce,size:0},e={};return{insert:function(n,r,i){for(var o=t.root,u=ce;o!==ce&&n!==(u=o).low;)o=n<o.low?o.L:o.R;if(n===u.low&&u!==ce){if(!function(t,e,n){for(var r,i=t.list;i;){if(i.index===n)return 0;if(e>i.high)break;r=i,i=i.next}return r||(t.list={index:n,high:e,next:i}),r&&(r.next={index:n,high:e,next:r.next}),1}(u,r,i))return;return u.high=Math.max(u.high,r),tt(u),et(u),e[i]=u,void t.size++}var s={low:n,high:r,max:r,C:0,P:u,L:ce,R:ce,list:{index:i,high:r,next:null}};u===ce?t.root=s:(s.low<u.low?u.L=s:u.R=s,et(s)),function(t,e){for(var n;0===e.P.C;)e.P===e.P.P.L?0===(n=e.P.P.R).C?(e.P.C=1,n.C=1,e.P.P.C=0,e=e.P.P):(e===e.P.R&&nt(t,e=e.P),e.P.C=1,e.P.P.C=0,rt(t,e.P.P)):0===(n=e.P.P.L).C?(e.P.C=1,n.C=1,e.P.P.C=0,e=e.P.P):(e===e.P.L&&rt(t,e=e.P),e.P.C=1,e.P.P.C=0,nt(t,e.P.P));t.root.C=1}(t,s),e[i]=s,t.size++},remove:function(n){var r=e[n];if(void 0!==r){delete e[n];var i=function(t,e){var n=t.list;if(n.index===e)return null===n.next?0:(t.list=n.next,1);var r=n;for(n=n.next;null!==n;){if(n.index===e)return r.next=n.next,1;r=n,n=n.next}}(r,n);if(void 0!==i){if(1===i)return r.high=r.list.high,tt(r),et(r),void t.size--;var o,u=r,s=u.C;r.L===ce?(o=r.R,it(t,r,r.R)):r.R===ce?(o=r.L,it(t,r,r.L)):(s=(u=function(t){for(;t.L!==ce;)t=t.L;return t}(r.R)).C,o=u.R,u.P===r?o.P=u:(it(t,u,u.R),u.R=r.R,u.R.P=u),it(t,r,u),u.L=r.L,u.L.P=u,u.C=r.C),tt(o),et(o),1===s&&function(t,e){for(var n;e!==ce&&1===e.C;)e===e.P.L?(0===(n=e.P.R).C&&(n.C=1,e.P.C=0,nt(t,e.P),n=e.P.R),1===n.L.C&&1===n.R.C?(n.C=0,e=e.P):(1===n.R.C&&(n.L.C=1,n.C=0,rt(t,n),n=e.P.R),n.C=e.P.C,e.P.C=1,n.R.C=1,nt(t,e.P),e=t.root)):(0===(n=e.P.L).C&&(n.C=1,e.P.C=0,rt(t,e.P),n=e.P.L),1===n.R.C&&1===n.L.C?(n.C=0,e=e.P):(1===n.L.C&&(n.R.C=1,n.C=0,nt(t,n),n=e.P.L),n.C=e.P.C,e.P.C=1,n.L.C=1,rt(t,e.P),e=t.root));e.C=1}(t,o),t.size--}}},search:function(e,n,r){for(var i=[t.root];0!==i.length;){var o=i.pop();if(o!==ce&&e<=o.max&&(o.L!==ce&&i.push(o.L),o.R!==ce&&i.push(o.R),o.low<=n&&o.high>=e))for(var u=o.list;null!==u;)u.high<e||r(u.index,o.low),u=u.next}},get size(){return t.size}}}(),i=new Array(t),o=[],u=new Array(t),s=0;t>s;s++)i[s]=0,u[s]=[];return{columnCount:t,columnWidth:e,set:function(t,s){void 0===s&&(s=0);for(var c=0,a=1;a<i.length;a++)i[a]<i[c]&&(c=a);var f=i[c]||0;i[c]=f+s+n,u[c].push(t),o[t]={left:c*(e+n),top:f,height:s,column:c},r.insert(f,f+s,t)},get:function(t){return o[t]},update:function(e){for(var s=new Array(t),c=0,a=0;c<e.length-1;c++){var f=e[c],d=o[f];d.height=e[++c],r.remove(f),r.insert(d.top,d.top+d.height,f),s[d.column]=void 0===s[d.column]?f:Math.min(f,s[d.column])}for(c=0;c<s.length;c++)if(void 0!==s[c]){var h=u[c],l=fe(h,s[c]),v=u[c][l],p=o[v];for(i[c]=p.top+p.height+n,a=l+1;a<h.length;a++){var m=h[a],g=o[m];g.top=i[c],i[c]=g.top+g.height+n,r.remove(m),r.insert(g.top,g.top+g.height,m)}}},range:function(t,e,n){return r.search(t,e,(function(t,e){return n(t,o[t].left,e)}))},estimateHeight:function(e,n){var o=Math.max(0,Math.max.apply(null,i));return e===r.size?o:o+Math.ceil((e-r.size)/t)*n},shortestColumn:function(){return i.length>1?Math.min.apply(null,i):i[0]||0},size:function(){return r.size}}},fe=function(t,e){for(var n=0,r=t.length-1;r>=n;){var i=n+r>>>1,o=t[i];if(o===e)return i;o>e?r=i-1:n=i+1}return-1},de=function(t,e,n,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=8),r=r||Math.floor(t/(e+n))||1,[Math.floor((t-n*(r-1))/r),r]},he=[],le={index:void 0,position:void 0,prevTop:void 0},ve=e.createElement,pe=e.createElement,me=function(t,e){return void 0!==e[t]},ge={};t.List=function(t){return pe(st,n({role:"list",columnGutter:t.rowGutter,columnCount:1,columnWidth:1},t))},t.Masonry=st,t.MasonryScroller=d,t.createPositioner=ae,t.createResizeObserver=se,t.useContainerPosition=h,t.useInfiniteLoader=function(t,n){void 0===n&&(n=ge);var r=n,i=r.isItemLoaded,o=r.minimumBatchSize,u=void 0===o?16:o,s=r.threshold,c=void 0===s?16:s,a=r.totalItems,f=void 0===a?9e9:a,d=ct(t),h=ct(i);return e.useCallback((function(t,e,n){for(var r=function(t,e,n,r,i,o){void 0===t&&(t=me),void 0===e&&(e=16),void 0===r&&(r=9e9);for(var u,s,c=[],a=i;o>=a;a++)t(a,n)?void 0!==u&&void 0!==s&&(c.push(u,s),u=s=void 0):(s=a,void 0===u&&(u=a));if(void 0!==u&&void 0!==s){var f=Math.min(Math.max(s,u+e-1),r-1);for(a=s+1;f>=a&&!t(a,n);a++)s=a;c.push(u,s)}if(c.length)for(var d=c[0],h=c[1];e>h-d+1&&d>0;){var l=d-1;if(t(l,n))break;c[0]=d=l}return c}(h.current,u,n,f,Math.max(0,t-c),Math.min(f-1,(e||0)+c)),i=0;i<r.length-1;++i)d.current(r[i],r[++i],n)}),[f,u,c,d,h])},t.useMasonry=a,t.usePositioner=ot,t.useResizeObserver=$,t.useScrollToIndex=ut,t.useScroller=s,Object.defineProperty(t,"__esModule",{value:1})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t=t||self).Masonic={},t.React)}(this,(function(t,e){"use strict";function n(){return(n=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function r(t,e,n,r){function o(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];u.current.apply(this,e)}void 0===r&&(r=i);var u=ft(n),s=ft(r);at((function(){var n=t&&"current"in t?t.current:t;if(n){var r=o;n.addEventListener(e,r);var i=s.current;return function(){n.removeEventListener(e,r),i()}}}),[t,e])}function i(){}function o(t,n,r){function i(){a.current=0,d()}void 0===n&&(n=30),void 0===r&&(r=0);var o,u,s=(o=t,(u=e.useRef(o)).current=o,u),c=1e3/n,a=e.useRef(0),f=e.useRef(),d=function(){return f.current&&clearTimeout(f.current)},h=[n,r,s];return e.useEffect((function(){return i}),h),e.useCallback((function(){var t=arguments,e=pt(),n=function(){a.current=e,d(),s.current.apply(null,t)},i=a.current;if(r&&0===i)return n();if(e-i>c){if(i>0)return n();a.current=e}d(),f.current=setTimeout((function(){n(),a.current=0}),c)}),h)}function u(){}function s(t,n){function r(){a(0)}void 0===t&&(t=0),void 0===n&&(n=12);var i=function(t){void 0===t&&(t=30);var n=function(t,n){var r=e.useState(t);return[r[0],o(r[1],n,1)]}("undefined"==typeof window?0:yt,t);return function(t,e,r,i){function o(){for(var t=arguments.length,e=new Array(t),n=0;t>n;n++)e[n]=arguments[n];s.current.apply(this,e)}void 0===i&&(i=u);var s=mt((function(){return n[1](yt())})),c=mt(i);at((function(){var e=t&&"current"in t?t.current:t;if(e){var n=o;e.addEventListener("scroll",n);var r=c.current;return function(){e.removeEventListener("scroll",n),r()}}}),[t,"scroll"])}(gt),n[0]}(n),s=e.useState(0),c=s[0],a=s[1],f=e.useRef(0);return e.useEffect((function(){1===f.current&&a(1);var t,e,i,o,u=(t=r,e=40+1e3/n,i=Pt(),(o={}).v=Ct((function n(){Pt()-i<e?o.v=Ct(n):t.call(null)})),o);return f.current=1,function(){return function(t){Mt(t.v||-1)}(u)}}),[n,i]),{scrollTop:Math.max(0,i-t),isScrolling:c}}function c(){var t=e.useState(It)[1];return e.useRef((function(){return t({})})).current}function a(t){var r,i=t.positioner,o=t.resizeObserver,u=t.items,s=t.as,a=void 0===s?"div":s,d=t.id,h=t.className,l=t.style,v=t.role,p=void 0===v?"grid":v,m=t.tabIndex,g=void 0===m?0:m,y=t.containerRef,b=t.itemAs,w=void 0===b?"div":b,_=t.itemStyle,P=t.itemHeightEstimate,x=void 0===P?300:P,R=t.itemKey,E=void 0===R?f:R,C=t.overscanBy,M=void 0===C?2:C,L=t.scrollTop,O=t.isScrolling,T=t.height,z=t.render,A=t.onRender,S=0,W=c(),k=Nt(i,o),I=u.length,H=i.columnWidth,j=i.columnCount,D=i.range,q=i.estimateHeight,B=i.size,F=i.shortestColumn,G=B(),N=F(),V=[],Y=p+"item",K=Wt(A),J=L+(M*=T),Q=J>N&&I>G;if(D(Math.max(0,L-M/2),J,(function(t,e,i){var o=u[t],s=E(o,t),c={top:i,left:e,width:H,writingMode:"horizontal-tb",position:"absolute"};V.push(Ht(w,{key:s,ref:k(t),role:Y,style:"object"==typeof _&&null!==_?n({},c,_):c},Dt(z,t,o,H))),void 0===r?(S=t,r=t):(S=Math.min(S,t),r=Math.max(r,t))})),Q)for(var U=Math.min(I-G,Math.ceil((L+M-N)/x*j)),X=G,Z=Gt(H);G+U>X;X++){var $=u[X],tt=E($,X);V.push(Ht(w,{key:tt,ref:k(X),role:Y,style:"object"==typeof _?n({},Z,_):Z},Dt(z,X,$,H)))}e.useEffect((function(){"function"==typeof K.current&&void 0!==r&&K.current(S,r,u),jt="1"}),[S,r,u,K]),e.useEffect((function(){Q&&W()}),[Q]);var et=qt(O,q(I,x));return Ht(a,{ref:y,key:jt,id:d,role:p,className:h,tabIndex:g,style:"object"==typeof l?Ft(et,l):et,children:V})}function f(t,e){return e}function d(t){var e=s(t.offset,t.scrollFps);return a({scrollTop:e.scrollTop,isScrolling:e.isScrolling,positioner:t.positioner,resizeObserver:t.resizeObserver,items:t.items,onRender:t.onRender,as:t.as,id:t.id,className:t.className,style:t.style,role:t.role,tabIndex:t.tabIndex,containerRef:t.containerRef,itemAs:t.itemAs,itemStyle:t.itemStyle,itemHeightEstimate:t.itemHeightEstimate,itemKey:t.itemKey,overscanBy:t.overscanBy,height:t.height,render:t.render})}function h(t,n){void 0===n&&(n=Vt);var r=e.useState({offset:0,width:0}),i=r[0],o=r[1];return at((function(){var e=t.current;if(null!==e){var n=0,r=e;do{n+=r.offsetTop||0,r=r.offsetParent}while(r);n===i.offset&&e.offsetWidth===i.width||o({offset:n,width:e.offsetWidth})}}),n),i}function l(t,e){var n=-1;return t.some((function(t,r){return t[0]===e?(n=r,1):0})),n}function v(){this.__entries__=[]}function p(){return this.__entries__.length}function m(t){var e=l(this.__entries__,t),n=this.__entries__[e];return n&&n[1]}function g(t,e){var n=l(this.__entries__,t);~n?this.__entries__[n][1]=e:this.__entries__.push([t,e])}function y(t){var e=this.__entries__,n=l(e,t);~n&&e.splice(n,1)}function b(t){return!!~l(this.__entries__,t)}function w(){this.__entries__.splice(0)}function _(t,e){void 0===e&&(e=null);for(var n=0,r=this.__entries__;n<r.length;n++){var i=r[n];t.call(e,i[1],i[0])}}function P(t){return setTimeout((function(){return t(Date.now())}),1e3/60)}function x(){this.connected_=0,this.mutationEventsAdded_=0,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(t){function e(){i&&(i=0,t()),o&&r()}function n(){Qt(e)}function r(){var t=Date.now();if(i){if(2>t-u)return;o=1}else i=1,o=0,setTimeout(n,20);u=t}var i=0,o=0,u=0;return r}(this.refresh.bind(this))}function R(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()}function E(t){var e=this.observers_,n=e.indexOf(t);~n&&e.splice(n,1),!e.length&&this.connected_&&this.disconnect_()}function C(){this.updateObservers_()&&this.refresh()}function M(t){return t.gatherActive(),t.hasActive()}function L(t){return t.broadcastActive()}function O(){var t=this.observers_.filter(M);return t.forEach(L),t.length>0}function T(){Kt&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),Xt?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:1,childList:1,characterData:1,subtree:1})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=1),this.connected_=1)}function z(){Kt&&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_=0,this.connected_=0)}function A(t){var e=t.propertyName,n=void 0===e?"":e;Ut.some((function(t){return!!~n.indexOf(t)}))&&this.refresh()}function S(){return this.instance_||(this.instance_=new x),this.instance_}function W(t){return parseFloat(t)||0}function k(t){for(var e=[],n=1;arguments.length>n;n++)e[n-1]=arguments[n];return e.reduce((function(e,n){return e+W(t["border-"+n+"-width"])}),0)}function I(t){return t instanceof te(t).SVGGraphicsElement}function H(t){return t instanceof te(t).SVGElement&&"function"==typeof t.getBBox}function j(t){return Kt?ne(t)?function(t){var e=t.getBBox();return D(0,0,e.width,e.height)}(t):function(t){var e=t.clientWidth,n=t.clientHeight;if(!e&&!n)return ee;var r=te(t).getComputedStyle(t),i=function(t){for(var e={},n=0,r=["top","right","bottom","left"];r.length>n;n++){var i=r[n],o=t["padding-"+i];e[i]=W(o)}return e}(r),o=i.left+i.right,u=i.top+i.bottom,s=W(r.width),c=W(r.height);if("border-box"===r.boxSizing&&(Math.round(s+o)!==e&&(s-=k(r,"left","right")+o),Math.round(c+u)!==n&&(c-=k(r,"top","bottom")+u)),!function(t){return t===te(t).document.documentElement}(t)){var a=Math.round(s+o)-e,f=Math.round(c+u)-n;1!==Math.abs(a)&&(s-=a),1!==Math.abs(f)&&(c-=f)}return D(i.left,i.top,s,c)}(t):ee}function D(t,e,n,r){return{x:t,y:e,width:n,height:r}}function q(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=D(0,0,0,0),this.target=t}function B(){var t=j(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight}function F(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t}function G(t,e){var n,r,i,o,u,s,c,a=(r=(n=e).x,i=n.y,o=n.width,u=n.height,s="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,c=Object.create(s.prototype),$t(c,{x:r,y:i,width:o,height:u,top:i,right:r+o,bottom:u+i,left:r}),c);$t(this,{target:t,contentRect:a})}function N(t,e,n){if(this.activeObservations_=[],this.observations_=new Yt,"function"!=typeof t)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=e,this.callbackCtx_=n}function V(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof te(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)||(e.set(t,new re(t)),this.controller_.addObserver(this),this.controller_.refresh())}}function Y(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof te(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)&&(e.delete(t),e.size||this.controller_.removeObserver(this))}}function K(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)}function J(){var t=this;this.clearActive(),this.observations_.forEach((function(e){e.isActive()&&t.activeObservations_.push(e)}))}function Q(t){return new ie(t.target,t.broadcastRect())}function U(){if(this.hasActive()){var t=this.callbackCtx_,e=this.activeObservations_.map(Q);this.callback_.call(t,e,t),this.clearActive()}}function X(){this.activeObservations_.splice(0)}function Z(){return this.activeObservations_.length>0}function $(t){function n(){return i.disconnect()}var r=c(),i=ae(t,r);return e.useEffect((function(){return n}),[i]),i}function tt(t){var e=t.high;t.L===fe&&t.R===fe?t.max=e:t.L===fe?t.max=Math.max(t.R.max,e):t.R===fe?t.max=Math.max(t.L.max,e):t.max=Math.max(Math.max(t.L.max,t.R.max),e)}function et(t){for(var e=t;e.P!==fe;)tt(e.P),e=e.P}function nt(t,e){if(e.R!==fe){var n=e.R;e.R=n.L,n.L!==fe&&(n.L.P=e),n.P=e.P,e.P===fe?t.root=n:e===e.P.L?e.P.L=n:e.P.R=n,n.L=e,e.P=n,tt(e),tt(n)}}function rt(t,e){if(e.L!==fe){var n=e.L;e.L=n.R,n.R!==fe&&(n.R.P=e),n.P=e.P,e.P===fe?t.root=n:e===e.P.R?e.P.R=n:e.P.L=n,n.R=e,e.P=n,tt(e),tt(n)}}function it(t,e,n){e.P===fe?t.root=n:e===e.P.L?e.P.L=n:e.P.R=n,n.P=e.P}function ot(t,n){var r=t.width,i=t.columnWidth,o=void 0===i?200:i,u=t.columnGutter,s=void 0===u?0:u,c=t.columnCount;void 0===n&&(n=ve);var a=function(){var t=le(r,o,s,c),e=t[0],n=t[1];return de(n,e,s)},f=e.useRef();void 0===f.current&&(f.current=a());var d=e.useRef(n),h=[r,o,s,c],l=e.useRef(h),v=!h.every((function(t,e){return l.current[e]===t}));if(v||!n.every((function(t,e){return d.current[e]===t}))){var p=f.current,m=a();if(d.current=n,l.current=h,v)for(var g=p.size(),y=0;g>y;y++){var b=p.get(y);m.set(y,void 0!==b?b.height:0)}f.current=m}return f.current}function ut(t,n){var r,i,u,s,c=n.align,a=void 0===c?"top":c,f=n.element,d=void 0===f?"undefined"!=typeof window&&window:f,h=n.offset,l=void 0===h?0:h,v=n.height,p=void 0===v?"undefined"!=typeof window?window.innerHeight:0:v,m=Wt({positioner:t,element:d,align:a,offset:l,height:p}),g=e.useRef((function(){var t=m.current.element;return t&&"current"in t?t.current:t})).current,y=e.useReducer((function(t,e){var n,r={position:t.position,index:t.index,prevTop:t.prevTop};if("scrollToIndex"===e.type)return{position:m.current.positioner.get(null!==(n=e.value)&&void 0!==n?n:-1),index:e.value,prevTop:void 0};if("setPosition"===e.type)r.position=e.value;else if("setPrevTop"===e.type)r.prevTop=e.value;else if("reset"===e.type)return me;return r}),me),b=y[0],w=y[1],_=o(w,15);i=g(),u=pe((function(){if(!b.position&&b.index){var t=m.current.positioner.get(b.index);t&&w({type:"setPosition",value:t})}})),s=pe(void 0),at((function(){function t(){if(!n){for(var t=arguments.length,e=new Array(t),r=0;t>r;r++)e[r]=arguments[r];u.current.apply(this,e)}}var e=i&&"current"in i?i.current:i;if(e){var n=0;e.addEventListener("scroll",t);var r=s.current;return function(){n=1,e.removeEventListener("scroll",t),r&&r()}}}),[i,"scroll"]);var P=void 0!==b.index&&(null===(r=m.current.positioner.get(b.index))||void 0===r?void 0:r.top);return e.useEffect((function(){var t=g();if(t){var e=m.current,n=e.height,r=e.align,i=e.offset,o=e.positioner;if(b.position){var u=b.position.top;"bottom"===r?u=u-n+b.position.height:"center"===r&&(u-=(n-b.position.height)/2),t.scrollTo(0,Math.max(0,u+=i));var s=0,c=setTimeout((function(){return!s&&w({type:"reset"})}),400);return function(){s=1,clearTimeout(c)}}if(void 0!==b.index){var a=o.shortestColumn()/o.size()*b.index;b.prevTop&&(a=Math.max(a,b.prevTop+n)),t.scrollTo(0,a),_({type:"setPrevTop",value:a})}}}),[P,b,m,g,_]),e.useRef((function(t){w({type:"scrollToIndex",value:t})})).current}function st(t){var i=e.useRef(null),o=function(t){void 0===t&&(t=dt);var n=t,i=n.wait,o=n.leading,u=n.initialWidth,s=void 0===u?0:u,c=n.initialHeight,a=function(t,n,r){var i=e.useState(t);return[i[0],ct(i[1],n,r)]}("undefined"==typeof document?[s,void 0===c?0:c]:lt,i,o),f=a[0],d=a[1],h=function(){return d(lt)};return r(ht,"resize",h),r(ht,"orientationchange",h),f}({initialWidth:t.ssrWidth,initialHeight:t.ssrHeight}),u=h(i,o),s=n({offset:u.offset,width:u.width||o[0],height:o[1],containerRef:i},t);s.positioner=ot(s),s.resizeObserver=$(s.positioner);var c=ut(s.positioner,{height:s.height,offset:u.offset,align:"object"==typeof t.scrollToIndex?t.scrollToIndex.align:void 0}),a=t.scrollToIndex&&("number"==typeof t.scrollToIndex?t.scrollToIndex:t.scrollToIndex.index);return e.useEffect((function(){void 0!==a&&c(a)}),[a,c]),ge(d,s)}var ct=function(t,n,r){function i(){a.current&&clearTimeout(a.current),a.current=void 0}function o(){a.current=void 0}void 0===n&&(n=100),void 0===r&&(r=0);var u,s,c=(u=t,(s=e.useRef(u)).current=u,s),a=e.useRef(),f=[n,r,c];return e.useEffect((function(){return i}),f),e.useCallback((function(){var t=arguments,e=a.current;if(void 0===e&&r)return a.current=setTimeout(o,n),c.current.apply(null,t);e&&clearTimeout(e),a.current=setTimeout((function(){a.current=void 0,c.current.apply(null,t)}),n)}),f)},at=e["undefined"!=typeof document&&void 0!==document.createElement?"useLayoutEffect":"useEffect"],ft=function(t){var n=e.useRef(t);return n.current=t,n},dt={},ht="undefined"==typeof window?null:window,lt=function(){return[document.documentElement.clientWidth,document.documentElement.clientHeight]},vt="undefined"!=typeof performance?performance:Date,pt=function(){return vt.now()},mt=function(t){var n=e.useRef(t);return n.current=t,n},gt="undefined"==typeof window?null:window,yt=function(){return void 0!==gt.scrollY?gt.scrollY:void 0===gt.pageYOffset?0:gt.pageYOffset},bt="undefined",wt=typeof window!==bt?window:{},_t=typeof performance!==bt?performance:Date,Pt=function(){return _t.now()},xt="AnimationFrame",Rt="cancel"+xt,Et="request"+xt,Ct=wt[Et]&&wt[Et].bind(wt),Mt=wt[Rt]&&wt[Rt].bind(wt);if(!Ct||!Mt){var Lt=0;Ct=function(t){var e=Pt(),n=Math.max(Lt+1e3/60,e);return setTimeout((function(){t(Lt=n)}),n-e)},Mt=function(t){return clearTimeout(t)}}var Ot=function(t){try{return new t}catch(t){var e={};return{set:function(t,n){e[t]=n},get:function(t){return e[t]}}}},Tt=function(t,e){var n,r,i,o,u,s,c,a,f,d=(c=(r=t).length,a=Ot(r[0]),f=1===c,3>c?{g:function(t){return void 0===(i=a.get(t[0]))||f?i:i.get(t[1])},s:function(t,e){return f?a.set(t[0],e):void 0===(i=a.get(t[0]))?((o=Ot(r[1])).set(t[1],e),a.set(t[0],o)):i.set(t[1],e),e}}:{g:function(t){for(s=a,u=0;c>u;u++)if(void 0===(s=s.get(t[u])))return;return s},s:function(t,e){for(s=a,u=0;c-1>u;u++)void 0===(o=s.get(t[u]))?(o=Ot(r[u+1]),s.set(t[u],o),s=o):s=o;return s.set(t[c-1],e),e}}),h=d.g,l=d.s;return function(){return void 0===(n=h(arguments))?l(arguments,e.apply(null,arguments)):n}},zt=function(){var t,e;this.set=void 0,this.get=void 0,this.get=function(n){return n===t?e:void 0},this.set=function(n,r){t=n,e=r}},At=function(t,e){var n,r,i=e||St;return function(){return n&&i(arguments,n)?r:r=t.apply(null,n=arguments)}},St=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},Wt=function(t){var n=e.useRef(t);return e.useEffect((function(){n.current=t})),n},kt=new WeakMap,It={},Ht=e.createElement,jt="0",Dt=Tt([zt,{},WeakMap,zt],(function(t,e,n,r){return Ht(t,{index:e,data:n,width:r})})),qt=At((function(t,e){return{position:"relative",width:"100%",maxWidth:"100%",height:Math.ceil(e),maxHeight:Math.ceil(e),willChange:t?"contents":void 0,pointerEvents:t?"none":void 0}})),Bt=function(t,e){return t[0]===e[0]&&t[1]===e[1]},Ft=At((function(t,e){return n({},t,e)}),Bt),Gt=At((function(t){return{width:t,zIndex:-1e3,visibility:"hidden",position:"absolute",writingMode:"horizontal-tb"}}),(function(t,e){return t[0]===e[0]})),Nt=At((function(t,e){return function(n){return function(r){null!==r&&(e&&(e.observe(r),kt.set(r,n)),void 0===t.get(n)&&t.set(n,r.offsetHeight))}}}),Bt),Vt=[],Yt=function(){return"undefined"!=typeof Map?Map:(Object.defineProperty(v.prototype,"size",{get:p,enumerable:1,configurable:1}),v.prototype.get=m,v.prototype.set=g,v.prototype.delete=y,v.prototype.has=b,v.prototype.clear=w,v.prototype.forEach=_,v)}(),Kt="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,Jt=function(){return"undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")()}(),Qt=function(){return"function"==typeof requestAnimationFrame?requestAnimationFrame.bind(Jt):P}(),Ut=["top","right","bottom","left","width","height","size","weight"],Xt="undefined"!=typeof MutationObserver,Zt=function(){return x.prototype.addObserver=R,x.prototype.removeObserver=E,x.prototype.refresh=C,x.prototype.updateObservers_=O,x.prototype.connect_=T,x.prototype.disconnect_=z,x.prototype.onTransitionEnd_=A,x.getInstance=S,x.instance_=null,x}(),$t=function(t,e){for(var n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];Object.defineProperty(t,i,{value:e[i],enumerable:0,writable:0,configurable:1})}return t},te=function(t){return t&&t.ownerDocument&&t.ownerDocument.defaultView||Jt},ee=D(0,0,0,0),ne=function(){return"undefined"!=typeof SVGGraphicsElement?I:H}(),re=function(){return q.prototype.isActive=B,q.prototype.broadcastRect=F,q}(),ie=function(){return G}(),oe=function(){return N.prototype.observe=V,N.prototype.unobserve=Y,N.prototype.disconnect=K,N.prototype.gatherActive=J,N.prototype.broadcastActive=U,N.prototype.clearActive=X,N.prototype.hasActive=Z,N}(),ue="undefined"!=typeof WeakMap?new WeakMap:new Yt,se=function(){return function t(e){if(!(this instanceof t))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=Zt.getInstance(),r=new oe(e,n,this);ue.set(this,r)}}();["observe","unobserve","disconnect"].forEach((function(t){se.prototype[t]=function(){var e;return(e=ue.get(this))[t].apply(e,arguments)}}));var ce=function(){return void 0!==Jt.ResizeObserver?Jt.ResizeObserver:se}(),ae=Tt([WeakMap],(function(t,e){var n=function(t){function e(){r=null,t.apply(void 0,n)}var n=[],r=null,i=function(){for(var t=arguments.length,i=new Array(t),o=0;t>o;o++)i[o]=arguments[o];n=i,r||(r=requestAnimationFrame(e))};return i.cancel=function(){r&&(cancelAnimationFrame(r),r=null)},i}((function(n){for(var r=[],i=0;i<n.length;i++){var o=n[i],u=o.target.offsetHeight;if(u>0){var s=kt.get(o.target);if(void 0!==s){var c=t.get(s);void 0!==c&&u!==c.height&&r.push(s,u)}}}r.length>0&&(t.update(r),e(r))})),r=new ce(n),i=r.disconnect.bind(r);return r.disconnect=function(){i(),n.cancel()},r})),fe={low:0,max:0,high:0,C:2,P:void 0,R:void 0,L:void 0,list:void 0};fe.P=fe,fe.L=fe,fe.R=fe;var de=function(t,e,n){void 0===n&&(n=0);for(var r=function(){var t={root:fe,size:0},e={};return{insert:function(n,r,i){for(var o=t.root,u=fe;o!==fe&&n!==(u=o).low;)o=n<o.low?o.L:o.R;if(n===u.low&&u!==fe){if(!function(t,e,n){for(var r,i=t.list;i;){if(i.index===n)return 0;if(e>i.high)break;r=i,i=i.next}return r||(t.list={index:n,high:e,next:i}),r&&(r.next={index:n,high:e,next:r.next}),1}(u,r,i))return;return u.high=Math.max(u.high,r),tt(u),et(u),e[i]=u,void t.size++}var s={low:n,high:r,max:r,C:0,P:u,L:fe,R:fe,list:{index:i,high:r,next:null}};u===fe?t.root=s:(s.low<u.low?u.L=s:u.R=s,et(s)),function(t,e){for(var n;0===e.P.C;)e.P===e.P.P.L?0===(n=e.P.P.R).C?(e.P.C=1,n.C=1,e.P.P.C=0,e=e.P.P):(e===e.P.R&&nt(t,e=e.P),e.P.C=1,e.P.P.C=0,rt(t,e.P.P)):0===(n=e.P.P.L).C?(e.P.C=1,n.C=1,e.P.P.C=0,e=e.P.P):(e===e.P.L&&rt(t,e=e.P),e.P.C=1,e.P.P.C=0,nt(t,e.P.P));t.root.C=1}(t,s),e[i]=s,t.size++},remove:function(n){var r=e[n];if(void 0!==r){delete e[n];var i=function(t,e){var n=t.list;if(n.index===e)return null===n.next?0:(t.list=n.next,1);var r=n;for(n=n.next;null!==n;){if(n.index===e)return r.next=n.next,1;r=n,n=n.next}}(r,n);if(void 0!==i){if(1===i)return r.high=r.list.high,tt(r),et(r),void t.size--;var o,u=r,s=u.C;r.L===fe?(o=r.R,it(t,r,r.R)):r.R===fe?(o=r.L,it(t,r,r.L)):(s=(u=function(t){for(;t.L!==fe;)t=t.L;return t}(r.R)).C,o=u.R,u.P===r?o.P=u:(it(t,u,u.R),u.R=r.R,u.R.P=u),it(t,r,u),u.L=r.L,u.L.P=u,u.C=r.C),tt(o),et(o),1===s&&function(t,e){for(var n;e!==fe&&1===e.C;)e===e.P.L?(0===(n=e.P.R).C&&(n.C=1,e.P.C=0,nt(t,e.P),n=e.P.R),1===n.L.C&&1===n.R.C?(n.C=0,e=e.P):(1===n.R.C&&(n.L.C=1,n.C=0,rt(t,n),n=e.P.R),n.C=e.P.C,e.P.C=1,n.R.C=1,nt(t,e.P),e=t.root)):(0===(n=e.P.L).C&&(n.C=1,e.P.C=0,rt(t,e.P),n=e.P.L),1===n.R.C&&1===n.L.C?(n.C=0,e=e.P):(1===n.L.C&&(n.R.C=1,n.C=0,nt(t,n),n=e.P.L),n.C=e.P.C,e.P.C=1,n.L.C=1,rt(t,e.P),e=t.root));e.C=1}(t,o),t.size--}}},search:function(e,n,r){for(var i=[t.root];0!==i.length;){var o=i.pop();if(o!==fe&&e<=o.max&&(o.L!==fe&&i.push(o.L),o.R!==fe&&i.push(o.R),o.low<=n&&o.high>=e))for(var u=o.list;null!==u;)u.high<e||r(u.index,o.low),u=u.next}},get size(){return t.size}}}(),i=new Array(t),o=[],u=new Array(t),s=0;t>s;s++)i[s]=0,u[s]=[];return{columnCount:t,columnWidth:e,set:function(t,s){void 0===s&&(s=0);for(var c=0,a=1;a<i.length;a++)i[a]<i[c]&&(c=a);var f=i[c]||0;i[c]=f+s+n,u[c].push(t),o[t]={left:c*(e+n),top:f,height:s,column:c},r.insert(f,f+s,t)},get:function(t){return o[t]},update:function(e){for(var s=new Array(t),c=0,a=0;c<e.length-1;c++){var f=e[c],d=o[f];d.height=e[++c],r.remove(f),r.insert(d.top,d.top+d.height,f),s[d.column]=void 0===s[d.column]?f:Math.min(f,s[d.column])}for(c=0;c<s.length;c++)if(void 0!==s[c]){var h=u[c],l=he(h,s[c]),v=u[c][l],p=o[v];for(i[c]=p.top+p.height+n,a=l+1;a<h.length;a++){var m=h[a],g=o[m];g.top=i[c],i[c]=g.top+g.height+n,r.remove(m),r.insert(g.top,g.top+g.height,m)}}},range:function(t,e,n){return r.search(t,e,(function(t,e){return n(t,o[t].left,e)}))},estimateHeight:function(e,n){var o=Math.max(0,Math.max.apply(null,i));return e===r.size?o:o+Math.ceil((e-r.size)/t)*n},shortestColumn:function(){return i.length>1?Math.min.apply(null,i):i[0]||0},size:function(){return r.size}}},he=function(t,e){for(var n=0,r=t.length-1;r>=n;){var i=n+r>>>1,o=t[i];if(o===e)return i;o>e?r=i-1:n=i+1}return-1},le=function(t,e,n,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=8),r=r||Math.floor(t/(e+n))||1,[Math.floor((t-n*(r-1))/r),r]},ve=[],pe=function(t){var n=e.useRef(t);return n.current=t,n},me={index:void 0,position:void 0,prevTop:void 0},ge=e.createElement,ye=e.createElement,be=function(t,e){return void 0!==e[t]},we={};t.List=function(t){return ye(st,n({role:"list",columnGutter:t.rowGutter,columnCount:1,columnWidth:1},t))},t.Masonry=st,t.MasonryScroller=d,t.createPositioner=de,t.createResizeObserver=ae,t.useContainerPosition=h,t.useInfiniteLoader=function(t,n){void 0===n&&(n=we);var r=n,i=r.isItemLoaded,o=r.minimumBatchSize,u=void 0===o?16:o,s=r.threshold,c=void 0===s?16:s,a=r.totalItems,f=void 0===a?9e9:a,d=Wt(t),h=Wt(i);return e.useCallback((function(t,e,n){for(var r=function(t,e,n,r,i,o){void 0===t&&(t=be),void 0===e&&(e=16),void 0===r&&(r=9e9);for(var u,s,c=[],a=i;o>=a;a++)t(a,n)?void 0!==u&&void 0!==s&&(c.push(u,s),u=s=void 0):(s=a,void 0===u&&(u=a));if(void 0!==u&&void 0!==s){var f=Math.min(Math.max(s,u+e-1),r-1);for(a=s+1;f>=a&&!t(a,n);a++)s=a;c.push(u,s)}if(c.length)for(var d=c[0],h=c[1];e>h-d+1&&d>0;){var l=d-1;if(t(l,n))break;c[0]=d=l}return c}(h.current,u,n,f,Math.max(0,t-c),Math.min(f-1,(e||0)+c)),i=0;i<r.length-1;++i)d.current(r[i],r[++i],n)}),[f,u,c,d,h])},t.useMasonry=a,t.usePositioner=ot,t.useResizeObserver=$,t.useScrollToIndex=ut,t.useScroller=s,Object.defineProperty(t,"__esModule",{value:1})})); | ||
//# sourceMappingURL=masonic.js.map |
{ | ||
"name": "masonic", | ||
"version": "3.3.9", | ||
"version": "3.3.10", | ||
"homepage": "https://github.com/jaredLunde/masonic#readme", | ||
@@ -168,3 +168,3 @@ "repository": "github:jaredLunde/masonic", | ||
"@react-hook/event": "^1.2.2", | ||
"@react-hook/latest": "^1.0.2", | ||
"@react-hook/latest": "^1.0.3", | ||
"@react-hook/passive-layout-effect": "^1.2.0", | ||
@@ -171,0 +171,0 @@ "@react-hook/throttle": "^2.2.0", |
@@ -154,7 +154,3 @@ import * as React from 'react' | ||
*/ | ||
onRender?: ( | ||
startIndex: number, | ||
stopIndex: number | undefined, | ||
items: Item[] | ||
) => void | ||
onRender?: (startIndex: number, stopIndex: number, items: Item[]) => void | ||
} | ||
@@ -161,0 +157,0 @@ export interface RenderComponentProps<Item> { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
968126
9381
Updated@react-hook/latest@^1.0.3