|
1
|
|
-var bit_virtualized_list=function(){"use strict";var e,t="undefined"==typeof document?void 0:document,i=!!t&&"content"in t.createElement("template"),n=!!t&&t.createRange&&"createContextualFragment"in t.createRange();function o(e,t){var i,n,o=e.nodeName,r=t.nodeName;return o===r||(i=o.charCodeAt(0),n=r.charCodeAt(0),i<=90&&n>=97?o===r.toUpperCase():n<=90&&i>=97&&r===o.toUpperCase())}function r(e,t,i){e[i]!==t[i]&&(e[i]=t[i],e[i]?e.setAttribute(i,""):e.removeAttribute(i))}var a={OPTION:function(e,t){var i=e.parentNode;if(i){var n=i.nodeName.toUpperCase();"OPTGROUP"===n&&(n=(i=i.parentNode)&&i.nodeName.toUpperCase()),"SELECT"!==n||i.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),i.selectedIndex=-1)}r(e,t,"selected")},INPUT:function(e,t){r(e,t,"checked"),r(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var i=t.value;e.value!==i&&(e.value=i);var n=e.firstChild;if(n){var o=n.nodeValue;if(o==i||!i&&o==e.placeholder)return;n.nodeValue=i}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var i,n,o=-1,r=0,a=e.firstChild;a;)if("OPTGROUP"===(n=a.nodeName&&a.nodeName.toUpperCase()))a=(i=a).firstChild;else{if("OPTION"===n){if(a.hasAttribute("selected")){o=r;break}r++}!(a=a.nextSibling)&&i&&(a=i.nextSibling,i=null)}e.selectedIndex=o}}};function s(){}function d(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}var f=function(r,f,l){if(l||(l={}),"string"==typeof f)if("#document"===r.nodeName||"HTML"===r.nodeName||"BODY"===r.nodeName){var u=f;(f=t.createElement("html")).innerHTML=u}else h=(h=f).trim(),f=i?function(e){var i=t.createElement("template");return i.innerHTML=e,i.content.childNodes[0]}(h):n?function(i){return e||(e=t.createRange()).selectNode(t.body),e.createContextualFragment(i).childNodes[0]}(h):function(e){var i=t.createElement("body");return i.innerHTML=e,i.childNodes[0]}(h);else 11===f.nodeType&&(f=f.firstElementChild);var h,c=l.getNodeKey||d,p=l.onBeforeNodeAdded||s,m=l.onNodeAdded||s,v=l.onBeforeElUpdated||s,g=l.onElUpdated||s,S=l.onBeforeNodeDiscarded||s,x=l.onNodeDiscarded||s,A=l.onBeforeElChildrenUpdated||s,z=l.skipFromChildren||s,y=l.addChild||function(e,t){return e.appendChild(t)},b=!0===l.childrenOnly,C=Object.create(null),I=[];function N(e){I.push(e)}function _(e,t){if(1===e.nodeType)for(var i=e.firstChild;i;){var n=void 0;t&&(n=c(i))?N(n):(x(i),i.firstChild&&_(i,t)),i=i.nextSibling}}function M(e,t,i){!1!==S(e)&&(t&&t.removeChild(e),x(e),_(e,i))}function T(e){if(1===e.nodeType||11===e.nodeType)for(var t=e.firstChild;t;){var i=c(t);i&&(C[i]=t),T(t),t=t.nextSibling}}function w(e){m(e);for(var t=e.firstChild;t;){var i=t.nextSibling,n=c(t);if(n){var r=C[n];r&&o(t,r)?(t.parentNode.replaceChild(r,t),E(r,t)):w(t)}else w(t);t=i}}function E(e,i,n){var r=c(i);if(r&&delete C[r],!n){var s=v(e,i);if(!1===s)return;if(s instanceof HTMLElement&&T(e=s),function(e,t){var i,n,o,r,a=t.attributes;if(11!==t.nodeType&&11!==e.nodeType){for(var s=a.length-1;s>=0;s--)n=(i=a[s]).name,o=i.namespaceURI,r=i.value,o?(n=i.localName||n,e.getAttributeNS(o,n)!==r&&("xmlns"===i.prefix&&(n=i.name),e.setAttributeNS(o,n,r))):e.getAttribute(n)!==r&&e.setAttribute(n,r);for(var d=e.attributes,f=d.length-1;f>=0;f--)n=(i=d[f]).name,(o=i.namespaceURI)?(n=i.localName||n,t.hasAttributeNS(o,n)||e.removeAttributeNS(o,n)):t.hasAttribute(n)||e.removeAttribute(n)}}(e,i),g(e),!1===A(e,i))return}"TEXTAREA"!==e.nodeName?function(e,i){var n,r,s,d,f,l=z(e,i),u=i.firstChild,h=e.firstChild;e:for(;u;){for(d=u.nextSibling,n=c(u);!l&&h;){if(s=h.nextSibling,u.isSameNode&&u.isSameNode(h)){u=d,h=s;continue e}r=c(h);var m=h.nodeType,v=void 0;if(m===u.nodeType&&(1===m?(n?n!==r&&((f=C[n])?s===f?v=!1:(e.insertBefore(f,h),r?N(r):M(h,e,!0),r=c(h=f)):v=!1):r&&(v=!1),(v=!1!==v&&o(h,u))&&E(h,u)):3!==m&&8!=m||(v=!0,h.nodeValue!==u.nodeValue&&(h.nodeValue=u.nodeValue))),v){u=d,h=s;continue e}r?N(r):M(h,e,!0),h=s}if(n&&(f=C[n])&&o(f,u))l||y(e,f),E(f,u);else{var g=p(u);!1!==g&&(g&&(u=g),u.actualize&&(u=u.actualize(e.ownerDocument||t)),y(e,u),w(u))}u=d,h=s}!function(e,t,i){for(;t;){var n=t.nextSibling;(i=c(t))?N(i):M(t,e,!0),t=n}}(e,h,r);var S=a[e.nodeName];S&&S(e,i)}(e,i):a.TEXTAREA(e,i)}T(r);var P,R,O=r,U=O.nodeType,L=f.nodeType;if(!b)if(1===U)1===L?o(r,f)||(x(r),O=function(e,t){for(var i=e.firstChild;i;){var n=i.nextSibling;t.appendChild(i),i=n}return t}(r,(P=f.nodeName,(R=f.namespaceURI)&&"http://www.w3.org/1999/xhtml"!==R?t.createElementNS(R,P):t.createElement(P)))):O=f;else if(3===U||8===U){if(L===U)return O.nodeValue!==f.nodeValue&&(O.nodeValue=f.nodeValue),O;O=f}if(O===f)x(r);else{if(f.isSameNode&&f.isSameNode(O))return;if(E(O,f,b),I)for(var F=0,D=I.length;F<D;F++){var V=C[I[F]];V&&M(V,V.parentNode,!1)}}return!b&&O!==r&&r.parentNode&&(O.actualize&&(O=O.actualize(r.ownerDocument||t)),r.parentNode.replaceChild(O,r)),O},l=function(){function e(t){var i=t.itemCount,n=t.itemSizeGetter,o=t.estimatedItemSize;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._itemSizeGetter=n,this._itemCount=i,this._estimatedItemSize=o,this._itemSizeAndPositionData={},this._lastMeasuredIndex=-1}return e.prototype.getLastMeasuredIndex=function(){return this._lastMeasuredIndex},e.prototype.getSizeAndPositionForIndex=function(e){if(e<0||e>=this._itemCount)throw Error("Requested index "+e+" is outside of range 0.."+this._itemCount);if(e>this._lastMeasuredIndex){for(var t=this.getSizeAndPositionOfLastMeasuredItem(),i=t.offset+t.size,n=this._lastMeasuredIndex+1;n<=e;n++){var o=this._itemSizeGetter({index:n});if(null==o||isNaN(o))throw Error("Invalid size returned for index "+n+" of value "+o);this._itemSizeAndPositionData[n]={offset:i,size:o},i+=o}this._lastMeasuredIndex=e}return this._itemSizeAndPositionData[e]},e.prototype.getSizeAndPositionOfLastMeasuredItem=function(){return this._lastMeasuredIndex>=0?this._itemSizeAndPositionData[this._lastMeasuredIndex]:{offset:0,size:0}},e.prototype.getTotalSize=function(){var e=this.getSizeAndPositionOfLastMeasuredItem();return e.offset+e.size+(this._itemCount-this._lastMeasuredIndex-1)*this._estimatedItemSize},e.prototype.getUpdatedOffsetForIndex=function(e){var t=e.align,i=void 0===t?"start":t,n=e.containerSize,o=e.targetIndex;if(n<=0)return 0;var r=this.getSizeAndPositionForIndex(o),a=r.offset,s=a-n+r.size,d=void 0;switch(i){case"end":d=s;break;case"center":d=a-(n-r.size)/2;break;default:d=a}var f=this.getTotalSize();return Math.max(0,Math.min(f-n,d))},e.prototype.getVisibleRange=function(e){var t=e.containerSize,i=e.offset,n=e.overscanCount;if(0===this.getTotalSize())return{};var o=i+t,r=this._findNearestItem(i),a=r,s=this.getSizeAndPositionForIndex(r);for(i=s.offset+s.size;i<o&&a<this._itemCount-1;)a++,i+=this.getSizeAndPositionForIndex(a).size;return n&&(r=Math.max(0,r-n),a=Math.min(a+n,this._itemCount)),{start:r,stop:a}},e.prototype.resetItem=function(e){this._lastMeasuredIndex=Math.min(this._lastMeasuredIndex,e-1)},e.prototype._binarySearch=function(e){for(var t=e.low,i=e.high,n=e.offset,o=void 0,r=void 0;t<=i;){if(o=t+Math.floor((i-t)/2),(r=this.getSizeAndPositionForIndex(o).offset)===n)return o;r<n?t=o+1:r>n&&(i=o-1)}if(t>0)return t-1},e.prototype._exponentialSearch=function(e){for(var t=e.index,i=e.offset,n=1;t<this._itemCount&&this.getSizeAndPositionForIndex(t).offset<i;)t+=n,n*=2;return this._binarySearch({high:Math.min(t,this._itemCount-1),low:Math.floor(t/2),offset:i})},e.prototype._findNearestItem=function(e){if(isNaN(e))throw Error("Invalid offset "+e+" specified");e=Math.max(0,e);var t=this.getSizeAndPositionOfLastMeasuredItem(),i=Math.max(0,this._lastMeasuredIndex);return t.offset>=e?this._binarySearch({high:i,low:0,offset:e}):this._exponentialSearch({index:i,offset:e})},e}(),u=function(){function e(t,i){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getRowHeight=function(e){var t=e.index,i=n.options.rowHeight;return"function"==typeof i?i(t):Array.isArray(i)?i[t]:i},this.container=t,this.options=i,this.state={},this._initializeSizeAndPositionManager(i.rowCount),this.render=this.render.bind(this),this.handleScroll=this.handleScroll.bind(this),this.componentDidMount()}return e.prototype.componentDidMount=function(){var e=this,t=this.options,i=t.onMount,n=t.initialScrollTop,o=t.initialIndex,r=t.height,a=n||null!=o&&this.getRowOffset(o)||0,s=this.inner=document.createElement("div"),d=this.content=document.createElement("div");s.setAttribute("style","position:relative; overflow:hidden; width:100%; min-height:100%; will-change: transform;"),d.setAttribute("style","position:absolute; top:0; left:0; height:100%; width:100%; overflow:visible;"),s.appendChild(d),this.container.appendChild(s),this.setState({offset:a,height:r},(function(){a&&(e.container.scrollTop=a),e.container.addEventListener("scroll",e.handleScroll),"function"==typeof i&&i()}))},e.prototype._initializeSizeAndPositionManager=function(e){this._sizeAndPositionManager=new l({itemCount:e,itemSizeGetter:this.getRowHeight,estimatedItemSize:this.options.estimatedRowHeight||100})},e.prototype.setState=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments[1];this.state=Object.assign(this.state,t),requestAnimationFrame((function(){e.render(),"function"==typeof i&&i()}))},e.prototype.resize=function(e,t){this.setState({height:e},t)},e.prototype.handleScroll=function(e){var t=this.options.onScroll,i=this.container.scrollTop;this.setState({offset:i}),"function"==typeof t&&t(i,e)},e.prototype.getRowOffset=function(e){return this._sizeAndPositionManager.getSizeAndPositionForIndex(e).offset},e.prototype.scrollToIndex=function(e,t){var i=this.state.height,n=this._sizeAndPositionManager.getUpdatedOffsetForIndex({align:t,containerSize:i,targetIndex:e});this.container.scrollTop=n},e.prototype.setRowCount=function(e){this._initializeSizeAndPositionManager(e),this.render()},e.prototype.onRowsRendered=function(e){var t=this.options.onRowsRendered;"function"==typeof t&&t(e)},e.prototype.destroy=function(){this.container.removeEventListener("scroll",this.handleScroll),this.container.innerHTML=""},e.prototype.render=function(){for(var e=this.options,t=e.overscanCount,i=e.renderRow,n=this.state,o=n.height,r=n.offset,a=void 0===r?0:r,s=this._sizeAndPositionManager.getVisibleRange({containerSize:o,offset:a,overscanCount:t}),d=s.start,l=s.stop,u=document.createDocumentFragment(),h=d;h<=l;h++)u.appendChild(i(h));this.inner.style.height=this._sizeAndPositionManager.getTotalSize()+"px",this.content.style.top=this.getRowOffset(d)+"px",f(this.content,u,{childrenOnly:!0,getNodeKey:function(e){return e.nodeIndex}}),this.onRowsRendered({startIndex:d,stopIndex:l})},e}();return u}(); |
|
1
|
+var bit_virtualized_list=function(){"use strict";var e,t="undefined"==typeof document?void 0:document,i=!!t&&"content"in t.createElement("template"),n=!!t&&t.createRange&&"createContextualFragment"in t.createRange();function o(e,t){var i,n,o=e.nodeName,r=t.nodeName;return o===r||(i=o.charCodeAt(0),n=r.charCodeAt(0),i<=90&&n>=97?o===r.toUpperCase():n<=90&&i>=97&&r===o.toUpperCase())}function r(e,t,i){e[i]!==t[i]&&(e[i]=t[i],e[i]?e.setAttribute(i,""):e.removeAttribute(i))}var a={OPTION:function(e,t){var i=e.parentNode;if(i){var n=i.nodeName.toUpperCase();"OPTGROUP"===n&&(n=(i=i.parentNode)&&i.nodeName.toUpperCase()),"SELECT"!==n||i.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),i.selectedIndex=-1)}r(e,t,"selected")},INPUT:function(e,t){r(e,t,"checked"),r(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var i=t.value;e.value!==i&&(e.value=i);var n=e.firstChild;if(n){var o=n.nodeValue;if(o==i||!i&&o==e.placeholder)return;n.nodeValue=i}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var i,n,o=-1,r=0,a=e.firstChild;a;)if("OPTGROUP"===(n=a.nodeName&&a.nodeName.toUpperCase()))(a=(i=a).firstChild)||(a=i.nextSibling,i=null);else{if("OPTION"===n){if(a.hasAttribute("selected")){o=r;break}r++}!(a=a.nextSibling)&&i&&(a=i.nextSibling,i=null)}e.selectedIndex=o}}};function s(){}function d(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}var l=function(r,l,f){if(f||(f={}),"string"==typeof l)if("#document"===r.nodeName||"HTML"===r.nodeName){var u=l;(l=t.createElement("html")).innerHTML=u}else if("BODY"===r.nodeName){var h=l;(l=t.createElement("html")).innerHTML=h;var c=l.querySelector("body");c&&(l=c)}else p=(p=l).trim(),l=i?function(e){var i=t.createElement("template");return i.innerHTML=e,i.content.childNodes[0]}(p):n?function(i){return e||(e=t.createRange()).selectNode(t.body),e.createContextualFragment(i).childNodes[0]}(p):function(e){var i=t.createElement("body");return i.innerHTML=e,i.childNodes[0]}(p);else 11===l.nodeType&&(l=l.firstElementChild);var p,m=f.getNodeKey||d,v=f.onBeforeNodeAdded||s,g=f.onNodeAdded||s,S=f.onBeforeElUpdated||s,x=f.onElUpdated||s,y=f.onBeforeNodeDiscarded||s,A=f.onNodeDiscarded||s,z=f.onBeforeElChildrenUpdated||s,b=f.skipFromChildren||s,C=f.addChild||function(e,t){return e.appendChild(t)},I=!0===f.childrenOnly,N=Object.create(null),M=[];function _(e){M.push(e)}function T(e,t){if(1===e.nodeType)for(var i=e.firstChild;i;){var n=void 0;t&&(n=m(i))?_(n):(A(i),i.firstChild&&T(i,t)),i=i.nextSibling}}function w(e,t,i){!1!==y(e)&&(t&&t.removeChild(e),A(e),T(e,i))}function E(e){if(1===e.nodeType||11===e.nodeType)for(var t=e.firstChild;t;){var i=m(t);i&&(N[i]=t),E(t),t=t.nextSibling}}function P(e){g(e);for(var t=e.firstChild;t;){var i=t.nextSibling,n=m(t);if(n){var r=N[n];r&&o(t,r)?(t.parentNode.replaceChild(r,t),R(r,t)):P(t)}else P(t);t=i}}function R(e,i,n){var r=m(i);if(r&&delete N[r],!n){var s=S(e,i);if(!1===s)return;if(s instanceof HTMLElement&&E(e=s),function(e,t){var i,n,o,r,a=t.attributes;if(11!==t.nodeType&&11!==e.nodeType){for(var s=a.length-1;s>=0;s--)n=(i=a[s]).name,o=i.namespaceURI,r=i.value,o?(n=i.localName||n,e.getAttributeNS(o,n)!==r&&("xmlns"===i.prefix&&(n=i.name),e.setAttributeNS(o,n,r))):e.getAttribute(n)!==r&&e.setAttribute(n,r);for(var d=e.attributes,l=d.length-1;l>=0;l--)n=(i=d[l]).name,(o=i.namespaceURI)?(n=i.localName||n,t.hasAttributeNS(o,n)||e.removeAttributeNS(o,n)):t.hasAttribute(n)||e.removeAttribute(n)}}(e,i),x(e),!1===z(e,i))return}"TEXTAREA"!==e.nodeName?function(e,i){var n,r,s,d,l,f=b(e,i),u=i.firstChild,h=e.firstChild;e:for(;u;){for(d=u.nextSibling,n=m(u);!f&&h;){if(s=h.nextSibling,u.isSameNode&&u.isSameNode(h)){u=d,h=s;continue e}r=m(h);var c=h.nodeType,p=void 0;if(c===u.nodeType&&(1===c?(n?n!==r&&((l=N[n])?s===l?p=!1:(e.insertBefore(l,h),r?_(r):w(h,e,!0),r=m(h=l)):p=!1):r&&(p=!1),(p=!1!==p&&o(h,u))&&R(h,u)):3!==c&&8!=c||(p=!0,h.nodeValue!==u.nodeValue&&(h.nodeValue=u.nodeValue))),p){u=d,h=s;continue e}r?_(r):w(h,e,!0),h=s}if(n&&(l=N[n])&&o(l,u))f||C(e,l),R(l,u);else{var g=v(u);!1!==g&&(g&&(u=g),u.actualize&&(u=u.actualize(e.ownerDocument||t)),C(e,u),P(u))}u=d,h=s}!function(e,t,i){for(;t;){var n=t.nextSibling;(i=m(t))?_(i):w(t,e,!0),t=n}}(e,h,r);var S=a[e.nodeName];S&&S(e,i)}(e,i):a.TEXTAREA(e,i)}E(r);var O,L,U=r,F=U.nodeType,D=l.nodeType;if(!I)if(1===F)1===D?o(r,l)||(A(r),U=function(e,t){for(var i=e.firstChild;i;){var n=i.nextSibling;t.appendChild(i),i=n}return t}(r,(O=l.nodeName,(L=l.namespaceURI)&&"http://www.w3.org/1999/xhtml"!==L?t.createElementNS(L,O):t.createElement(O)))):U=l;else if(3===F||8===F){if(D===F)return U.nodeValue!==l.nodeValue&&(U.nodeValue=l.nodeValue),U;U=l}if(U===l)A(r);else{if(l.isSameNode&&l.isSameNode(U))return;if(R(U,l,I),M)for(var V=0,H=M.length;V<H;V++){var B=N[M[V]];B&&w(B,B.parentNode,!1)}}return!I&&U!==r&&r.parentNode&&(U.actualize&&(U=U.actualize(r.ownerDocument||t)),r.parentNode.replaceChild(U,r)),U},f=function(){function e(t){var i=t.itemCount,n=t.itemSizeGetter,o=t.estimatedItemSize;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._itemSizeGetter=n,this._itemCount=i,this._estimatedItemSize=o,this._itemSizeAndPositionData={},this._lastMeasuredIndex=-1}return e.prototype.getLastMeasuredIndex=function(){return this._lastMeasuredIndex},e.prototype.getSizeAndPositionForIndex=function(e){if(e<0||e>=this._itemCount)throw Error("Requested index "+e+" is outside of range 0.."+this._itemCount);if(e>this._lastMeasuredIndex){for(var t=this.getSizeAndPositionOfLastMeasuredItem(),i=t.offset+t.size,n=this._lastMeasuredIndex+1;n<=e;n++){var o=this._itemSizeGetter({index:n});if(null==o||isNaN(o))throw Error("Invalid size returned for index "+n+" of value "+o);this._itemSizeAndPositionData[n]={offset:i,size:o},i+=o}this._lastMeasuredIndex=e}return this._itemSizeAndPositionData[e]},e.prototype.getSizeAndPositionOfLastMeasuredItem=function(){return this._lastMeasuredIndex>=0?this._itemSizeAndPositionData[this._lastMeasuredIndex]:{offset:0,size:0}},e.prototype.getTotalSize=function(){var e=this.getSizeAndPositionOfLastMeasuredItem();return e.offset+e.size+(this._itemCount-this._lastMeasuredIndex-1)*this._estimatedItemSize},e.prototype.getUpdatedOffsetForIndex=function(e){var t=e.align,i=void 0===t?"start":t,n=e.containerSize,o=e.targetIndex;if(n<=0)return 0;var r=this.getSizeAndPositionForIndex(o),a=r.offset,s=a-n+r.size,d=void 0;switch(i){case"end":d=s;break;case"center":d=a-(n-r.size)/2;break;default:d=a}var l=this.getTotalSize();return Math.max(0,Math.min(l-n,d))},e.prototype.getVisibleRange=function(e){var t=e.containerSize,i=e.offset,n=e.overscanCount;if(0===this.getTotalSize())return{};var o=i+t,r=this._findNearestItem(i),a=r,s=this.getSizeAndPositionForIndex(r);for(i=s.offset+s.size;i<o&&a<this._itemCount-1;)a++,i+=this.getSizeAndPositionForIndex(a).size;return n&&(r=Math.max(0,r-n),a=Math.min(a+n,this._itemCount)),{start:r,stop:a}},e.prototype.resetItem=function(e){this._lastMeasuredIndex=Math.min(this._lastMeasuredIndex,e-1)},e.prototype._binarySearch=function(e){for(var t=e.low,i=e.high,n=e.offset,o=void 0,r=void 0;t<=i;){if(o=t+Math.floor((i-t)/2),(r=this.getSizeAndPositionForIndex(o).offset)===n)return o;r<n?t=o+1:r>n&&(i=o-1)}if(t>0)return t-1},e.prototype._exponentialSearch=function(e){for(var t=e.index,i=e.offset,n=1;t<this._itemCount&&this.getSizeAndPositionForIndex(t).offset<i;)t+=n,n*=2;return this._binarySearch({high:Math.min(t,this._itemCount-1),low:Math.floor(t/2),offset:i})},e.prototype._findNearestItem=function(e){if(isNaN(e))throw Error("Invalid offset "+e+" specified");e=Math.max(0,e);var t=this.getSizeAndPositionOfLastMeasuredItem(),i=Math.max(0,this._lastMeasuredIndex);return t.offset>=e?this._binarySearch({high:i,low:0,offset:e}):this._exponentialSearch({index:i,offset:e})},e}(),u=function(){function e(t,i){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.getRowHeight=function(e){var t=e.index,i=n.options.rowHeight;return"function"==typeof i?i(t):Array.isArray(i)?i[t]:i},this.container=t,this.options=i,this.state={},this._initializeSizeAndPositionManager(i.rowCount),this.render=this.render.bind(this),this.handleScroll=this.handleScroll.bind(this),this.componentDidMount()}return e.prototype.componentDidMount=function(){var e=this,t=this.options,i=t.onMount,n=t.initialScrollTop,o=t.initialIndex,r=t.height,a=n||null!=o&&this.getRowOffset(o)||0,s=this.inner=document.createElement("div"),d=this.content=document.createElement("div");s.setAttribute("style","position:relative; overflow:hidden; width:100%; min-height:100%; will-change: transform;"),d.setAttribute("style","position:absolute; top:0; left:0; height:100%; width:100%; overflow:visible;"),s.appendChild(d),this.container.appendChild(s),this.setState({offset:a,height:r},function(){a&&(e.container.scrollTop=a),e.container.addEventListener("scroll",e.handleScroll),"function"==typeof i&&i()})},e.prototype._initializeSizeAndPositionManager=function(e){this._sizeAndPositionManager=new f({itemCount:e,itemSizeGetter:this.getRowHeight,estimatedItemSize:this.options.estimatedRowHeight||100})},e.prototype.setState=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments[1];this.state=Object.assign(this.state,t),requestAnimationFrame(function(){e.render(),"function"==typeof i&&i()})},e.prototype.resize=function(e,t){this.setState({height:e},t)},e.prototype.handleScroll=function(e){var t=this.options.onScroll,i=this.container.scrollTop;this.setState({offset:i}),"function"==typeof t&&t(i,e)},e.prototype.getRowOffset=function(e){return this._sizeAndPositionManager.getSizeAndPositionForIndex(e).offset},e.prototype.scrollToIndex=function(e,t){var i=this.state.height,n=this._sizeAndPositionManager.getUpdatedOffsetForIndex({align:t,containerSize:i,targetIndex:e});this.container.scrollTop=n},e.prototype.setRowCount=function(e){this._initializeSizeAndPositionManager(e),this.render()},e.prototype.onRowsRendered=function(e){var t=this.options.onRowsRendered;"function"==typeof t&&t(e)},e.prototype.destroy=function(){this.container.removeEventListener("scroll",this.handleScroll),this.container.innerHTML=""},e.prototype.render=function(){for(var e=this.options,t=e.overscanCount,i=e.renderRow,n=this.state,o=n.height,r=n.offset,a=void 0===r?0:r,s=this._sizeAndPositionManager.getVisibleRange({containerSize:o,offset:a,overscanCount:t}),d=s.start,f=s.stop,u=document.createDocumentFragment(),h=d;h<=f;h++)u.appendChild(i(h));this.inner.style.height=this._sizeAndPositionManager.getTotalSize()+"px",this.content.style.top=this.getRowOffset(d)+"px",l(this.content,u,{childrenOnly:!0,getNodeKey:function(e){return e.nodeIndex}}),this.onRowsRendered({startIndex:d,stopIndex:f})},e}();return u}(); |