diff --git a/dist/vue-virtual-scroller.esm.js b/dist/vue-virtual-scroller.esm.js index 33e441d9..41356695 100644 --- a/dist/vue-virtual-scroller.esm.js +++ b/dist/vue-virtual-scroller.esm.js @@ -706,79 +706,79 @@ var script = { } }; -function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) { - if (typeof shadowMode !== 'boolean') { - createInjectorSSR = createInjector; - createInjector = shadowMode; - shadowMode = false; - } - // Vue.extend constructor export interop. - const options = typeof script === 'function' ? script.options : script; - // render functions - if (template && template.render) { - options.render = template.render; - options.staticRenderFns = template.staticRenderFns; - options._compiled = true; - // functional template - if (isFunctionalTemplate) { - options.functional = true; - } - } - // scopedId - if (scopeId) { - options._scopeId = scopeId; - } - let hook; - if (moduleIdentifier) { - // server build - hook = function (context) { - // 2.3 injection - context = - context || // cached call - (this.$vnode && this.$vnode.ssrContext) || // stateful - (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional - // 2.2 with runInNewContext: true - if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { - context = __VUE_SSR_CONTEXT__; - } - // inject component styles - if (style) { - style.call(this, createInjectorSSR(context)); - } - // register component module identifier for async chunk inference - if (context && context._registeredComponents) { - context._registeredComponents.add(moduleIdentifier); - } - }; - // used by ssr in case component is cached and beforeCreate - // never gets called - options._ssrRegister = hook; - } - else if (style) { - hook = shadowMode - ? function (context) { - style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot)); - } - : function (context) { - style.call(this, createInjector(context)); - }; - } - if (hook) { - if (options.functional) { - // register for functional component in vue file - const originalRender = options.render; - options.render = function renderWithStyleInjection(h, context) { - hook.call(context); - return originalRender(h, context); - }; - } - else { - // inject component registration as beforeCreate hook - const existing = options.beforeCreate; - options.beforeCreate = existing ? [].concat(existing, hook) : [hook]; - } - } - return script; +function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) { + if (typeof shadowMode !== 'boolean') { + createInjectorSSR = createInjector; + createInjector = shadowMode; + shadowMode = false; + } + // Vue.extend constructor export interop. + const options = typeof script === 'function' ? script.options : script; + // render functions + if (template && template.render) { + options.render = template.render; + options.staticRenderFns = template.staticRenderFns; + options._compiled = true; + // functional template + if (isFunctionalTemplate) { + options.functional = true; + } + } + // scopedId + if (scopeId) { + options._scopeId = scopeId; + } + let hook; + if (moduleIdentifier) { + // server build + hook = function (context) { + // 2.3 injection + context = + context || // cached call + (this.$vnode && this.$vnode.ssrContext) || // stateful + (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional + // 2.2 with runInNewContext: true + if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { + context = __VUE_SSR_CONTEXT__; + } + // inject component styles + if (style) { + style.call(this, createInjectorSSR(context)); + } + // register component module identifier for async chunk inference + if (context && context._registeredComponents) { + context._registeredComponents.add(moduleIdentifier); + } + }; + // used by ssr in case component is cached and beforeCreate + // never gets called + options._ssrRegister = hook; + } + else if (style) { + hook = shadowMode + ? function (context) { + style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot)); + } + : function (context) { + style.call(this, createInjector(context)); + }; + } + if (hook) { + if (options.functional) { + // register for functional component in vue file + const originalRender = options.render; + options.render = function renderWithStyleInjection(h, context) { + hook.call(context); + return originalRender(h, context); + }; + } + else { + // inject component registration as beforeCreate hook + const existing = options.beforeCreate; + options.beforeCreate = existing ? [].concat(existing, hook) : [hook]; + } + } + return script; } /* script */ diff --git a/dist/vue-virtual-scroller.min.js b/dist/vue-virtual-scroller.min.js index ba5df9d2..456b023c 100644 --- a/dist/vue-virtual-scroller.min.js +++ b/dist/vue-virtual-scroller.min.js @@ -1,2 +1,4 @@ -var VueVirtualScroller=function(e,t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var i={itemsLimit:1e3};function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function o(e){for(var t=1;te.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,r,s=!0,o=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,r=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw r}}}}var c=void 0;function d(){d.init||(d.init=!0,c=-1!==function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return parseInt(e.substring(t+5,e.indexOf(".",t)),10);if(e.indexOf("Trident/")>0){var i=e.indexOf("rv:");return parseInt(e.substring(i+3,e.indexOf(".",i)),10)}var n=e.indexOf("Edge/");return n>0?parseInt(e.substring(n+5,e.indexOf(".",n)),10):-1}())}var u={render:function(){var e=this.$createElement;return(this._self._c||e)("div",{staticClass:"resize-observer",attrs:{tabindex:"-1"}})},staticRenderFns:[],_scopeId:"data-v-b329ee4c",name:"resize-observer",methods:{compareAndNotify:function(){this._w===this.$el.offsetWidth&&this._h===this.$el.offsetHeight||(this._w=this.$el.offsetWidth,this._h=this.$el.offsetHeight,this.$emit("notify"))},addResizeHandlers:function(){this._resizeObject.contentDocument.defaultView.addEventListener("resize",this.compareAndNotify),this.compareAndNotify()},removeResizeHandlers:function(){this._resizeObject&&this._resizeObject.onload&&(!c&&this._resizeObject.contentDocument&&this._resizeObject.contentDocument.defaultView.removeEventListener("resize",this.compareAndNotify),delete this._resizeObject.onload)}},mounted:function(){var e=this;d(),this.$nextTick((function(){e._w=e.$el.offsetWidth,e._h=e.$el.offsetHeight}));var t=document.createElement("object");this._resizeObject=t,t.setAttribute("aria-hidden","true"),t.setAttribute("tabindex",-1),t.onload=this.addResizeHandlers,t.type="text/html",c&&this.$el.appendChild(t),t.data="about:blank",c||this.$el.appendChild(t)},beforeDestroy:function(){this.removeResizeHandlers()}};var h={version:"0.4.5",install:function(e){e.component("resize-observer",u),e.component("ResizeObserver",u)}},f=null;function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:{},o=function(o){for(var l=arguments.length,a=new Array(l>1?l-1:0),c=1;c1){var n=e.find((function(e){return e.isIntersecting}));n&&(t=n)}if(i.callback){var r=t.isIntersecting&&t.intersectionRatio>=i.threshold;if(r===i.oldResult)return;i.oldResult=r,i.callback(r,t)}}),this.options.intersection),t.context.$nextTick((function(){i.observer&&i.observer.observe(i.el)}))}}},{key:"destroyObserver",value:function(){this.observer&&(this.observer.disconnect(),this.observer=null),this.callback&&this.callback._clear&&(this.callback._clear(),this.callback=null)}},{key:"threshold",get:function(){return this.options.intersection&&this.options.intersection.threshold||0}}])&&p(t.prototype,i),n&&p(t,n),e}();function b(e,t,i){var n=t.value;if(n)if("undefined"==typeof IntersectionObserver)console.warn("[vue-observe-visibility] IntersectionObserver API is not available in your browser. Please install this polyfill: https://github.com/w3c/IntersectionObserver/tree/master/polyfill");else{var r=new y(e,n,i);e._vue_visibilityState=r}}function _(e){var t=e._vue_visibilityState;t&&(t.destroyObserver(),delete e._vue_visibilityState)}var g={bind:b,update:function(e,t,i){var n=t.value;if(!function e(t,i){if(t===i)return!0;if("object"===v(t)){for(var n in t)if(!e(t[n],i[n]))return!1;return!0}return!1}(n,t.oldValue)){var r=e._vue_visibilityState;n?r?r.createObserver(n,i):b(e,{value:n},i):_(e)}},unbind:_};var $={version:"0.4.6",install:function(e){e.directive("observe-visibility",g)}},S=null;"undefined"!=typeof window?S=window.Vue:"undefined"!=typeof global&&(S=global.Vue),S&&S.use($);var z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var w=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t,i;t=z,i=function(){var e=/(auto|scroll)/,t=function(e,i){return null===e.parentNode?i:t(e.parentNode,i.concat([e]))},i=function(e,t){return getComputedStyle(e,null).getPropertyValue(t)},n=function(t){return e.test(function(e){return i(e,"overflow")+i(e,"overflow-y")+i(e,"overflow-x")}(t))};return function(e){if(e instanceof HTMLElement||e instanceof SVGElement){for(var i=t(e.parentNode,[]),r=0;r1&&void 0!==arguments[1]&&arguments[1],i=this.$_unusedViews,n=e.nr.type,r=i.get(n);r||(r=[],i.set(n,r)),r.push(e),t||(e.nr.used=!1,e.position=-9999,this.$_views.delete(e.nr.key))},handleResize:function(){this.$emit("resize"),this.ready&&this.updateVisibleItems(!1)},handleScroll:function(e){var t=this;this.$_scrollDirty||(this.$_scrollDirty=!0,requestAnimationFrame((function(){t.$_scrollDirty=!1,t.updateVisibleItems(!1,!0).continuous||(clearTimeout(t.$_refreshTimout),t.$_refreshTimout=setTimeout(t.handleScroll,100))})))},handleVisibilityChange:function(e,t){var i=this;this.ready&&(e||0!==t.boundingClientRect.width||0!==t.boundingClientRect.height?(this.$emit("visible"),requestAnimationFrame((function(){i.updateVisibleItems(!1)}))):this.$emit("hidden"))},updateVisibleItems:function(e){var t,n,r,s,o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=this.itemSize,a=this.$_computedMinItemSize,c=this.typeField,d=this.simpleArray?null:this.keyField,u=this.items,h=u.length,f=this.sizes,v=this.$_views,p=this.$_unusedViews,m=this.pool;if(h)if(this.$_prerender)t=0,n=this.prerender,r=null;else{var y=this.getScroll();if(o){var b=y.start-this.$_lastUpdateScrollPosition;if(b<0&&(b=-b),null===l&&by.start&&(S=z),z=~~(($+S)/2)}while(z!==g);for(z<0&&(z=0),t=z,r=f[h-1].accumulator,n=z;nh&&(n=h)}else(t=~~(y.start/l))<0&&(t=0),(n=Math.ceil(y.end/l))>h&&(n=h),r=h*l}else t=n=r=0;n-t>i.itemsLimit&&this.itemsLimitError(),this.totalSize=r;var w=t<=this.$_endIndex&&n>=this.$_startIndex;if(this.$_continuous!==w){if(w){v.clear(),p.clear();for(var O=0,x=m.length;O=n)&&this.unuseView(s));for(var D,R,T,P,k=w?null:new Map,A=t;A=T.length)&&(s=this.addView(m,A,D,E,R),this.unuseView(s,!0),T=p.get(R)),(s=T[P]).item=D,s.nr.used=!0,s.nr.index=A,s.nr.key=E,s.nr.type=R,k.set(R,P+1),P++),v.set(E,s)),s.position=null===l?f[A-1].accumulator:A*l):s&&this.unuseView(s)}return this.$_startIndex=t,this.$_endIndex=n,this.emitUpdate&&this.$emit("update",t,n),clearTimeout(this.$_sortTimer),this.$_sortTimer=setTimeout(this.sortViews,300),{continuous:w}},getListenerTarget:function(){var e=w(this.$el);return!window.document||e!==window.document.documentElement&&e!==window.document.body||(e=window),e},getScroll:function(){var e,t=this.$el,i="vertical"===this.direction;if(this.pageMode){var n=t.getBoundingClientRect(),r=i?n.height:n.width,s=-(i?n.top:n.left),o=i?window.innerHeight:window.innerWidth;s<0&&(o+=s,s=0),s+o>r&&(o=r-s),e={start:s,end:s+o}}else e=i?{start:t.scrollTop,end:t.scrollTop+t.clientHeight}:{start:t.scrollLeft,end:t.scrollLeft+t.clientWidth};return e},applyPageMode:function(){this.pageMode?this.addListeners():this.removeListeners()},addListeners:function(){this.listenerTarget=this.getListenerTarget(),this.listenerTarget.addEventListener("scroll",this.handleScroll,!!I&&{passive:!0}),this.listenerTarget.addEventListener("resize",this.handleResize)},removeListeners:function(){this.listenerTarget&&(this.listenerTarget.removeEventListener("scroll",this.handleScroll),this.listenerTarget.removeEventListener("resize",this.handleResize),this.listenerTarget=null)},scrollToItem:function(e){var t;t=null===this.itemSize?e>0?this.sizes[e-1].accumulator:0:e*this.itemSize,this.scrollToPosition(t)},scrollToPosition:function(e){"vertical"===this.direction?this.$el.scrollTop=e:this.$el.scrollLeft=e},itemsLimitError:function(){var e=this;throw setTimeout((function(){console.log("It seems the scroller element isn't scrolling, so it tries to render all the items at once.","Scroller:",e.$el),console.log("Make sure the scroller has a fixed height (or width) and 'overflow-y' (or 'overflow-x') set to 'auto' so it can scroll correctly and only render the items visible in the scroll viewport.")})),new Error("Rendered items limit reached")},sortViews:function(){this.pool.sort((function(e,t){return e.nr.index-t.nr.index}))}}};var P=function(){var e,t,i=this,n=i.$createElement,r=i._self._c||n;return r("div",{directives:[{name:"observe-visibility",rawName:"v-observe-visibility",value:i.handleVisibilityChange,expression:"handleVisibilityChange"}],staticClass:"vue-recycle-scroller",class:(e={ready:i.ready,"page-mode":i.pageMode},e["direction-"+i.direction]=!0,e),on:{"&scroll":function(e){return i.handleScroll(e)}}},[i.$slots.before?r("div",{staticClass:"vue-recycle-scroller__slot"},[i._t("before")],2):i._e(),i._v(" "),r("div",{ref:"wrapper",staticClass:"vue-recycle-scroller__item-wrapper",style:(t={},t["vertical"===i.direction?"minHeight":"minWidth"]=i.totalSize+"px",t)},i._l(i.pool,(function(e){return r("div",{key:e.nr.id,staticClass:"vue-recycle-scroller__item-view",class:{hover:i.hoverKey===e.nr.key},style:i.ready?{transform:"translate"+("vertical"===i.direction?"Y":"X")+"("+e.position+"px)"}:null,on:{mouseenter:function(t){i.hoverKey=e.nr.key},mouseleave:function(e){i.hoverKey=null}}},[i._t("default",null,{item:e.item,index:e.nr.index,active:e.nr.used})],2)})),0),i._v(" "),i.$slots.after?r("div",{staticClass:"vue-recycle-scroller__slot"},[i._t("after")],2):i._e(),i._v(" "),r("ResizeObserver",{on:{notify:i.handleResize}})],1)};P._withStripped=!0;const k=R({render:P,staticRenderFns:[]},void 0,T,void 0,!1,void 0,!1,void 0,void 0,void 0);const A={name:"DynamicScroller",components:{RecycleScroller:k},inheritAttrs:!1,provide:function(){return"undefined"!=typeof ResizeObserver&&(this.$_resizeObserver=new ResizeObserver((function(e){var t,i=a(e);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n.target){var r=new CustomEvent("resize",{detail:{contentRect:n.contentRect}});n.target.dispatchEvent(r)}}}catch(e){i.e(e)}finally{i.f()}}))),{vscrollData:this.vscrollData,vscrollParent:this,vscrollResizeObserver:this.$_resizeObserver}},props:o({},O,{minItemSize:{type:[Number,String],required:!0}}),data:function(){return{vscrollData:{active:!0,sizes:{},validSizes:{},keyField:this.keyField,simpleArray:!1}}},computed:{simpleArray:x,itemsWithSize:function(){for(var e=[],t=this.items,i=this.keyField,n=this.simpleArray,r=this.vscrollData.sizes,s=0;s0&&void 0!==arguments[0])||arguments[0];(e||this.simpleArray)&&(this.vscrollData.validSizes={}),this.$emit("vscroll:update",{force:!0})},scrollToItem:function(e){var t=this.$refs.scroller;t&&t.scrollToItem(e)},getItemSize:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=this.simpleArray?null!=t?t:this.items.indexOf(e):e[this.keyField];return this.vscrollData.sizes[i]||0},scrollToBottom:function(){var e=this;if(!this.$_scrollingToBottom){this.$_scrollingToBottom=!0;var t=this.$el;this.$nextTick((function(){t.scrollTop=t.scrollHeight+5e3;requestAnimationFrame((function i(){t.scrollTop=t.scrollHeight+5e3,requestAnimationFrame((function(){t.scrollTop=t.scrollHeight+5e3,0===e.$_undefinedSizes?e.$_scrollingToBottom=!1:requestAnimationFrame(i)}))}))}))}}}};var E=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("RecycleScroller",e._g(e._b({ref:"scroller",attrs:{items:e.itemsWithSize,"min-item-size":e.minItemSize,direction:e.direction,"key-field":"id"},on:{resize:e.onScrollerResize,visible:e.onScrollerVisible},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.item,n=t.index,r=t.active;return[e._t("default",null,null,{item:i.item,index:n,active:r,itemWithSize:i})]}}],null,!0)},"RecycleScroller",e.$attrs,!1),e.listeners),[e._v(" "),i("template",{slot:"before"},[e._t("before")],2),e._v(" "),i("template",{slot:"after"},[e._t("after")],2)],2)};E._withStripped=!0;const j=R({render:E,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0);const U=R({},void 0,{name:"DynamicScrollerItem",inject:["vscrollData","vscrollParent","vscrollResizeObserver"],props:{item:{required:!0},watchData:{type:Boolean,default:!1},active:{type:Boolean,required:!0},index:{type:Number,default:void 0},sizeDependencies:{type:[Array,Object],default:null},emitResize:{type:Boolean,default:!1},tag:{type:String,default:"div"}},computed:{id:function(){return this.vscrollData.simpleArray?this.index:this.item[this.vscrollData.keyField]},size:function(){return this.vscrollData.validSizes[this.id]&&this.vscrollData.sizes[this.id]||0},finalActive:function(){return this.active&&this.vscrollData.active}},watch:{watchData:"updateWatchData",id:function(){this.size||this.onDataUpdate()},finalActive:function(e){this.size||(e?this.vscrollParent.$_undefinedMap[this.id]||(this.vscrollParent.$_undefinedSizes++,this.vscrollParent.$_undefinedMap[this.id]=!0):this.vscrollParent.$_undefinedMap[this.id]&&(this.vscrollParent.$_undefinedSizes--,this.vscrollParent.$_undefinedMap[this.id]=!1)),this.vscrollResizeObserver?e?this.observeSize():this.unobserveSize():e&&this.$_pendingVScrollUpdate===this.id&&this.updateSize()}},created:function(){var e=this;if(!this.$isServer&&(this.$_forceNextVScrollUpdate=null,this.updateWatchData(),!this.vscrollResizeObserver)){var t=function(t){e.$watch((function(){return e.sizeDependencies[t]}),e.onDataUpdate)};for(var i in this.sizeDependencies)t(i);this.vscrollParent.$on("vscroll:update",this.onVscrollUpdate),this.vscrollParent.$on("vscroll:update-size",this.onVscrollUpdateSize)}},mounted:function(){this.vscrollData.active&&(this.updateSize(),this.observeSize())},beforeDestroy:function(){this.vscrollParent.$off("vscroll:update",this.onVscrollUpdate),this.vscrollParent.$off("vscroll:update-size",this.onVscrollUpdateSize),this.unobserveSize()},methods:{updateSize:function(){this.finalActive?this.$_pendingSizeUpdate!==this.id&&(this.$_pendingSizeUpdate=this.id,this.$_forceNextVScrollUpdate=null,this.$_pendingVScrollUpdate=null,this.computeSize(this.id)):this.$_forceNextVScrollUpdate=this.id},updateWatchData:function(){var e=this;this.watchData?this.$_watchData=this.$watch("data",(function(){e.onDataUpdate()}),{deep:!0}):this.$_watchData&&(this.$_watchData(),this.$_watchData=null)},onVscrollUpdate:function(e){var t=e.force;!this.finalActive&&t&&(this.$_pendingVScrollUpdate=this.id),this.$_forceNextVScrollUpdate!==this.id&&!t&&this.size||this.updateSize()},onDataUpdate:function(){this.updateSize()},computeSize:function(e){var t=this;this.$nextTick((function(){if(t.id===e){var i=t.$el.offsetWidth,n=t.$el.offsetHeight;t.applySize(i,n)}t.$_pendingSizeUpdate=null}))},applySize:function(e,t){var i=Math.round("vertical"===this.vscrollParent.direction?t:e);i&&this.size!==i&&(this.vscrollParent.$_undefinedMap[this.id]&&(this.vscrollParent.$_undefinedSizes--,this.vscrollParent.$_undefinedMap[this.id]=void 0),this.$set(this.vscrollData.sizes,this.id,i),this.$set(this.vscrollData.validSizes,this.id,!0),this.emitResize&&this.$emit("resize",this.id))},observeSize:function(){this.vscrollResizeObserver&&(this.vscrollResizeObserver.observe(this.$el.parentNode),this.$el.parentNode.addEventListener("resize",this.onResize))},unobserveSize:function(){this.vscrollResizeObserver&&(this.vscrollResizeObserver.unobserve(this.$el.parentNode),this.$el.parentNode.removeEventListener("resize",this.onResize))},onResize:function(e){var t=e.detail.contentRect,i=t.width,n=t.height;this.applySize(i,n)}},render:function(e){return e(this.tag,this.$slots.default)}},void 0,void 0,void 0,!1,void 0,void 0,void 0);var C={version:"1.0.10",install:function(e,t){var n=Object.assign({},{installComponents:!0,componentsPrefix:""},t);for(var r in n)void 0!==n[r]&&(i[r]=n[r]);n.installComponents&&function(e,t){e.component("".concat(t,"recycle-scroller"),k),e.component("".concat(t,"RecycleScroller"),k),e.component("".concat(t,"dynamic-scroller"),j),e.component("".concat(t,"DynamicScroller"),j),e.component("".concat(t,"dynamic-scroller-item"),U),e.component("".concat(t,"DynamicScrollerItem"),U)}(e,n.componentsPrefix)}},M=null;return"undefined"!=typeof window?M=window.Vue:"undefined"!=typeof global&&(M=global.Vue),M&&M.use(C),e.DynamicScroller=j,e.DynamicScrollerItem=U,e.IdState=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.idProp,n=void 0===i?function(e){return e.item.id}:i,r={},s=new t({data:function(){return{store:r}}});return{data:function(){return{idState:null}},created:function(){var e=this;this.$_id=null,this.$_getId="function"==typeof n?function(){return n.call(e,e)}:function(){return e[n]},this.$watch(this.$_getId,{handler:function(e){var t=this;this.$nextTick((function(){t.$_id=e}))},immediate:!0}),this.$_updateIdState()},beforeUpdate:function(){this.$_updateIdState()},methods:{$_idStateInit:function(e){var t=this.$options.idState;if("function"==typeof t){var i=t.call(this,this);return s.$set(r,e,i),this.$_id=e,i}throw new Error("[mixin IdState] Missing `idState` function on component definition.")},$_updateIdState:function(){var e=this.$_getId();null==e&&console.warn("No id found for IdState with idProp: '".concat(n,"'.")),e!==this.$_id&&(r[e]||this.$_idStateInit(e),this.idState=r[e])}}}},e.RecycleScroller=k,e.default=C,e}({},Vue); +var VueVirtualScroller=function(e,t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var i={itemsLimit:1e3};function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function o(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function s(e){for(var t=1;te.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,r,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,r=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw r}}}}var c=void 0;function d(){d.init||(d.init=!0,c=-1!==function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return parseInt(e.substring(t+5,e.indexOf(".",t)),10);if(e.indexOf("Trident/")>0){var i=e.indexOf("rv:");return parseInt(e.substring(i+3,e.indexOf(".",i)),10)}var n=e.indexOf("Edge/");return n>0?parseInt(e.substring(n+5,e.indexOf(".",n)),10):-1}())}var u={render:function(){var e=this.$createElement;return(this._self._c||e)("div",{staticClass:"resize-observer",attrs:{tabindex:"-1"}})},staticRenderFns:[],_scopeId:"data-v-b329ee4c",name:"resize-observer",methods:{compareAndNotify:function(){this._w===this.$el.offsetWidth&&this._h===this.$el.offsetHeight||(this._w=this.$el.offsetWidth,this._h=this.$el.offsetHeight,this.$emit("notify"))},addResizeHandlers:function(){this._resizeObject.contentDocument.defaultView.addEventListener("resize",this.compareAndNotify),this.compareAndNotify()},removeResizeHandlers:function(){this._resizeObject&&this._resizeObject.onload&&(!c&&this._resizeObject.contentDocument&&this._resizeObject.contentDocument.defaultView.removeEventListener("resize",this.compareAndNotify),delete this._resizeObject.onload)}},mounted:function(){var e=this;d(),this.$nextTick((function(){e._w=e.$el.offsetWidth,e._h=e.$el.offsetHeight}));var t=document.createElement("object");this._resizeObject=t,t.setAttribute("aria-hidden","true"),t.setAttribute("tabindex",-1),t.onload=this.advar VueVirtualScroller=function(e,t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var i={itemsLimit:1e3};function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function o(e){for(var t=1;te.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,r,s=!0,o=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,r=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw r}}}}var c=void 0;function d(){d.init||(d.init=!0,c=-1!==function(){var e=window.navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return parseInt(e.substring(t+5,e.indexOf(".",t)),10);if(e.indexOf("Trident/")>0){var i=e.indexOf("rv:");return parseInt(e.substring(i+3,e.indexOf(".",i)),10)}var n=e.indexOf("Edge/");return n>0?parseInt(e.substring(n+5,e.indexOf(".",n)),10):-1}())}var u={render:function(){var e=this.$createElement;return(this._self._c||e)("div",{staticClass:"resize-observer",attrs:{tabindex:"-1"}})},staticRenderFns:[],_scopeId:"data-v-b329ee4c",name:"resize-observer",methods:{compareAndNotify:function(){this._w===this.$el.offsetWidth&&this._h===this.$el.offsetHeight||(this._w=this.$el.offsetWidth,this._h=this.$el.offsetHeight,this.$emit("notify"))},addResizeHandlers:function(){this._resizeObject.contentDocument.defaultView.addEventListener("resize",this.compareAndNotify),this.compareAndNotify()},removeResizeHandlers:function(){this._resizeObject&&this._resizeObject.onload&&(!c&&this._resizeObject.contentDocument&&this._resizeObject.contentDocument.defaultView.removeEventListener("resize",this.compareAndNotify),delete this._resizeObject.onload)}},mounted:function(){var e=this;d(),this.$nextTick((function(){e._w=e.$el.offsetWidth,e._h=e.$el.offsetHeight}));var t=document.createElement("object");this._resizeObject=t,t.setAttribute("aria-hidden","true"),t.setAttribute("tabindex",-1),t.onload=this.addResizeHandlers,t.type="text/html",c&&this.$el.appendChild(t),t.data="about:blank",c||this.$el.appendChild(t)},beforeDestroy:function(){this.removeResizeHandlers()}};var h={version:"0.4.5",install:function(e){e.component("resize-observer",u),e.component("ResizeObserver",u)}},f=null;function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:{},o=function(o){for(var l=arguments.length,a=new Array(l>1?l-1:0),c=1;c1){var n=e.find((function(e){return e.isIntersecting}));n&&(t=n)}if(i.callback){var r=t.isIntersecting&&t.intersectionRatio>=i.threshold;if(r===i.oldResult)return;i.oldResult=r,i.callback(r,t)}}),this.options.intersection),t.context.$nextTick((function(){i.observer&&i.observer.observe(i.el)}))}}},{key:"destroyObserver",value:function(){this.observer&&(this.observer.disconnect(),this.observer=null),this.callback&&this.callback._clear&&(this.callback._clear(),this.callback=null)}},{key:"threshold",get:function(){return this.options.intersection&&this.options.intersection.threshold||0}}])&&p(t.prototype,i),n&&p(t,n),e}();function b(e,t,i){var n=t.value;if(n)if("undefined"==typeof IntersectionObserver)console.warn("[vue-observe-visibility] IntersectionObserver API is not available in your browser. Please install this polyfill: https://github.com/w3c/IntersectionObserver/tree/master/polyfill");else{var r=new y(e,n,i);e._vue_visibilityState=r}}function _(e){var t=e._vue_visibilityState;t&&(t.destroyObserver(),delete e._vue_visibilityState)}var g={bind:b,update:function(e,t,i){var n=t.value;if(!function e(t,i){if(t===i)return!0;if("object"===v(t)){for(var n in t)if(!e(t[n],i[n]))return!1;return!0}return!1}(n,t.oldValue)){var r=e._vue_visibilityState;n?r?r.createObserver(n,i):b(e,{value:n},i):_(e)}},unbind:_};var $={version:"0.4.6",install:function(e){e.directive("observe-visibility",g)}},S=null;"undefined"!=typeof window?S=window.Vue:"undefined"!=typeof global&&(S=global.Vue),S&&S.use($);var z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var w=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t,i;t=z,i=function(){var e=/(auto|scroll)/,t=function(e,i){return null===e.parentNode?i:t(e.parentNode,i.concat([e]))},i=function(e,t){return getComputedStyle(e,null).getPropertyValue(t)},n=function(t){return e.test(function(e){return i(e,"overflow")+i(e,"overflow-y")+i(e,"overflow-x")}(t))};return function(e){if(e instanceof HTMLElement||e instanceof SVGElement){for(var i=t(e.parentNode,[]),r=0;r1&&void 0!==arguments[1]&&arguments[1],i=this.$_unusedViews,n=e.nr.type,r=i.get(n);r||(r=[],i.set(n,r)),r.push(e),t||(e.nr.used=!1,e.position=-9999,this.$_views.delete(e.nr.key))},handleResize:function(){this.$emit("resize"),this.ready&&this.updateVisibleItems(!1)},handleScroll:function(e){var t=this;this.$_scrollDirty||(this.$_scrollDirty=!0,requestAnimationFrame((function(){t.$_scrollDirty=!1,t.updateVisibleItems(!1,!0).continuous||(clearTimeout(t.$_refreshTimout),t.$_refreshTimout=setTimeout(t.handleScroll,100))})))},handleVisibilityChange:function(e,t){var i=this;this.ready&&(e||0!==t.boundingClientRect.width||0!==t.boundingClientRect.height?(this.$emit("visible"),requestAnimationFrame((function(){i.updateVisibleItems(!1)}))):this.$emit("hidden"))},updateVisibleItems:function(e){var t,n,r,s,o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=this.itemSize,a=this.$_computedMinItemSize,c=this.typeField,d=this.simpleArray?null:this.keyField,u=this.items,h=u.length,f=this.sizes,v=this.$_views,p=this.$_unusedViews,m=this.pool;if(h)if(this.$_prerender)t=0,n=this.prerender,r=null;else{var y=this.getScroll();if(o){var b=y.start-this.$_lastUpdateScrollPosition;if(b<0&&(b=-b),null===l&&by.start&&(S=z),z=~~(($+S)/2)}while(z!==g);for(z<0&&(z=0),t=z,r=f[h-1].accumulator,n=z;nh&&(n=h)}else(t=~~(y.start/l))<0&&(t=0),(n=Math.ceil(y.end/l))>h&&(n=h),r=h*l}else t=n=r=0;n-t>i.itemsLimit&&this.itemsLimitError(),this.totalSize=r;var w=t<=this.$_endIndex&&n>=this.$_startIndex;if(this.$_continuous!==w){if(w){v.clear(),p.clear();for(var O=0,x=m.length;O=n)&&this.unuseView(s));for(var D,R,T,P,k=w?null:new Map,A=t;A=T.length)&&(s=this.addView(m,A,D,E,R),this.unuseView(s,!0),T=p.get(R)),(s=T[P]).item=D,s.nr.used=!0,s.nr.index=A,s.nr.key=E,s.nr.type=R,k.set(R,P+1),P++),v.set(E,s)),s.position=null===l?f[A-1].accumulator:A*l):s&&this.unuseView(s)}return this.$_startIndex=t,this.$_endIndex=n,this.emitUpdate&&this.$emit("update",t,n),clearTimeout(this.$_sortTimer),this.$_sortTimer=setTimeout(this.sortViews,300),{continuous:w}},getListenerTarget:function(){var e=w(this.$el);return!window.document||e!==window.document.documentElement&&e!==window.document.body||(e=window),e},getScroll:function(){var e,t=this.$el,i="vertical"===this.direction;if(this.pageMode){var n=t.getBoundingClientRect(),r=i?n.height:n.width,s=-(i?n.top:n.left),o=i?window.innerHeight:window.innerWidth;s<0&&(o+=s,s=0),s+o>r&&(o=r-s),e={start:s,end:s+o}}else e=i?{start:t.scrollTop,end:t.scrollTop+t.clientHeight}:{start:t.scrollLeft,end:t.scrollLeft+t.clientWidth};return e},applyPageMode:function(){this.pageMode?this.addListeners():this.removeListeners()},addListeners:function(){this.listenerTarget=this.getListenerTarget(),this.listenerTarget.addEventListener("scroll",this.handleScroll,!!I&&{passive:!0}),this.listenerTarget.addEventListener("resize",this.handleResize)},removeListeners:function(){this.listenerTarget&&(this.listenerTarget.removeEventListener("scroll",this.handleScroll),this.listenerTarget.removeEventListener("resize",this.handleResize),this.listenerTarget=null)},scrollToItem:function(e){var t;t=null===this.itemSize?e>0?this.sizes[e-1].accumulator:0:e*this.itemSize,this.scrollToPosition(t)},scrollToPosition:function(e){"vertical"===this.direction?this.$el.scrollTop=e:this.$el.scrollLeft=e},itemsLimitError:function(){var e=this;throw setTimeout((function(){console.log("It seems the scroller element isn't scrolling, so it tries to render all the items at once.","Scroller:",e.$el),console.log("Make sure the scroller has a fixed height (or width) and 'overflow-y' (or 'overflow-x') set to 'auto' so it can scroll correctly and only render the items visible in the scroll viewport.")})),new Error("Rendered items limit reached")},sortViews:function(){this.pool.sort((function(e,t){return e.nr.index-t.nr.index}))}}};var P=function(){var e,t,i=this,n=i.$createElement,r=i._self._c||n;return r("div",{directives:[{name:"observe-visibility",rawName:"v-observe-visibility",value:i.handleVisibilityChange,expression:"handleVisibilityChange"}],staticClass:"vue-recycle-scroller",class:(e={ready:i.ready,"page-mode":i.pageMode},e["direction-"+i.direction]=!0,e),on:{"&scroll":function(e){return i.handleScroll(e)}}},[i.$slots.before?r("div",{staticClass:"vue-recycle-scroller__slot"},[i._t("before")],2):i._e(),i._v(" "),r("div",{ref:"wrapper",staticClass:"vue-recycle-scroller__item-wrapper",style:(t={},t["vertical"===i.direction?"minHeight":"minWidth"]=i.totalSize+"px",t)},i._l(i.pool,(function(e){return r("div",{key:e.nr.id,staticClass:"vue-recycle-scroller__item-view",class:{hover:i.hoverKey===e.nr.key},style:i.ready?{transform:"translate"+("vertical"===i.direction?"Y":"X")+"("+e.position+"px)"}:null,on:{mouseenter:function(t){i.hoverKey=e.nr.key},mouseleave:function(e){i.hoverKey=null}}},[i._t("default",null,{item:e.item,index:e.nr.index,active:e.nr.used})],2)})),0),i._v(" "),i.$slots.after?r("div",{staticClass:"vue-recycle-scroller__slot"},[i._t("after")],2):i._e(),i._v(" "),r("ResizeObserver",{on:{notify:i.handleResize}})],1)};P._withStripped=!0;const k=R({render:P,staticRenderFns:[]},void 0,T,void 0,!1,void 0,!1,void 0,void 0,void 0);const A={name:"DynamicScroller",components:{RecycleScroller:k},inheritAttrs:!1,provide:function(){return"undefined"!=typeof ResizeObserver&&(this.$_resizeObserver=new ResizeObserver((function(e){var t,i=a(e);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n.target){var r=new CustomEvent("resize",{detail:{contentRect:n.contentRect}});n.target.dispatchEvent(r)}}}catch(e){i.e(e)}finally{i.f()}}))),{vscrollData:this.vscrollData,vscrollParent:this,vscrollResizeObserver:this.$_resizeObserver}},props:o({},O,{minItemSize:{type:[Number,String],required:!0}}),data:function(){return{vscrollData:{active:!0,sizes:{},validSizes:{},keyField:this.keyField,simpleArray:!1}}},computed:{simpleArray:x,itemsWithSize:function(){for(var e=[],t=this.items,i=this.keyField,n=this.simpleArray,r=this.vscrollData.sizes,s=0;s0&&void 0!==arguments[0])||arguments[0];(e||this.simpleArray)&&(this.vscrollData.validSizes={}),this.$emit("vscroll:update",{force:!0})},scrollToItem:function(e){var t=this.$refs.scroller;t&&t.scrollToItem(e)},getItemSize:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=this.simpleArray?null!=t?t:this.items.indexOf(e):e[this.keyField];return this.vscrollData.sizes[i]||0},scrollToBottom:function(){var e=this;if(!this.$_scrollingToBottom){this.$_scrollingToBottom=!0;var t=this.$el;this.$nextTick((function(){t.scrollTop=t.scrollHeight+5e3;requestAnimationFrame((function i(){t.scrollTop=t.scrollHeight+5e3,requestAnimationFrame((function(){t.scrollTop=t.scrollHeight+5e3,0===e.$_undefinedSizes?e.$_scrollingToBottom=!1:requestAnimationFrame(i)}))}))}))}}}};var E=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("RecycleScroller",e._g(e._b({ref:"scroller",attrs:{items:e.itemsWithSize,"min-item-size":e.minItemSize,direction:e.direction,"key-field":"id"},on:{resize:e.onScrollerResize,visible:e.onScrollerVisible},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.item,n=t.index,r=t.active;return[e._t("default",null,null,{item:i.item,index:n,active:r,itemWithSize:i})]}}],null,!0)},"RecycleScroller",e.$attrs,!1),e.listeners),[e._v(" "),i("template",{slot:"before"},[e._t("before")],2),e._v(" "),i("template",{slot:"after"},[e._t("after")],2)],2)};E._withStripped=!0;const j=R({render:E,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0);const U=R({},void 0,{name:"DynamicScrollerItem",inject:["vscrollData","vscrollParent","vscrollResizeObserver"],props:{item:{required:!0},watchData:{type:Boolean,default:!1},active:{type:Boolean,required:!0},index:{type:Number,default:void 0},sizeDependencies:{type:[Array,Object],default:null},emitResize:{type:Boolean,default:!1},tag:{type:String,default:"div"}},computed:{id:function(){return this.vscrollData.simpleArray?this.index:this.item[this.vscrollData.keyField]},size:function(){return this.vscrollData.validSizes[this.id]&&this.vscrollData.sizes[this.id]||0},finalActive:function(){return this.active&&this.vscrollData.active}},watch:{watchData:"updateWatchData",id:function(){this.size||this.onDataUpdate()},finalActive:function(e){this.size||(e?this.vscrollParent.$_undefinedMap[this.id]||(this.vscrollParent.$_undefinedSizes++,this.vscrollParent.$_undefinedMap[this.id]=!0):this.vscrollParent.$_undefinedMap[this.id]&&(this.vscrollParent.$_undefinedSizes--,this.vscrollParent.$_undefinedMap[this.id]=!1)),this.vscrollResizeObserver?e?this.observeSize():this.unobserveSize():e&&this.$_pendingVScrollUpdate===this.id&&this.updateSize()}},created:function(){var e=this;if(!this.$isServer&&(this.$_forceNextVScrollUpdate=null,this.updateWatchData(),!this.vscrollResizeObserver)){var t=function(t){e.$watch((function(){return e.sizeDependencies[t]}),e.onDataUpdate)};for(var i in this.sizeDependencies)t(i);this.vscrollParent.$on("vscroll:update",this.onVscrollUpdate),this.vscrollParent.$on("vscroll:update-size",this.onVscrollUpdateSize)}},mounted:function(){this.vscrollData.active&&(this.updateSize(),this.observeSize())},beforeDestroy:function(){this.vscrollParent.$off("vscroll:update",this.onVscrollUpdate),this.vscrollParent.$off("vscroll:update-size",this.onVscrollUpdateSize),this.unobserveSize()},methods:{updateSize:function(){this.finalActive?this.$_pendingSizeUpdate!==this.id&&(this.$_pendingSizeUpdate=this.id,this.$_forceNextVScrollUpdate=null,this.$_pendingVScrollUpdate=null,this.computeSize(this.id)):this.$_forceNextVScrollUpdate=this.id},updateWatchData:function(){var e=this;this.watchData?this.$_watchData=this.$watch("data",(function(){e.onDataUpdate()}),{deep:!0}):this.$_watchData&&(this.$_watchData(),this.$_watchData=null)},onVscrollUpdate:function(e){var t=e.force;!this.finalActive&&t&&(this.$_pendingVScrollUpdate=this.id),this.$_forceNextVScrollUpdate!==this.id&&!t&&this.size||this.updateSize()},onDataUpdate:function(){this.updateSize()},computeSize:function(e){var t=this;this.$nextTick((function(){if(t.id===e){var i=t.$el.offsetWidth,n=t.$el.offsetHeight;t.applySize(i,n)}t.$_pendingSizeUpdate=null}))},applySize:function(e,t){var i=Math.round("vertical"===this.vscrollParent.direction?t:e);i&&this.size!==i&&(this.vscrollParent.$_undefinedMap[this.id]&&(this.vscrollParent.$_undefinedSizes--,this.vscrollParent.$_undefinedMap[this.id]=void 0),this.$set(this.vscrollData.sizes,this.id,i),this.$set(this.vscrollData.validSizes,this.id,!0),this.emitResize&&this.$emit("resize",this.id))},observeSize:function(){this.vscrollResizeObserver&&(this.vscrollResizeObserver.observe(this.$el.parentNode),this.$el.parentNode.addEventListener("resize",this.onResize))},unobserveSize:function(){this.vscrollResizeObserver&&(this.vscrollResizeObserver.unobserve(this.$el.parentNode),this.$el.parentNode.removeEventListener("resize",this.onResize))},onResize:function(e){var t=e.detail.contentRect,i=t.width,n=t.height;this.applySize(i,n)}},render:function(e){return e(this.tag,this.$slots.default)}},void 0,void 0,void 0,!1,void 0,void 0,void 0);var C={version:"1.0.10",install:function(e,t){var n=Object.assign({},{installComponents:!0,componentsPrefix:""},t);for(var r in n)void 0!==n[r]&&(i[r]=n[r]);n.installComponents&&function(e,t){e.component("".concat(t,"recycle-scroller"),k),e.component("".concat(t,"RecycleScroller"),k),e.component("".concat(t,"dynamic-scroller"),j),e.component("".concat(t,"DynamicScroller"),j),e.component("".concat(t,"dynamic-scroller-item"),U),e.component("".concat(t,"DynamicScrollerItem"),U)}(e,n.componentsPrefix)}},M=null;return"undefined"!=typeof window?M=window.Vue:"undefined"!=typeof global&&(M=global.Vue),M&&M.use(C),e.DynamicScroller=j,e.DynamicScrollerItem=U,e.IdState=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.idProp,n=void 0===i?function(e){return e.item.id}:i,r={},s=new t({data:function(){return{store:r}}});return{data:function(){return{idState:null}},created:function(){var e=this;this.$_id=null,this.$_getId="function"==typeof n?function(){return n.call(e,e)}:function(){return e[n]},this.$watch(this.$_getId,{handler:function(e){var t=this;this.$nextTick((function(){t.$_id=e}))},immediate:!0}),this.$_updateIdState()},beforeUpdate:function(){this.$_updateIdState()},methods:{$_idStateInit:function(e){var t=this.$options.idState;if("function"==typeof t){var i=t.call(this,this);return s.$set(r,e,i),this.$_id=e,i}throw new Error("[mixin IdState] Missing `idState` function on component definition.")},$_updateIdState:function(){var e=this.$_getId();null==e&&console.warn("No id found for IdState with idProp: '".concat(n,"'.")),e!==this.$_id&&(r[e]||this.$_idStateInit(e),this.idState=r[e])}}}},e.RecycleScroller=k,e.default=C,e}({},Vue); +//# sourceMappingURL=vue-virtual-scroller.min.js.map +dResizeHandlers,t.type="text/html",c&&this.$el.appendChild(t),t.data="about:blank",c||this.$el.appendChild(t)},beforeDestroy:function(){this.removeResizeHandlers()}};var h={version:"0.4.5",install:function(e){e.component("resize-observer",u),e.component("ResizeObserver",u)}},f=null;function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:{},s=function(s){for(var l=arguments.length,a=new Array(l>1?l-1:0),c=1;c1){var n=e.find((function(e){return e.isIntersecting}));n&&(t=n)}if(i.callback){var r=t.isIntersecting&&t.intersectionRatio>=i.threshold;if(r===i.oldResult)return;i.oldResult=r,i.callback(r,t)}}),this.options.intersection),t.context.$nextTick((function(){i.observer&&i.observer.observe(i.el)}))}}},{key:"destroyObserver",value:function(){this.observer&&(this.observer.disconnect(),this.observer=null),this.callback&&this.callback._clear&&(this.callback._clear(),this.callback=null)}},{key:"threshold",get:function(){return this.options.intersection&&this.options.intersection.threshold||0}}])&&p(t.prototype,i),n&&p(t,n),e}();function b(e,t,i){var n=t.value;if(n)if("undefined"==typeof IntersectionObserver)console.warn("[vue-observe-visibility] IntersectionObserver API is not available in your browser. Please install this polyfill: https://github.com/w3c/IntersectionObserver/tree/master/polyfill");else{var r=new y(e,n,i);e._vue_visibilityState=r}}function _(e){var t=e._vue_visibilityState;t&&(t.destroyObserver(),delete e._vue_visibilityState)}var g={bind:b,update:function(e,t,i){var n=t.value;if(!function e(t,i){if(t===i)return!0;if("object"===v(t)){for(var n in t)if(!e(t[n],i[n]))return!1;return!0}return!1}(n,t.oldValue)){var r=e._vue_visibilityState;n?r?r.createObserver(n,i):b(e,{value:n},i):_(e)}},unbind:_};var $={version:"0.4.6",install:function(e){e.directive("observe-visibility",g)}},S=null;"undefined"!=typeof window?S=window.Vue:"undefined"!=typeof global&&(S=global.Vue),S&&S.use($);var z="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var w=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t,i;t=z,i=function(){var e=/(auto|scroll)/,t=function(e,i){return null===e.parentNode?i:t(e.parentNode,i.concat([e]))},i=function(e,t){return getComputedStyle(e,null).getPropertyValue(t)},n=function(t){return e.test(function(e){return i(e,"overflow")+i(e,"overflow-y")+i(e,"overflow-x")}(t))};return function(e){if(e instanceof HTMLElement||e instanceof SVGElement){for(var i=t(e.parentNode,[]),r=0;r1&&void 0!==arguments[1]&&arguments[1],i=this.$_unusedViews,n=e.nr.type,r=i.get(n);r||(r=[],i.set(n,r)),r.push(e),t||(e.nr.used=!1,e.position=-9999,this.$_views.delete(e.nr.key))},handleResize:function(){this.$emit("resize"),this.ready&&this.updateVisibleItems(!1)},handleScroll:function(e){var t=this,i=function(){t.$_scrollDirty||(t.$_scrollDirty=!0,requestAnimationFrame((function(){t.$_scrollDirty=!1,t.updateVisibleItems(!1,!0).continuous||(clearTimeout(t.$_refreshTimeout),t.$_refreshTimeout=setTimeout(t.handleScroll,100))})))};clearTimeout(this.scrollTimeout),this.debounce?this.scrollTimeout=setTimeout(i,parseInt(this.debounce)):i()},handleVisibilityChange:function(e,t){var i=this;this.ready&&(e||0!==t.boundingClientRect.width||0!==t.boundingClientRect.height?(this.$emit("visible"),requestAnimationFrame((function(){i.updateVisibleItems(!1)}))):this.$emit("hidden"))},updateVisibleItems:function(e){var t,n,r,o,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=this.itemSize,a=this.$_computedMinItemSize,c=this.typeField,d=this.simpleArray?null:this.keyField,u=this.items,h=u.length,f=this.sizes,v=this.$_views,p=this.$_unusedViews,m=this.pool;if(h)if(this.$_prerender)t=0,n=this.prerender,r=null;else{var y=this.getScroll();if(s){var b=y.start-this.$_lastUpdateScrollPosition;if(b<0&&(b=-b),null===l&&by.start&&(S=z),z=~~(($+S)/2)}while(z!==g);for(z<0&&(z=0),t=z,r=f[h-1].accumulator,n=z;nh&&(n=h)}else(t=~~(y.start/l))<0&&(t=0),(n=Math.ceil(y.end/l))>h&&(n=h),r=h*l}else t=n=r=0;n-t>i.itemsLimit&&this.itemsLimitError(),this.totalSize=r;var w=t<=this.$_endIndex&&n>=this.$_startIndex;if(this.$_continuous!==w){if(w){v.clear(),p.clear();for(var O=0,x=m.length;O=n)&&this.unuseView(o));for(var V,D,R,P,k=w?null:new Map,A=t;A=R.length)&&(o=this.addView(m,A,V,E,D),this.unuseView(o,!0),R=p.get(D)),(o=R[P]).item=V,o.nr.used=!0,o.nr.index=A,o.nr.key=E,o.nr.type=D,k.set(D,P+1),P++),v.set(E,o)),o.position=null===l?f[A-1].accumulator:A*l):o&&this.unuseView(o)}return this.$_startIndex=t,this.$_endIndex=n,this.emitUpdate&&this.$emit("update",t,n),clearTimeout(this.$_sortTimer),this.$_sortTimer=setTimeout(this.sortViews,300),{continuous:w}},getListenerTarget:function(){var e=w(this.$el);return!window.document||e!==window.document.documentElement&&e!==window.document.body||(e=window),e},getScroll:function(){var e,t=this.$el,i="vertical"===this.direction;if(this.pageMode){var n=t.getBoundingClientRect(),r=i?n.height:n.width,o=-(i?n.top:n.left),s=i?window.innerHeight:window.innerWidth;o<0&&(s+=o,o=0),o+s>r&&(s=r-o),e={start:o,end:o+s}}else e=i?{start:t.scrollTop,end:t.scrollTop+t.clientHeight}:{start:t.scrollLeft,end:t.scrollLeft+t.clientWidth};return e},applyPageMode:function(){this.pageMode?this.addListeners():this.removeListeners()},addListeners:function(){this.listenerTarget=this.getListenerTarget(),this.listenerTarget.addEventListener("scroll",this.handleScroll,!!I&&{passive:!0}),this.listenerTarget.addEventListener("resize",this.handleResize)},removeListeners:function(){this.listenerTarget&&(this.listenerTarget.removeEventListener("scroll",this.handleScroll),this.listenerTarget.removeEventListener("resize",this.handleResize),this.listenerTarget=null)},scrollToItem:function(e){var t;t=null===this.itemSize?e>0?this.sizes[e-1].accumulator:0:e*this.itemSize,this.scrollToPosition(t)},scrollToPosition:function(e){"vertical"===this.direction?this.$el.scrollTop=e:this.$el.scrollLeft=e},itemsLimitError:function(){var e=this;throw setTimeout((function(){console.log("It seems the scroller element isn't scrolling, so it tries to render all the items at once.","Scroller:",e.$el),console.log("Make sure the scroller has a fixed height (or width) and 'overflow-y' (or 'overflow-x') set to 'auto' so it can scroll correctly and only render the items visible in the scroll viewport.")})),new Error("Rendered items limit reached")},sortViews:function(){this.pool.sort((function(e,t){return e.nr.index-t.nr.index}))}}};var P=function(){var e,t,i=this,n=i.$createElement,r=i._self._c||n;return r("div",{directives:[{name:"observe-visibility",rawName:"v-observe-visibility",value:i.handleVisibilityChange,expression:"handleVisibilityChange"}],staticClass:"vue-recycle-scroller",class:(e={ready:i.ready,"page-mode":i.pageMode},e["direction-"+i.direction]=!0,e),on:{"&scroll":function(e){return i.handleScroll(e)}}},[i.$slots.before?r("div",{staticClass:"vue-recycle-scroller__slot"},[i._t("before")],2):i._e(),i._v(" "),r("div",{ref:"wrapper",staticClass:"vue-recycle-scroller__item-wrapper",style:(t={},t["vertical"===i.direction?"minHeight":"minWidth"]=i.totalSize+"px",t)},i._l(i.pool,(function(e){return r("div",{key:e.nr.id,staticClass:"vue-recycle-scroller__item-view",class:{hover:i.hoverKey===e.nr.key},style:i.ready?{transform:"translate"+("vertical"===i.direction?"Y":"X")+"("+e.position+"px)"}:null,on:{mouseenter:function(t){i.hoverKey=e.nr.key},mouseleave:function(e){i.hoverKey=null}}},[i._t("default",null,{item:e.item,index:e.nr.index,active:e.nr.used})],2)})),0),i._v(" "),i.$slots.after?r("div",{staticClass:"vue-recycle-scroller__slot"},[i._t("after")],2):i._e(),i._v(" "),r("ResizeObserver",{on:{notify:i.handleResize}})],1)};P._withStripped=!0;const k=D({render:P,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0);const A={name:"DynamicScroller",components:{RecycleScroller:k},inheritAttrs:!1,provide:function(){return"undefined"!=typeof ResizeObserver&&(this.$_resizeObserver=new ResizeObserver((function(e){var t,i=a(e);try{for(i.s();!(t=i.n()).done;){var n=t.value;if(n.target){var r=new CustomEvent("resize",{detail:{contentRect:n.contentRect}});n.target.dispatchEvent(r)}}}catch(e){i.e(e)}finally{i.f()}}))),{vscrollData:this.vscrollData,vscrollParent:this,vscrollResizeObserver:this.$_resizeObserver}},props:s({},O,{minItemSize:{type:[Number,String],required:!0}}),data:function(){return{vscrollData:{active:!0,sizes:{},validSizes:{},keyField:this.keyField,simpleArray:!1}}},computed:{simpleArray:x,itemsWithSize:function(){for(var e=[],t=this.items,i=this.keyField,n=this.simpleArray,r=this.vscrollData.sizes,o=0;o0&&void 0!==arguments[0])||arguments[0];(e||this.simpleArray)&&(this.vscrollData.validSizes={}),this.$emit("vscroll:update",{force:!0})},scrollToItem:function(e){var t=this.$refs.scroller;t&&t.scrollToItem(e)},getItemSize:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=this.simpleArray?null!=t?t:this.items.indexOf(e):e[this.keyField];return this.vscrollData.sizes[i]||0},scrollToBottom:function(){var e=this;if(!this.$_scrollingToBottom){this.$_scrollingToBottom=!0;var t=this.$el;this.$nextTick((function(){t.scrollTop=t.scrollHeight+5e3;requestAnimationFrame((function i(){t.scrollTop=t.scrollHeight+5e3,requestAnimationFrame((function(){t.scrollTop=t.scrollHeight+5e3,0===e.$_undefinedSizes?e.$_scrollingToBottom=!1:requestAnimationFrame(i)}))}))}))}}}};var E=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("RecycleScroller",e._g(e._b({ref:"scroller",attrs:{items:e.itemsWithSize,"min-item-size":e.minItemSize,direction:e.direction,debounce:e.debounce,"key-field":"id"},on:{resize:e.onScrollerResize,visible:e.onScrollerVisible},scopedSlots:e._u([{key:"default",fn:function(t){var i=t.item,n=t.index,r=t.active;return[e._t("default",null,null,{item:i.item,index:n,active:r,itemWithSize:i})]}}],null,!0)},"RecycleScroller",e.$attrs,!1),e.listeners),[e._v(" "),i("template",{slot:"before"},[e._t("before")],2),e._v(" "),i("template",{slot:"after"},[e._t("after")],2)],2)};E._withStripped=!0;const j=D({render:E,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0);const U=D({},void 0,{name:"DynamicScrollerItem",inject:["vscrollData","vscrollParent","vscrollResizeObserver"],props:{item:{required:!0},watchData:{type:Boolean,default:!1},active:{type:Boolean,required:!0},index:{type:Number,default:void 0},sizeDependencies:{type:[Array,Object],default:null},emitResize:{type:Boolean,default:!1},tag:{type:String,default:"div"}},computed:{id:function(){return this.vscrollData.simpleArray?this.index:this.item[this.vscrollData.keyField]},size:function(){return this.vscrollData.validSizes[this.id]&&this.vscrollData.sizes[this.id]||0},finalActive:function(){return this.active&&this.vscrollData.active}},watch:{watchData:"updateWatchData",id:function(){this.size||this.onDataUpdate()},finalActive:function(e){this.size||(e?this.vscrollParent.$_undefinedMap[this.id]||(this.vscrollParent.$_undefinedSizes++,this.vscrollParent.$_undefinedMap[this.id]=!0):this.vscrollParent.$_undefinedMap[this.id]&&(this.vscrollParent.$_undefinedSizes--,this.vscrollParent.$_undefinedMap[this.id]=!1)),this.vscrollResizeObserver?e?this.observeSize():this.unobserveSize():e&&this.$_pendingVScrollUpdate===this.id&&this.updateSize()}},created:function(){var e=this;if(!this.$isServer&&(this.$_forceNextVScrollUpdate=null,this.updateWatchData(),!this.vscrollResizeObserver)){var t=function(t){e.$watch((function(){return e.sizeDependencies[t]}),e.onDataUpdate)};for(var i in this.sizeDependencies)t(i);this.vscrollParent.$on("vscroll:update",this.onVscrollUpdate),this.vscrollParent.$on("vscroll:update-size",this.onVscrollUpdateSize)}},mounted:function(){this.vscrollData.active&&(this.updateSize(),this.observeSize())},beforeDestroy:function(){this.vscrollParent.$off("vscroll:update",this.onVscrollUpdate),this.vscrollParent.$off("vscroll:update-size",this.onVscrollUpdateSize),this.unobserveSize()},methods:{updateSize:function(){this.finalActive?this.$_pendingSizeUpdate!==this.id&&(this.$_pendingSizeUpdate=this.id,this.$_forceNextVScrollUpdate=null,this.$_pendingVScrollUpdate=null,this.computeSize(this.id)):this.$_forceNextVScrollUpdate=this.id},updateWatchData:function(){var e=this;this.watchData?this.$_watchData=this.$watch("data",(function(){e.onDataUpdate()}),{deep:!0}):this.$_watchData&&(this.$_watchData(),this.$_watchData=null)},onVscrollUpdate:function(e){var t=e.force;!this.finalActive&&t&&(this.$_pendingVScrollUpdate=this.id),this.$_forceNextVScrollUpdate!==this.id&&!t&&this.size||this.updateSize()},onDataUpdate:function(){this.updateSize()},computeSize:function(e){var t=this;this.$nextTick((function(){if(t.id===e){var i=t.$el.offsetWidth,n=t.$el.offsetHeight;t.applySize(i,n)}t.$_pendingSizeUpdate=null}))},applySize:function(e,t){var i=Math.round("vertical"===this.vscrollParent.direction?t:e);i&&this.size!==i&&(this.vscrollParent.$_undefinedMap[this.id]&&(this.vscrollParent.$_undefinedSizes--,this.vscrollParent.$_undefinedMap[this.id]=void 0),this.$set(this.vscrollData.sizes,this.id,i),this.$set(this.vscrollData.validSizes,this.id,!0),this.emitResize&&this.$emit("resize",this.id))},observeSize:function(){this.vscrollResizeObserver&&(this.vscrollResizeObserver.observe(this.$el.parentNode),this.$el.parentNode.addEventListener("resize",this.onResize))},unobserveSize:function(){this.vscrollResizeObserver&&(this.vscrollResizeObserver.unobserve(this.$el.parentNode),this.$el.parentNode.removeEventListener("resize",this.onResize))},onResize:function(e){var t=e.detail.contentRect,i=t.width,n=t.height;this.applySize(i,n)}},render:function(e){return e(this.tag,this.$slots.default)}},void 0,void 0,void 0,!1,void 0,void 0,void 0);var C={version:"1.0.10",install:function(e,t){var n=Object.assign({},{installComponents:!0,componentsPrefix:""},t);for(var r in n)void 0!==n[r]&&(i[r]=n[r]);n.installComponents&&function(e,t){e.component("".concat(t,"recycle-scroller"),k),e.component("".concat(t,"RecycleScroller"),k),e.component("".concat(t,"dynamic-scroller"),j),e.component("".concat(t,"DynamicScroller"),j),e.component("".concat(t,"dynamic-scroller-item"),U),e.component("".concat(t,"DynamicScrollerItem"),U)}(e,n.componentsPrefix)}},M=null;return"undefined"!=typeof window?M=window.Vue:"undefined"!=typeof global&&(M=global.Vue),M&&M.use(C),e.DynamicScroller=j,e.DynamicScrollerItem=U,e.IdState=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e.idProp,n=void 0===i?function(e){return e.item.id}:i,r={},o=new t({data:function(){return{store:r}}});return{data:function(){return{idState:null}},created:function(){var e=this;this.$_id=null,this.$_getId="function"==typeof n?function(){return n.call(e,e)}:function(){return e[n]},this.$watch(this.$_getId,{handler:function(e){var t=this;this.$nextTick((function(){t.$_id=e}))},immediate:!0}),this.$_updateIdState()},beforeUpdate:function(){this.$_updateIdState()},methods:{$_idStateInit:function(e){var t=this.$options.idState;if("function"==typeof t){var i=t.call(this,this);return o.$set(r,e,i),this.$_id=e,i}throw new Error("[mixin IdState] Missing `idState` function on component definition.")},$_updateIdState:function(){var e=this.$_getId();null==e&&console.warn("No id found for IdState with idProp: '".concat(n,"'.")),e!==this.$_id&&(r[e]||this.$_idStateInit(e),this.idState=r[e])}}}},e.RecycleScroller=k,e.default=C,e}({},Vue); //# sourceMappingURL=vue-virtual-scroller.min.js.map diff --git a/dist/vue-virtual-scroller.umd.js b/dist/vue-virtual-scroller.umd.js index 1853f791..3152bed3 100644 --- a/dist/vue-virtual-scroller.umd.js +++ b/dist/vue-virtual-scroller.umd.js @@ -1176,79 +1176,79 @@ } }; - function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) { - if (typeof shadowMode !== 'boolean') { - createInjectorSSR = createInjector; - createInjector = shadowMode; - shadowMode = false; - } - // Vue.extend constructor export interop. - const options = typeof script === 'function' ? script.options : script; - // render functions - if (template && template.render) { - options.render = template.render; - options.staticRenderFns = template.staticRenderFns; - options._compiled = true; - // functional template - if (isFunctionalTemplate) { - options.functional = true; - } - } - // scopedId - if (scopeId) { - options._scopeId = scopeId; - } - let hook; - if (moduleIdentifier) { - // server build - hook = function (context) { - // 2.3 injection - context = - context || // cached call - (this.$vnode && this.$vnode.ssrContext) || // stateful - (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional - // 2.2 with runInNewContext: true - if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { - context = __VUE_SSR_CONTEXT__; - } - // inject component styles - if (style) { - style.call(this, createInjectorSSR(context)); - } - // register component module identifier for async chunk inference - if (context && context._registeredComponents) { - context._registeredComponents.add(moduleIdentifier); - } - }; - // used by ssr in case component is cached and beforeCreate - // never gets called - options._ssrRegister = hook; - } - else if (style) { - hook = shadowMode - ? function (context) { - style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot)); - } - : function (context) { - style.call(this, createInjector(context)); - }; - } - if (hook) { - if (options.functional) { - // register for functional component in vue file - const originalRender = options.render; - options.render = function renderWithStyleInjection(h, context) { - hook.call(context); - return originalRender(h, context); - }; - } - else { - // inject component registration as beforeCreate hook - const existing = options.beforeCreate; - options.beforeCreate = existing ? [].concat(existing, hook) : [hook]; - } - } - return script; + function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) { + if (typeof shadowMode !== 'boolean') { + createInjectorSSR = createInjector; + createInjector = shadowMode; + shadowMode = false; + } + // Vue.extend constructor export interop. + const options = typeof script === 'function' ? script.options : script; + // render functions + if (template && template.render) { + options.render = template.render; + options.staticRenderFns = template.staticRenderFns; + options._compiled = true; + // functional template + if (isFunctionalTemplate) { + options.functional = true; + } + } + // scopedId + if (scopeId) { + options._scopeId = scopeId; + } + let hook; + if (moduleIdentifier) { + // server build + hook = function (context) { + // 2.3 injection + context = + context || // cached call + (this.$vnode && this.$vnode.ssrContext) || // stateful + (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional + // 2.2 with runInNewContext: true + if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { + context = __VUE_SSR_CONTEXT__; + } + // inject component styles + if (style) { + style.call(this, createInjectorSSR(context)); + } + // register component module identifier for async chunk inference + if (context && context._registeredComponents) { + context._registeredComponents.add(moduleIdentifier); + } + }; + // used by ssr in case component is cached and beforeCreate + // never gets called + options._ssrRegister = hook; + } + else if (style) { + hook = shadowMode + ? function (context) { + style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot)); + } + : function (context) { + style.call(this, createInjector(context)); + }; + } + if (hook) { + if (options.functional) { + // register for functional component in vue file + const originalRender = options.render; + options.render = function renderWithStyleInjection(h, context) { + hook.call(context); + return originalRender(h, context); + }; + } + else { + // inject component registration as beforeCreate hook + const existing = options.beforeCreate; + options.beforeCreate = existing ? [].concat(existing, hook) : [hook]; + } + } + return script; } /* script */ diff --git a/src/components/DynamicScroller.vue b/src/components/DynamicScroller.vue index d6acf8d8..a1a88331 100644 --- a/src/components/DynamicScroller.vue +++ b/src/components/DynamicScroller.vue @@ -4,6 +4,7 @@ :items="itemsWithSize" :min-item-size="minItemSize" :direction="direction" + :debounce="debounce" :key-field="keyField" :list-tag="listTag" :item-tag="itemTag" diff --git a/src/components/DynamicScrollerItem.vue b/src/components/DynamicScrollerItem.vue index fbf9d35c..e5b4a95c 100644 --- a/src/components/DynamicScrollerItem.vue +++ b/src/components/DynamicScrollerItem.vue @@ -50,9 +50,10 @@ export default { computed: { id () { - if (this.vscrollData.simpleArray) return this.index; - if (this.item.hasOwnProperty(this.vscrollData.keyField)) return this.item[this.vscrollData.keyField]; - throw new Error(`keyField '${this.vscrollData.keyField}' not found in your item. You should set a valid keyField prop on your Scroller`); + if (this.vscrollData.simpleArray) return this.index + // eslint-disable-next-line no-prototype-builtins + if (this.item.hasOwnProperty(this.vscrollData.keyField)) return this.item[this.vscrollData.keyField] + throw new Error(`keyField '${this.vscrollData.keyField}' not found in your item. You should set a valid keyField prop on your Scroller`) }, size () { diff --git a/src/components/RecycleScroller.vue b/src/components/RecycleScroller.vue index ba4d5c9a..4c9198a2 100644 --- a/src/components/RecycleScroller.vue +++ b/src/components/RecycleScroller.vue @@ -231,6 +231,7 @@ export default { beforeDestroy () { this.removeListeners() + clearTimeout(this.scrollTimeout) }, methods: { @@ -276,19 +277,29 @@ export default { }, handleScroll (event) { - if (!this.$_scrollDirty) { - this.$_scrollDirty = true - requestAnimationFrame(() => { - this.$_scrollDirty = false - const { continuous } = this.updateVisibleItems(false, true) - - // It seems sometimes chrome doesn't fire scroll event :/ - // When non continous scrolling is ending, we force a refresh - if (!continuous) { - clearTimeout(this.$_refreshTimout) - this.$_refreshTimout = setTimeout(this.handleScroll, 100) - } - }) + const job = () => { + if (!this.$_scrollDirty) { + this.$_scrollDirty = true + requestAnimationFrame(() => { + this.$_scrollDirty = false + const { continuous } = this.updateVisibleItems(false, true) + + // It seems sometimes chrome doesn't fire scroll event :/ + // When non continous scrolling is ending, we force a refresh + if (!continuous) { + clearTimeout(this.$_refreshTimeout) + this.$_refreshTimeout = setTimeout(this.handleScroll, 100) + } + }) + } + } + + clearTimeout(this.scrollTimeout) + + if (this.debounce) { + this.scrollTimeout = setTimeout(job, parseInt(this.debounce)) + } else { + job() } }, diff --git a/src/components/common.js b/src/components/common.js index 45aa4004..559e556e 100644 --- a/src/components/common.js +++ b/src/components/common.js @@ -15,6 +15,11 @@ export const props = { validator: (value) => ['vertical', 'horizontal'].includes(value), }, + debounce: { + type: [Number, String], + default: 0, + }, + listTag: { type: String, default: 'div',