Comparing version 3.3.0 to 3.3.1
@@ -5,2 +5,8 @@ # Changelog | ||
### [3.3.1](https://github.com/jaredLunde/masonic/compare/v3.3.0...v3.3.1) (2020-07-04) | ||
### Bug Fixes | ||
- **masonry:** fix loop in scrollToIndex effect ([dae9984](https://github.com/jaredLunde/masonic/commit/dae99847fe29d7c9b50141f8035968143680b292)) | ||
## [3.3.0](https://github.com/jaredLunde/masonic/compare/v3.2.0...v3.3.0) (2020-07-04) | ||
@@ -7,0 +13,0 @@ |
@@ -52,9 +52,6 @@ "use strict"; | ||
}); | ||
const index = props.scrollToIndex && (typeof props.scrollToIndex === 'number' ? props.scrollToIndex : props.scrollToIndex.index); | ||
React.useEffect(() => { | ||
const index = props.scrollToIndex; | ||
if (index !== void 0) { | ||
scrollToIndex(typeof index === 'number' ? index : index.index); | ||
} | ||
}, [props.scrollToIndex, scrollToIndex]); | ||
if (index !== void 0) scrollToIndex(index); | ||
}, [index, scrollToIndex]); | ||
return __reactCreateElement__(_masonryScroller.MasonryScroller, nextProps); | ||
@@ -61,0 +58,0 @@ } |
@@ -36,9 +36,6 @@ import * as React from 'react'; | ||
}); | ||
const index = props.scrollToIndex && (typeof props.scrollToIndex === 'number' ? props.scrollToIndex : props.scrollToIndex.index); | ||
React.useEffect(() => { | ||
const index = props.scrollToIndex; | ||
if (index !== void 0) { | ||
scrollToIndex(typeof index === 'number' ? index : index.index); | ||
} | ||
}, [props.scrollToIndex, scrollToIndex]); | ||
if (index !== void 0) scrollToIndex(index); | ||
}, [index, scrollToIndex]); | ||
return __reactCreateElement__(MasonryScroller, nextProps); | ||
@@ -45,0 +42,0 @@ } |
@@ -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(kt)[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,h=t.className,d=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,k=c(),W=qt(r,i),H=o.length,I=r.columnWidth,j=r.columnCount,D=r.range,B=r.estimateHeight,G=r.size,q=r.shortestColumn,F=G(),N=q(),V=[],Y=v+"item",K=ct(z),J=M+(E*=O),Q=J>N&&H>F;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:I,writingMode:"horizontal-tb",position:"absolute"};V.push(Wt(b,{key:u,ref:W(t),role:Y,style:"object"==typeof w&&null!==w?n(s,w):s},It(T,t,i,I))),void 0===S?(A=t,S=t):(A=Math.min(A,t),S=Math.max(S,t))})),Q)for(var U=Math.min(H-F,Math.ceil((M+E-N)/P*j)),X=F,Z=Gt(I);F+U>X;X++){var $=o[X],tt=R($,X);V.push(Wt(b,{key:tt,ref:W(X),role:Y,style:"object"==typeof w?n(Z,w):Z},It(T,X,$,I)))}e.useEffect((function(){"function"==typeof K.current&&void 0!==S&&K.current(A,S,o),Ht="1"}),[A,S,o,K]),e.useEffect((function(){Q&&k()}),[Q]);var et=jt(L,B(H,P));return Wt(s,{ref:g,key:Ht,id:a,role:v,className:h,tabIndex:m,style:"object"==typeof d?Bt(et,d):et,children:V})}function f(t,e){return e}function h(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 d(t,n){void 0===n&&(n=Ft);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 k(t){return parseFloat(t)||0}function W(t){for(var e=[],n=1;arguments.length>n;n++)e[n-1]=arguments[n];return e.reduce((function(e,n){return e+k(t["border-"+n+"-width"])}),0)}function H(t){return t instanceof Zt(t).SVGGraphicsElement}function I(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]=k(o)}return e}(r),o=i.left+i.right,u=i.top+i.bottom,s=k(r.width),c=k(r.height);if("border-box"===r.boxSizing&&(Math.round(s+o)!==e&&(s-=W(r,"left","right")+o),Math.round(c+u)!==n&&(c-=W(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 B(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=D(0,0,0,0),this.target=t}function G(){var t=j(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight}function q(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t}function F(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=de);var a=function(){var t=he(r,o,s,c),e=t[0],n=t[1];return ae(n,e,s)},f=e.useState(a),h=f[0],d=f[1],l=e.useRef(0);return ft((function(){l.current&&d(a()),l.current=1}),n),ft((function(){if(l.current){for(var t=h.size(),e=a(),n=0;t>n;n++){var r=h.get(n);e.set(n,void 0!==r?r.height:0)}d(e)}}),[r,o,s,c]),h}function ut(t,n){var r,i,u,s,c=n.align,a=void 0===c?"top":c,f=n.element,h=void 0===f?"undefined"!=typeof window&&window:f,d=n.offset,l=void 0===d?0:d,v=n.height,p=void 0===v?"undefined"!=typeof window?window.innerHeight:0:v,m=ct({positioner:t,element:h,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=ht);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],h=a[1],d=function(){return h(lt)};return r(dt,"resize",d),r(dt,"orientationchange",d),f}({initialWidth:t.ssrWidth,initialHeight:t.ssrHeight}),u=d(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});return e.useEffect((function(){var e=t.scrollToIndex;void 0!==e&&c("number"==typeof e?e:e.index)}),[t.scrollToIndex,c]),ve(h,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"],ht={},dt="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,h=(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}}),d=h.g,l=h.s;return function(){return void 0===(n=d(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,kt={},Wt=e.createElement,Ht="0",It=Ot([Tt,{},WeakMap,Tt],(function(t,e,n,r){return Wt(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]},Bt=zt((function(t,e){return n({},t,e)}),Dt),Gt=zt((function(t){return{width:t,zIndex:-1e3,visibility:"hidden",position:"absolute",writingMode:"horizontal-tb"}}),(function(t,e){return t[0]===e[0]})),qt=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),Ft=[],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?H:I}(),ee=function(){return B.prototype.isActive=G,B.prototype.broadcastRect=q,B}(),ne=function(){return F}(),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){return new ue((function(n){for(var r=[],i=0;i<n.length;i++){var o=n[i],u=void 0!==o.borderBoxSize?o.borderBoxSize.blockSize: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))}))})),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],h=o[f];h.height=e[++c],r.remove(f),r.insert(h.top,h.top+h.height,f),s[h.column]=void 0===s[h.column]?f:Math.min(f,s[h.column])}for(c=0;c<s.length;c++)if(void 0!==s[c]){var d=u[c],l=fe(d,s[c]),v=u[c][l],p=o[v];for(i[c]=p.top+p.height+n,a=l+1;a<d.length;a++){var m=d[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},he=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]},de=[],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=h,t.createPositioner=ae,t.createResizeObserver=se,t.useContainerPosition=d,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,h=ct(t),d=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 h=c[0],d=c[1];e>d-h+1&&h>0;){var l=h-1;if(t(l,n))break;c[0]=h=l}return c}(d.current,u,n,f,Math.max(0,t-c),Math.min(f-1,(e||0)+c)),i=0;i<r.length-1;++i)h.current(r[i],r[++i],n)}),[f,u,c,h,d])},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=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(kt)[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,k=c(),W=qt(r,i),I=o.length,H=r.columnWidth,j=r.columnCount,D=r.range,B=r.estimateHeight,G=r.size,q=r.shortestColumn,F=G(),N=q(),V=[],Y=v+"item",K=ct(z),J=M+(E*=O),Q=J>N&&I>F;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(Wt(b,{key:u,ref:W(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-F,Math.ceil((M+E-N)/P*j)),X=F,Z=Gt(H);F+U>X;X++){var $=o[X],tt=R($,X);V.push(Wt(b,{key:tt,ref:W(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&&k()}),[Q]);var et=jt(L,B(I,P));return Wt(s,{ref:g,key:It,id:a,role:v,className:d,tabIndex:m,style:"object"==typeof h?Bt(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=Ft);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 k(t){return parseFloat(t)||0}function W(t){for(var e=[],n=1;arguments.length>n;n++)e[n-1]=arguments[n];return e.reduce((function(e,n){return e+k(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]=k(o)}return e}(r),o=i.left+i.right,u=i.top+i.bottom,s=k(r.width),c=k(r.height);if("border-box"===r.boxSizing&&(Math.round(s+o)!==e&&(s-=W(r,"left","right")+o),Math.round(c+u)!==n&&(c-=W(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 B(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=D(0,0,0,0),this.target=t}function G(){var t=j(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight}function q(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t}function F(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.useState(a),d=f[0],h=f[1],l=e.useRef(0);return ft((function(){l.current&&h(a()),l.current=1}),n),ft((function(){if(l.current){for(var t=d.size(),e=a(),n=0;t>n;n++){var r=d.get(n);e.set(n,void 0!==r?r.height:0)}h(e)}}),[r,o,s,c]),d}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,kt={},Wt=e.createElement,It="0",Ht=Ot([Tt,{},WeakMap,Tt],(function(t,e,n,r){return Wt(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]},Bt=zt((function(t,e){return n({},t,e)}),Dt),Gt=zt((function(t){return{width:t,zIndex:-1e3,visibility:"hidden",position:"absolute",writingMode:"horizontal-tb"}}),(function(t,e){return t[0]===e[0]})),qt=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),Ft=[],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 B.prototype.isActive=G,B.prototype.broadcastRect=q,B}(),ne=function(){return F}(),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){return new ue((function(n){for(var r=[],i=0;i<n.length;i++){var o=n[i],u=void 0!==o.borderBoxSize?o.borderBoxSize.blockSize: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))}))})),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})})); | ||
//# sourceMappingURL=masonic.js.map |
{ | ||
"name": "masonic", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"homepage": "https://github.com/jaredLunde/masonic#readme", | ||
@@ -5,0 +5,0 @@ "repository": "github:jaredLunde/masonic", |
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 not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
950612
2
9240