@fox-js/navigation 4.0.1-15 → 4.0.1-17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";/*!
2
- * @fox-js/navigation v4.0.1-14 Thu Jun 13 2024 07:29:14 GMT+0800 (中国标准时间)
3
- */const s=require("vue"),b=require("@fox-js/fox"),k=s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{class:"fox-card-navigator","view-class":"fox-card-navigator__item","view-active-class":"fox-card-navigator__item-active","view-inactive-class":"fox-card-navigator__item-inactive","transition-name":"fox-card-navigator__trans",transition:e.transition,multi:!0,name:e.routerViewName},null,8,["transition","name"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),U=s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{transition:!1,multi:!1,name:e.routerViewName},{default:s.withCtx(({Component:i})=>[s.createVNode(s.Transition,{name:"fox-default-navigator__trans"},{default:s.withCtx(()=>[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i)))]),_:2},1024)]),_:1},8,["name"])}}}),j=Object.freeze(Object.defineProperty({__proto__:null,default:U},Symbol.toStringTag,{value:"Module"})),S=10;function q(t,e){return t>e&&t>S?"horizontal":e>t&&e>S?"vertical":""}function V(){const t={startX:0,startY:0,startTime:0,duration:0,moveX:0,moveY:0,deltaX:0,deltaY:0,offsetX:0,offsetY:0,direction:""},e=()=>t.direction==="vertical",n=()=>t.direction==="horizontal",o=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:m=>{if(m.touches){const a=m.touches[0];t.deltaX=a.clientX-t.startX,t.deltaY=a.clientY-t.startY,t.moveX=a.clientX,t.moveY=a.clientY}else t.deltaX=m.clientX-t.startX,t.deltaY=m.clientY-t.startY,t.moveX=m.clientX,t.moveY=m.clientY;t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.duration=Date.now()-t.startTime,t.direction||(t.direction=q(t.offsetX,t.offsetY))},start:m=>{if(o(),m.touches){const a=m.touches[0];t.startX=a.clientX,t.startY=a.clientY}else t.startX=m.clientX,t.startY=m.clientY;t.startTime=Date.now()},reset:o,isVertical:e,isHorizontal:n,state:t}}function H(t){return t===window}const G=t=>{const e=s.unref(t);if(H(e)){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},J=(t,e,n)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const o=document.createEvent("Events");let i=!0,d=!0;for(let a in e)a==="bubbles"?i=!!e[a]:a==="cancelable"?d=!!e[a]:o[a]=e[a];o.initEvent(t,i,d),(n??document).dispatchEvent(o)},K=15,Q=300,Z=200;function tt(t){t.stopPropagation()}function et(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function P(t,e=0,n,o=Z){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function A(t){t.style.transition="",t.style.transform=""}const nt=/^matrix\((.+)\)$/;function C(t){let e=0;const n=t,{transform:o}=window.getComputedStyle(n);if(o){const i=nt.exec(o);i&&(e=+i[1].split(/,\s*/)[4])}return e}const X=new WeakMap;function ot(t,e,n,o,i,d=600,m=60){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},x=t.previousSibling,f=V(),g=(_,h,c,T)=>{let v=h+a.startDistance;if(c==="end"){const D=G(_);let l=D.width*e;v<l?v=0:v=D.width,a.transitionEndTrigger=()=>{a.moving=!1,i&&_.classList.remove(i),setTimeout(()=>{x&&A(x),v==0?A(_):J(b.FoxLeaveEnd,{},_),a.moving=!1},m)},x&&P(x,0,"",0),v>0&&typeof o=="function"&&o(),P(_,v,"end",T)}else v<0&&(v=0),P(_,v,"",0)},w=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},r=_=>{f.start(_),a.scrollDistance=0,a.moving&&(a.scrollDistance=C(t)),i&&t.classList.add(i),a.transitionEndTrigger=null,a.moving=!0},p=_=>{a.moving=!0,f.move(_),!(f.isVertical()||C(t)===0&&f.state.deltaX<0)&&(tt(_),g(t,f.state.deltaX,"",0))},u=()=>{if(f.isVertical()||C(t)===0&&f.state.deltaX<0)return;const h=f.state.deltaX;if(h===0){i&&t.classList.remove(i),a.moving=!1;return}const c=f.state.duration;if(c<Q&&Math.abs(h)>K){const v=et(h,c,n);g(t,v,"end",d)}else g(t,h,"end",d)};t.addEventListener("transitionend",w),t.addEventListener("transitioncancel",w),t.addEventListener("touchstart",r),t.addEventListener("touchmove",p),t.addEventListener("touchend",u),t.addEventListener("touchcancel",u),X.set(t,{state:a,transitionend:w,transitioncancel:w,touchstart:r,touchmove:p,touchend:u,touchcancel:u})}function it(t){const e=X.get(t);e&&(X.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("transitioncancel",e.transitioncancel),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const st=s.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},resetDelay:{default:120},swipeDuration:{default:60},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let n=null,o=null;function i(r){return(r.params&&r.params.animationType)??"slide"}function d(r){return(r.params&&r.params.dragRemove)??e.dragRemove}const m=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"show":"enter";if(c==="show"&&(h==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;c==="enter"&&(n=u,o="enter");const T=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-active`;r.classList.add(T),r.classList.add(v)}},a=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"show":"enter";if(c==="show"&&(h==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;const T=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-to`;r.classList.remove(T),r.classList.add(v)}},x=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const c=i(u),T=p?"show":"enter";if(T==="enter"&&(n=null,o=null),c!=="pop"){const v=`fox-root-navigator__${c}-${T}-active`,D=`fox-root-navigator__${c}-${T}-to`;r.classList.remove(v),r.classList.remove(D)}}d(u)===!0&&!p&&u.opsType===b.OperationType.Append&&ot(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,"fox-root-navigator__item-moving",e.swipeDuration,e.resetDelay)},f=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"hide":"leave";if(c==="hide"&&(h==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;c==="leave"&&(n=u,o="leave");const T=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-active`;r.classList.add(T),r.classList.add(v)}},g=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"hide":"leave";if(c==="hide"&&(h==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;const T=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-to`;r.classList.remove(T),r.classList.add(v)}},w=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const c=i(u),T=p?"hide":"leave";if(T==="leave"&&(n=null,o=null),c!=="pop"){const v=`fox-root-navigator__${c}-${T}-active`,D=`fox-root-navigator__${c}-${T}-to`;r.classList.remove(v),r.classList.remove(D)}}d(u)&&!p&&it(r)};return(r,p)=>{const u=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(u,{class:"fox-root-navigator","view-class":r.viewClass,"before-enter":m,enter:a,"after-enter":x,"before-leave":f,leave:g,"after-leave":w,multi:!0,name:r.routerViewName,"view-tag":r.viewTag,transition:r.transition},null,8,["view-class","name","view-tag","transition"])}}}),at=Object.freeze(Object.defineProperty({__proto__:null,default:st},Symbol.toStringTag,{value:"Module"})),rt={class:"fox-swiper-navigator"},ct=s.defineComponent({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,n=s.computed(()=>{const o={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(o["transition-duration"]=`${e.scrollDuration}ms`),o});return(o,i)=>(s.openBlock(),s.createElementBlock("div",rt,[s.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:s.normalizeStyle(n.value)},[s.renderSlot(o.$slots,"default")],4)]))}});let lt=0;function ut(){return++lt}const dt=15,ft=300,ht=200;function mt(t){t.stopPropagation()}function pt(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function I(t,e=0,n,o=ht){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}class vt{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;moveRatio=.5;momentumReduceRatio=1;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,n,o,i,d,m){this.getStartDistance=e,this.openPage=n,this.isPageOpened=o,this.pageOpened=i,this.moveRatio=d,this.momentumReduceRatio=m}open(){const e=this.el,n=V(),o=(i,d,m,a)=>{let x=d+this.startDistance;const f=this.columnWidth*this.moveRatio;if(m==="end"){if(d==0){this.moving=!1;return}Math.abs(d)>f?d>0?x=this.startDistance+this.columnWidth:x=this.startDistance-this.columnWidth:x=this.startDistance;let g=-x;g<0?g=0:g>this.width-this.columnWidth&&(g=this.width-this.columnWidth);const w=Math.floor(g/this.columnWidth);this.isPageOpened(w)||this.openPage(w),x=-w*this.columnWidth,a&&a>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(w)}),I(i,x,"end",a),this.scrollDistance=x}else{if(Math.abs(d)>f){let w=0;if(d>0?w=Math.abs(this.startDistance+this.columnWidth):w=Math.abs(this.startDistance-this.columnWidth),w>=0&&w<this.width){const r=Math.floor(w/this.columnWidth);this.isPageOpened(r)||this.openPage(r)}}let g=-x;g<this.min?g=this.min:g>this.max&&(g=this.max),I(i,-g,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=i=>{this.moving||(n.start(i),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=i=>{n.move(i),!n.isVertical()&&(mt(i),o(e,n.state.deltaX,"",0))},this.touchend=()=>{if(n.isVertical())return;const i=n.state.deltaX;if(i==0)return;const d=n.state.duration;if(d<ft&&Math.abs(i)>dt){const a=pt(i,d,this.momentumReduceRatio);o(e,a,"end",this.swipeDuration)}else o(e,i,"end",this.swipeDuration)},e.addEventListener("transitionend",this.transitionend),e.addEventListener("touchstart",this.touchstart),e.addEventListener("touchmove",this.touchmove),e.addEventListener("touchend",this.touchend),e.addEventListener("touchcancel",this.touchend)}close(){const e=this.el;this.transitionend&&e.addEventListener("transitionend",this.transitionend),this.touchstart&&e.addEventListener("touchstart",this.touchstart),this.touchmove&&e.addEventListener("touchmove",this.touchmove),this.touchend&&e.addEventListener("touchend",this.touchend),this.touchcancel&&e.addEventListener("touchcancel",this.touchcancel),this.el=null}}function gt(t,e,n,o,i,d){return new vt(t,e,n,o,i,d)}function _t(t){const e=s.unref(t),n=window.getComputedStyle(e,null),o=parseFloat(n.getPropertyValue("padding-left")),i=parseFloat(n.getPropertyValue("padding-right")),d=parseFloat(n.getPropertyValue("padding-top")),m=parseFloat(n.getPropertyValue("padding-bottom"));return{width:e.clientWidth-o-i,height:e.clientHeight-d-m}}const wt=s.defineComponent({__name:"index",props:{activePath:{},routes:{},height:{default:-1},width:{default:-1},draggable:{type:Boolean,default:!0},openViewPage:{},routerViewName:{},moveRatio:{default:.5},momentumReduceRatio:{default:1},direction:{default:"horizontal"},transition:{type:[Function,Boolean],default:!0},swipeDuration:{default:360},scrollDuration:{},customClass:{},customStyle:{}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,o=s.reactive({scrollDistance:0,index:-1,openedIndexList:[],width:n.width,height:n.height}),i=e,d=()=>o.scrollDistance,m=l=>{if(o.openedIndexList.indexOf(l)===-1){o.openedIndexList.push(l);const E=n.routes[l];try{n.openViewPage(E,l)}catch(y){console.error(y)}}},a=l=>o.openedIndexList.indexOf(l)!==-1,x=l=>{o.index=l,o.width>0?o.scrollDistance=-o.index*o.width:o.scrollDistance=0;const E=n.routes[l];i("update:activePath",E.path)};let f=null;n.draggable&&(f=gt(d,m,a,x,n.moveRatio,n.momentumReduceRatio));let g=null;s.onMounted(()=>{const l=h(),E=()=>{const y=_t(l);w(n.activePath,n.routes,y.width,y.height,n.swipeDuration,n.direction)};if(window.ResizeObserver&&(g=new window.ResizeObserver(E),g.observe(l)),E(),f){const y=T();f.el=y,f.open()}}),s.onBeforeUnmount(()=>{g&&(g.disconnect(),g=null),f&&f.close()}),s.watch([()=>n.activePath,()=>n.routes,()=>n.width,()=>n.height,()=>n.swipeDuration,()=>n.direction],([l,E,y,$,M,R])=>{const O=y<=0?o.width:y,L=$<=0?o.height:$;w(l,E,O,L,M,R)});const w=(l,E,y,$,M,R="horizontal")=>{const O=l;if(o.index=E.findIndex(L=>L.path===O),R==="horizontal"){const L=y;if(L>0){o.width=y;const z=L*n.routes.length,W=-L/3,N=L*(E.length-1)+L/3;f&&(f.columnWidth=L,f.width=z,f.min=W,f.max=N),o.index!==-1&&(o.openedIndexList.push(o.index),o.scrollDistance=-L*o.index)}}f&&(f.swipeDuration=M)},r=`fox-swiper-navigator-${ut()}`,p=s.computed(()=>{const l=[r];return n.customClass&&l.push(n.customClass),l}),u=s.computed(()=>{const l={},E=o.width>0?o.width:n.width;E>0&&(l.width=`${E}px`);const y=o.height>0?o.height:n.height;return y>0&&(l.height=`${y}px`),n.customStyle&&Object.assign(l,n.customStyle),l});let _=null;function h(){return _||(_=document.querySelector(`.${r}`),_)}let c=null;function T(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const v=s.computed(()=>o.width>0?`${o.width*n.routes.length}px`:"100%"),D=(l,E)=>{const y=n.routes.findIndex($=>{const M=l.path??l.name??"";return $.path==M});return o.width<=0?{}:{style:{left:`${y*o.width}px`,width:`${o.width}px`}}};return(l,E)=>{const y=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(y,{class:s.normalizeClass(p.value),style:s.normalizeStyle(u.value),"view-class":"fox-swiper-navigator__item",tag:ct,"view-tag-props":D,multi:!0,name:l.routerViewName,transition:l.transition,"scroll-distance":o.scrollDistance,"scroll-duration":l.scrollDuration,direction:l.direction,width:v.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),Tt=Object.freeze(Object.defineProperty({__proto__:null,default:wt},Symbol.toStringTag,{value:"Module"}));let yt="fox-";const xt=[],B=Object.assign({"/src/components/card-navigator/index.vue":F,"/src/components/default-navigator/index.vue":j,"/src/components/root-navigator/index.vue":at,"/src/components/swiper-navigator/index.vue":Tt}),Y=[];for(const t in B){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];xt.indexOf(e)===-1&&Y.push({name:e,component:B[t].default})}const Et={install(t){Y.forEach(e=>{t.component(`${yt}${e.name}`,e.component)})}};module.exports=Et;
2
+ * @fox-js/navigation v4.0.1-16 Sat Sep 28 2024 19:51:20 GMT+0800 (中国标准时间)
3
+ */const r=require("vue"),L=require("@fox-js/fox"),k=r.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,n)=>{const o=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(o,{class:"fox-card-navigator","view-class":"fox-card-navigator__item","view-active-class":"fox-card-navigator__item-active","view-inactive-class":"fox-card-navigator__item-inactive","transition-name":"fox-card-navigator__trans",transition:e.transition,multi:!0,name:e.routerViewName},null,8,["transition","name"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),U=r.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,n)=>{const o=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(o,{transition:!1,multi:!1,name:e.routerViewName},{default:r.withCtx(({Component:i})=>[r.createVNode(r.Transition,{name:"fox-default-navigator__trans"},{default:r.withCtx(()=>[(r.openBlock(),r.createBlock(r.resolveDynamicComponent(i)))]),_:2},1024)]),_:1},8,["name"])}}}),j=Object.freeze(Object.defineProperty({__proto__:null,default:U},Symbol.toStringTag,{value:"Module"})),X=10;function q(t,e){return t>e&&t>X?"horizontal":e>t&&e>X?"vertical":""}function B(){const t={startX:0,startY:0,startTime:0,duration:0,moveX:0,moveY:0,deltaX:0,deltaY:0,offsetX:0,offsetY:0,direction:""},e=()=>t.direction==="vertical",n=()=>t.direction==="horizontal",o=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:p=>{if(p.touches){const m=p.touches[0];t.deltaX=m.clientX-t.startX,t.deltaY=m.clientY-t.startY,t.moveX=m.clientX,t.moveY=m.clientY}else t.deltaX=p.clientX-t.startX,t.deltaY=p.clientY-t.startY,t.moveX=p.clientX,t.moveY=p.clientY;t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.duration=Date.now()-t.startTime,t.direction||(t.direction=q(t.offsetX,t.offsetY))},start:p=>{if(o(),p.touches){const m=p.touches[0];t.startX=m.clientX,t.startY=m.clientY}else t.startX=p.clientX,t.startY=p.clientY;t.startTime=Date.now()},reset:o,isVertical:e,isHorizontal:n,state:t}}function H(t){return t===window}const G=t=>{const e=r.unref(t);if(H(e)){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},J=(t,e,n)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const o=document.createEvent("Events");let i=!0,h=!0;for(let m in e)m==="bubbles"?i=!!e[m]:m==="cancelable"?h=!!e[m]:o[m]=e[m];o.initEvent(t,i,h),(n??document).dispatchEvent(o)},K=15,Q=300,Z=200;function tt(t){t.stopPropagation()}function et(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function C(t,e=0,n,o=Z){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function S(t){t.style.transition="",t.style.transform=""}const nt=/^matrix\((.+)\)$/;function A(t){let e=0;const n=t,{transform:o}=window.getComputedStyle(n);if(o){const i=nt.exec(o);i&&(e=+i[1].split(/,\s*/)[4])}return e}const P=new WeakMap;function ot(t,e,n,o,i,h=600,p=60,m=null){const l={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},_=t.previousSibling,u=B(),y=(d,a,v,E)=>{let w=a+l.startDistance;if(v==="end"){const c=G(d);let T=c.width*e;w<T?w=0:w=c.width,l.transitionEndTrigger=()=>{l.moving=!1,d.classList.remove(i),setTimeout(()=>{_&&S(_),w==0?S(d):J(L.FoxLeaveEnd,{},d),l.moving=!1},p)},_&&C(_,0,"",0),w>0&&typeof o=="function"&&o(),C(d,w,"end",E)}else w<0&&(w=0),C(d,w,"",0)},s=()=>{l.transitionEndTrigger&&(l.transitionEndTrigger(),l.transitionEndTrigger=null)},g=d=>{if(u.start(d),l.draging=m?m(t,u.state.startX,u.state.startY):!0,!l.draging){u.reset();return}l.scrollDistance=0,l.moving&&(l.scrollDistance=A(t)),t.classList.add(i),l.transitionEndTrigger=null,l.moving=!0},f=d=>{!l.draging||(l.moving=!0,u.move(d),u.isVertical())||A(t)===0&&u.state.deltaX<0||(tt(d),y(t,u.state.deltaX,"",0))},b=()=>{if(!l.draging||(l.draging=!1,u.isVertical())||A(t)===0&&u.state.deltaX<0)return;const a=u.state.deltaX;if(a===0){t.classList.remove(i),l.moving=!1;return}const v=u.state.duration;if(v<Q&&Math.abs(a)>K){const w=et(a,v,n);y(t,w,"end",h)}else y(t,a,"end",h)};t.addEventListener("transitionend",s),t.addEventListener("transitioncancel",s),t.addEventListener("touchstart",g),t.addEventListener("touchmove",f),t.addEventListener("touchend",b),t.addEventListener("touchcancel",b),P.set(t,{state:l,transitionend:s,transitioncancel:s,touchstart:g,touchmove:f,touchend:b,touchcancel:b})}function it(t){const e=P.get(t);e&&(P.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("transitioncancel",e.transitioncancel),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const st=r.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},resetDelay:{default:120},swipeDuration:{default:60},draggableArea:{},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let n=null,o=null;function i(s){return(s.params&&s.params.animationType)??"slide"}function h(s){return(s.params&&s.params.dragRemove)??e.dragRemove}const p=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"show":"enter";if(a==="show"&&(d==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;a==="enter"&&(n=f,o="enter");const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-active`;s.classList.add(v),s.classList.add(E)}},m=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"show":"enter";if(a==="show"&&(d==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-to`;s.classList.remove(v),s.classList.add(E)}},l=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const a=i(f),v=g?"show":"enter";if(v==="enter"&&(n=null,o=null),a!=="pop"){const E=`fox-root-navigator__${a}-${v}-active`,w=`fox-root-navigator__${a}-${v}-to`;s.classList.remove(E),s.classList.remove(w)}}if(h(f)===!0&&!g&&f.opsType===L.OperationType.Append){let a=null;e.draggableArea&&(a=function(v,E,w){const c=E-v.offsetLeft,T=w-v.offsetTop;return!(e.draggableArea?.left&&c<e.draggableArea?.left||e.draggableArea?.right&&c>e.draggableArea?.right||e.draggableArea?.top&&T<e.draggableArea?.top||e.draggableArea?.bottom&&T>e.draggableArea?.bottom)}),ot(s,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,"fox-root-navigator__item-moving",e.swipeDuration,e.resetDelay,a)}},_=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"hide":"leave";if(a==="hide"&&(d==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;a==="leave"&&(n=f,o="leave");const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-active`;s.classList.add(v),s.classList.add(E)}},u=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"hide":"leave";if(a==="hide"&&(d==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-to`;s.classList.remove(v),s.classList.add(E)}},y=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const a=i(f),v=g?"hide":"leave";if(v==="leave"&&(n=null,o=null),a!=="pop"){const E=`fox-root-navigator__${a}-${v}-active`,w=`fox-root-navigator__${a}-${v}-to`;s.classList.remove(E),s.classList.remove(w)}}h(f)&&!g&&it(s)};return(s,g)=>{const f=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(f,{class:"fox-root-navigator","view-class":s.viewClass,"before-enter":p,enter:m,"after-enter":l,"before-leave":_,leave:u,"after-leave":y,multi:!0,name:s.routerViewName,"view-tag":s.viewTag,transition:s.transition},null,8,["view-class","name","view-tag","transition"])}}}),at=Object.freeze(Object.defineProperty({__proto__:null,default:st},Symbol.toStringTag,{value:"Module"})),rt={class:"fox-swiper-navigator"},ct=r.defineComponent({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,n=r.computed(()=>{const o={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(o["transition-duration"]=`${e.scrollDuration}ms`),o});return(o,i)=>(r.openBlock(),r.createElementBlock("div",rt,[r.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:r.normalizeStyle(n.value)},[r.renderSlot(o.$slots,"default")],4)]))}});let lt=0;function ut(){return++lt}const dt=15,ft=300,ht=200;function mt(t){t.stopPropagation()}function pt(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function I(t,e=0,n,o=ht){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}class gt{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;moveRatio=.5;momentumReduceRatio=1;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,n,o,i,h,p){this.getStartDistance=e,this.openPage=n,this.isPageOpened=o,this.pageOpened=i,this.moveRatio=h,this.momentumReduceRatio=p}open(){const e=this.el,n=B(),o=(i,h,p,m)=>{let l=h+this.startDistance;const _=this.columnWidth*this.moveRatio;if(p==="end"){if(h==0){this.moving=!1;return}Math.abs(h)>_?h>0?l=this.startDistance+this.columnWidth:l=this.startDistance-this.columnWidth:l=this.startDistance;let u=-l;u<0?u=0:u>this.width-this.columnWidth&&(u=this.width-this.columnWidth);const y=Math.floor(u/this.columnWidth);this.isPageOpened(y)||this.openPage(y),l=-y*this.columnWidth,m&&m>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(y)}),I(i,l,"end",m),this.scrollDistance=l}else{if(Math.abs(h)>_){let y=0;if(h>0?y=Math.abs(this.startDistance+this.columnWidth):y=Math.abs(this.startDistance-this.columnWidth),y>=0&&y<this.width){const s=Math.floor(y/this.columnWidth);this.isPageOpened(s)||this.openPage(s)}}let u=-l;u<this.min?u=this.min:u>this.max&&(u=this.max),I(i,-u,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=i=>{this.moving||(n.start(i),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=i=>{n.move(i),!n.isVertical()&&(mt(i),o(e,n.state.deltaX,"",0))},this.touchend=()=>{if(n.isVertical())return;const i=n.state.deltaX;if(i==0)return;const h=n.state.duration;if(h<ft&&Math.abs(i)>dt){const m=pt(i,h,this.momentumReduceRatio);o(e,m,"end",this.swipeDuration)}else o(e,i,"end",this.swipeDuration)},e.addEventListener("transitionend",this.transitionend),e.addEventListener("touchstart",this.touchstart),e.addEventListener("touchmove",this.touchmove),e.addEventListener("touchend",this.touchend),e.addEventListener("touchcancel",this.touchend)}close(){const e=this.el;this.transitionend&&e.addEventListener("transitionend",this.transitionend),this.touchstart&&e.addEventListener("touchstart",this.touchstart),this.touchmove&&e.addEventListener("touchmove",this.touchmove),this.touchend&&e.addEventListener("touchend",this.touchend),this.touchcancel&&e.addEventListener("touchcancel",this.touchcancel),this.el=null}}function vt(t,e,n,o,i,h){return new gt(t,e,n,o,i,h)}function _t(t){const e=r.unref(t),n=window.getComputedStyle(e,null),o=parseFloat(n.getPropertyValue("padding-left")),i=parseFloat(n.getPropertyValue("padding-right")),h=parseFloat(n.getPropertyValue("padding-top")),p=parseFloat(n.getPropertyValue("padding-bottom"));return{width:e.clientWidth-o-i,height:e.clientHeight-h-p}}const wt=r.defineComponent({__name:"index",props:{activePath:{},routes:{},height:{default:-1},width:{default:-1},draggable:{type:Boolean,default:!0},openViewPage:{},routerViewName:{},moveRatio:{default:.5},momentumReduceRatio:{default:1},direction:{default:"horizontal"},transition:{type:[Function,Boolean],default:!0},swipeDuration:{default:360},scrollDuration:{},customClass:{},customStyle:{}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,o=r.reactive({scrollDistance:0,index:-1,openedIndexList:[],width:n.width,height:n.height}),i=e,h=()=>o.scrollDistance,p=c=>{if(o.openedIndexList.indexOf(c)===-1){o.openedIndexList.push(c);const T=n.routes[c];try{n.openViewPage(T,c)}catch(x){console.error(x)}}},m=c=>o.openedIndexList.indexOf(c)!==-1,l=c=>{o.index=c,o.width>0?o.scrollDistance=-o.index*o.width:o.scrollDistance=0;const T=n.routes[c];i("update:activePath",T.path)};let _=null;n.draggable&&(_=vt(h,p,m,l,n.moveRatio,n.momentumReduceRatio));let u=null;r.onMounted(()=>{const c=d(),T=()=>{const x=_t(c);y(n.activePath,n.routes,x.width,x.height,n.swipeDuration,n.direction)};if(window.ResizeObserver&&(u=new window.ResizeObserver(T),u.observe(c)),T(),_){const x=v();_.el=x,_.open()}}),r.onBeforeUnmount(()=>{u&&(u.disconnect(),u=null),_&&_.close()}),r.watch([()=>n.activePath,()=>n.routes,()=>n.width,()=>n.height,()=>n.swipeDuration,()=>n.direction],([c,T,x,$,M,R])=>{const O=x<=0?o.width:x,D=$<=0?o.height:$;y(c,T,O,D,M,R)});const y=(c,T,x,$,M,R="horizontal")=>{const O=c;if(o.index=T.findIndex(D=>D.path===O),R==="horizontal"){const D=x;if(D>0){o.width=x;const z=D*n.routes.length,N=-D/3,W=D*(T.length-1)+D/3;_&&(_.columnWidth=D,_.width=z,_.min=N,_.max=W),o.index!==-1&&(o.openedIndexList.push(o.index),o.scrollDistance=-D*o.index)}}_&&(_.swipeDuration=M)},s=`fox-swiper-navigator-${ut()}`,g=r.computed(()=>{const c=[s];return n.customClass&&c.push(n.customClass),c}),f=r.computed(()=>{const c={},T=o.width>0?o.width:n.width;T>0&&(c.width=`${T}px`);const x=o.height>0?o.height:n.height;return x>0&&(c.height=`${x}px`),n.customStyle&&Object.assign(c,n.customStyle),c});let b=null;function d(){return b||(b=document.querySelector(`.${s}`),b)}let a=null;function v(){return a||(a=document.querySelector(`.${s}>.fox-swiper-navigator__inner`),a)}const E=r.computed(()=>o.width>0?`${o.width*n.routes.length}px`:"100%"),w=(c,T)=>{const x=n.routes.findIndex($=>{const M=c.path??c.name??"";return $.path==M});return o.width<=0?{}:{style:{left:`${x*o.width}px`,width:`${o.width}px`}}};return(c,T)=>{const x=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(x,{class:r.normalizeClass(g.value),style:r.normalizeStyle(f.value),"view-class":"fox-swiper-navigator__item",tag:ct,"view-tag-props":w,multi:!0,name:c.routerViewName,transition:c.transition,"scroll-distance":o.scrollDistance,"scroll-duration":c.scrollDuration,direction:c.direction,width:E.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),Tt=Object.freeze(Object.defineProperty({__proto__:null,default:wt},Symbol.toStringTag,{value:"Module"}));let yt="fox-";const xt=[],Y=Object.assign({"/src/components/card-navigator/index.vue":F,"/src/components/default-navigator/index.vue":j,"/src/components/root-navigator/index.vue":at,"/src/components/swiper-navigator/index.vue":Tt}),V=[];for(const t in Y){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];xt.indexOf(e)===-1&&V.push({name:e,component:Y[t].default})}const Et={install(t){V.forEach(e=>{t.component(`${yt}${e.name}`,e.component)})}};module.exports=Et;