(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("vue")):typeof define=="function"&&define.amd?define(["vue"],i):(e=typeof globalThis<"u"?globalThis:e||self,e["virtual-list"]=i(e.Vue))})(this,function(e){"use strict";const i={name:"virtualList"},a=e.defineComponent({...i,props:{list:{},containerStyle:{},containerClassName:{},childStyle:{},childClassName:{},height:{},itemHeight:{},scrollButtonFn:{type:Function}},setup(s){const t=s,c=e.ref(5),l=e.ref(0),d=e.ref(0),f=e.computed(()=>t!=null&&t.containerStyle?t.containerStyle:{width:"200px"});e.getCurrentInstance();const h=e.computed(()=>t.list.length*t.itemHeight),m=e.computed(()=>t.list.slice(l.value,d.value).map((r,o)=>({data:r,style:{position:"absolute",transform:`translateY(${(o+l.value)*t.itemHeight}px)`}})));e.onMounted(()=>{u()});const p=n=>{l.value=Math.round(n/t.itemHeight),l.value>c.value&&(l.value=l.value-c.value),d.value=Math.floor(l.value+t.height/t.itemHeight)+c.value},g=()=>{(t==null?void 0:t.scrollButtonFn)instanceof Function&&t.scrollButtonFn()},u=n=>{const{scrollTop:r,scrollHeight:o}=(n==null?void 0:n.target)||{};p(r||0),(r||0)+t.height===(o||0)&&g()};return(n,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(t.containerClassName),style:e.normalizeStyle([{height:`${n.height}px`,...f.value},{"overflow-y":"scroll",background:"#f1f1f1"}]),onScroll:u},[e.createElementVNode("div",{class:e.normalizeClass(t.childClassName),style:e.normalizeStyle([{height:`${h.value}px`},{width:"100%",position:"relative"}])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(o,y)=>(e.openBlock(),e.createElementBlock("div",{key:o,ref_for:!0,ref:"items",style:e.normalizeStyle(o.style)},[e.renderSlot(n.$slots,"default",{item:o})],4))),128))],6)],38))}});return a.install=s=>{s.component(a.name,a)},a});
