import{_ as t,o as i,p as a,w as s,f as e,k as n,t as d,C as h,i as l,a9 as r,am as o,e as c,y as b,F as f,a4 as p,B as u,S as w,J as L,I as T}from"./index-2PZN6pGH.js";const g=t({components:{swiperPage:t({props:{pid:{type:[Number,String],default:""}},data:()=>({dataList:[]}),created(){},methods:{loadData(){},clear(){this.dataList.length=0}}},[["render",function(t,r,o,c,b,f){const p=h,u=l;return i(),a(u,{class:"uni-swiper-page"},{default:s((()=>[e(p,null,{default:s((()=>[n("Tab View "+d(o.pid),1)])),_:1})])),_:1})}],["__scopeId","data-v-e0ae306d"]])},data:()=>({tabList:[],tabIndex:0,cacheTab:[],scrollInto:"",indicatorLineLeft:0,indicatorLineWidth:0,isTap:!1}),onLoad(){for(var t=0;t<6;t++)this.tabList.push({id:"tab"+t,name:"Tab "+(t+1),pageid:t+1})},onReady(){this._lastTabIndex=0,this.swiperWidth=0,this.tabbarWidth=0,this.tabListSize={},this._touchTabIndex=0,this.pageList=this.$refs.page,this.switchTab(this.tabIndex),this.getTabbarItemsSize()},methods:{ontabtap(t){let i=t.target.dataset.current||t.currentTarget.dataset.current;this.isTap=!0;var a=this.tabListSize[i];this.updateIndicator(a.left,a.width),this._touchTabIndex=i,this.switchTab(i)},onswiperchange(t){},onswiperscroll(t){if(!this.isTap){var i=t.detail.dx,a=this._lastTabIndex;if(i>1?a++:i<-1&&a--,!(a===this._lastTabIndex||a<0||a>this.pageList.length-1)){0===this.pageList[a].dataList.length&&this.loadTabData(a);var s=Math.abs(this.swiperWidth/i),e=this.tabListSize[this._lastTabIndex],n=this.tabListSize[a],d=e.left+(n.left-e.left)/s,h=e.width+(n.width-e.width)/s;this.updateIndicator(d,h)}}},animationfinish(t){let i=t.detail.current;this._touchTabIndex===i&&(this.isTap=!1),this._lastTabIndex=i,this.switchTab(i),this.updateIndicator(this.tabListSize[i].left,this.tabListSize[i].width)},getTabbarItemsSize(){r().in(this).select(".tab-view").fields({dataset:!0,size:!0},(t=>{this.swiperWidth=t.width})).exec(),r().in(this).selectAll(".uni-tab-item").boundingClientRect((t=>{t.forEach((t=>{this.tabListSize[t.dataset.id]=t}))})).exec(),setTimeout((()=>{this.updateIndicator(this.tabListSize[this.tabIndex].left,this.tabListSize[this.tabIndex].width)}),100)},updateIndicator(t,i){this.indicatorLineLeft=t,this.indicatorLineWidth=i},switchTab(t){if(0===this.pageList[t].dataList.length&&this.loadTabData(t),this.tabIndex!==t){if(this.pageList[this.tabIndex].dataList.length>100){this.cacheTab.indexOf(this.tabIndex)<0&&this.cacheTab.push(this.tabIndex)}if(this.tabIndex=t,this.scrollInto=this.tabList[t].id,this.cacheTab.length>3){let t=this.cacheTab[0];this.clearTabData(t),this.cacheTab.splice(0,1)}}},scrollTabTo(t){const i=this.$refs["tabitem"+t][0];let a=0;t>0&&(a=this.tabbarWidth/2-this.tabListSize[t].width/2,this.tabListSize[t].right<this.tabbarWidth/2&&(a=this.tabListSize[0].width)),dom.scrollToElement(i,{offset:-a})},loadTabData(t){this.pageList[t].loadData()},clearTabData(t){this.pageList[t].clear()}}},[["render",function(t,r,g,I,m,x){const _=h,S=l,v=w,z=o("swiperPage"),y=T,W=L;return i(),a(S,{class:"tabs"},{default:s((()=>[e(v,{ref:"tabbar1",id:"tab-bar",class:"tab-bar",scroll:!1,"scroll-x":!0,"show-scrollbar":!1,"scroll-into-view":m.scrollInto},{default:s((()=>[e(S,{style:{"flex-direction":"column"}},{default:s((()=>[e(S,{style:{"flex-direction":"row"}},{default:s((()=>[(i(!0),c(f,null,b(m.tabList,((t,h)=>(i(),a(S,{class:"uni-tab-item",key:t.id,id:t.id,ref_for:!0,ref:"tabitem"+h,"data-id":h,"data-current":h,onClick:x.ontabtap},{default:s((()=>[e(_,{class:p(["uni-tab-item-title",m.tabIndex==h?"uni-tab-item-title-active":""])},{default:s((()=>[n(d(t.name),1)])),_:2},1032,["class"])])),_:2},1032,["id","data-id","data-current","onClick"])))),128))])),_:1}),e(S,{class:"scroll-view-indicator"},{default:s((()=>[e(S,{ref:"underline",class:p(["scroll-view-underline",m.isTap?"scroll-view-animation":""]),style:u({left:m.indicatorLineLeft+"px",width:m.indicatorLineWidth+"px"})},null,8,["class","style"])])),_:1})])),_:1})])),_:1},8,["scroll-into-view"]),e(S,{class:"tab-bar-line"}),e(W,{class:"tab-view",ref:"swiper1",id:"tab-bar-view",current:m.tabIndex,duration:300,onChange:x.onswiperchange,onTransition:x.onswiperscroll,onAnimationfinish:x.animationfinish,onOnAnimationEnd:x.animationfinish},{default:s((()=>[(i(!0),c(f,null,b(m.tabList,((t,n)=>(i(),a(y,{class:"swiper-item",key:n},{default:s((()=>[e(z,{class:"swiper-page",pid:t.pageid,ref_for:!0,ref:"page"},null,8,["pid"])])),_:2},1024)))),128))])),_:1},8,["current","onChange","onTransition","onAnimationfinish","onOnAnimationEnd"])])),_:1})}],["__scopeId","data-v-67ee1eed"]]);export{g as default};
