@fox-js/navigation 4.0.1-24 → 4.0.1-25

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 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let f=require("vue"),$=require("@fox-js/fox");var Q=(0,f.defineComponent)({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,i)=>{const n=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(n,{transition:!1,multi:!1,name:t.routerViewName},{default:(0,f.withCtx)(({Component:l})=>[(0,f.createVNode)(f.Transition,{name:"fox-default-navigator__trans"},{default:(0,f.withCtx)(()=>[((0,f.openBlock)(),(0,f.createBlock)((0,f.resolveDynamicComponent)(l)))]),_:2},1024)]),_:1},8,["name"])}}}),F=Q,I=10;function Z(t,e){return t>e&&t>I?"horizontal":e>t&&e>I?"vertical":""}function S(){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",i=()=>t.direction==="horizontal",n=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:(g=>{if(g.touches){const w=g.touches[0];t.deltaX=w.clientX-t.startX,t.deltaY=w.clientY-t.startY,t.moveX=w.clientX,t.moveY=w.clientY}else t.deltaX=g.clientX-t.startX,t.deltaY=g.clientY-t.startY,t.moveX=g.clientX,t.moveY=g.clientY;t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.duration=Date.now()-t.startTime,t.direction||(t.direction=Z(t.offsetX,t.offsetY))}),start:(g=>{if(n(),g.touches){const w=g.touches[0];t.startX=w.clientX,t.startY=w.clientY}else t.startX=g.clientX,t.startY=g.clientY;t.startTime=Date.now()}),reset:n,isVertical:e,isHorizontal:i,state:t}}function tt(t){return t===window}var N=t=>{const e=(0,f.unref)(t);if(tt(e)){const i=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:i,bottom:n,width:i,height:n}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},W=(t,e,i)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const n=document.createEvent("Events");let l=!0,m=!0;for(let g in e)g==="bubbles"?l=!!e[g]:g==="cancelable"?m=!!e[g]:n[g]=e[g];n.initEvent(t,l,m),(i??document).dispatchEvent(n)},et=15,nt=300,it=200;function ot(t){t.stopPropagation()}function at(t,e,i=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*i}function C(t,e=0,i,n=it){i==="end"?t.style.transition=`transform ${n}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function B(t){t.style.transition="",t.style.transform=""}var rt=/^matrix\((.+)\)$/;function R(t){let e=0;const i=t,{transform:n}=window.getComputedStyle(i);if(n){const l=rt.exec(n);l&&(e=+l[1].split(/,\s*/)[4])}return e}var X=new WeakMap;function st(t,e,i,n,l,m,g=600,w=60,E=null){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},T=t.previousSibling,p=S(),r=(o,v,h,L)=>{let d=v+a.startDistance;if(h==="end"){const y=N(o);let _=y.width*e;d<_?d=0:d=y.width,a.transitionEndTrigger=()=>{a.moving=!1,m&&o.classList.remove(m),setTimeout(()=>{T&&B(T),d==0?B(o):W($.FoxLeaveEnd,{},o),a.moving=!1},w)},T&&C(T,0,"",0),d>0&&typeof n=="function"&&n(l),C(o,d,"end",L)}else d<0&&(d=0),C(o,d,"",0)},u=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},c=o=>{if(p.start(o),a.draging=E?E(t,p.state.startX,p.state.startY):!0,!a.draging){p.reset();return}a.scrollDistance=0,a.moving&&(a.scrollDistance=R(t)),m&&t.classList.add(m),a.transitionEndTrigger=null,a.moving=!0},x=o=>{a.draging&&(a.moving=!0,p.move(o),!p.isVertical()&&(R(t)===0&&p.state.deltaX<0||(ot(o),r(t,p.state.deltaX,"",0))))},s=()=>{if(!a.draging||(a.draging=!1,p.isVertical())||R(t)===0&&p.state.deltaX<0)return;const o=p.state.deltaX;if(o===0){m&&t.classList.remove(m),a.moving=!1;return}const v=p.state.duration;v<nt&&Math.abs(o)>et?r(t,at(o,v,i),"end",g):r(t,o,"end",g)};t.addEventListener("transitionend",u),t.addEventListener("transitioncancel",u),t.addEventListener("touchstart",c),t.addEventListener("touchmove",x),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),X.set(t,{state:a,transitionend:u,transitioncancel:u,touchstart:c,touchmove:x,touchend:s,touchcancel:s})}function ct(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))}var lt=(0,f.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},transitionDuration:{},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let i=null,n=null;function l(r){return(r&&r.params&&r.params.animationType)??"slide"}function m(r){return(r&&r.params&&r.params.dragRemove)??e.dragRemove}const g=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"show":"enter";if(o==="show"&&(s==="pop"||n!=="leave"||(i?l(i):"")==="pop"))return;o==="enter"&&(i=c,n="enter");const v=`fox-root-navigator--${s}-${o}-from`,h=`fox-root-navigator--${s}-${o}-active`;r.classList.add(v),r.classList.add(h)}},w=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"show":"enter";if(o==="show"&&(s==="pop"||n!=="leave"||(i?l(i):"")==="pop"))return;const v=`fox-root-navigator--${s}-${o}-from`,h=`fox-root-navigator--${s}-${o}-to`;r.classList.remove(v),r.classList.add(h)}},E=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"show":"enter";if(o==="enter"&&(i=null,n=null),s!=="pop"){const v=`fox-root-navigator--${s}-${o}-active`,h=`fox-root-navigator--${s}-${o}-to`;r.classList.remove(v),r.classList.remove(h)}}if(m(c)===!0&&!u&&c?.opsType===$.OperationType.Append){let s=null;e.draggableArea&&(s=function(o,v,h){const L=v-o.offsetLeft,d=h-o.offsetTop;return!(e.draggableArea?.left&&L<e.draggableArea?.left||e.draggableArea?.right&&L>e.draggableArea?.right||e.draggableArea?.top&&d<e.draggableArea?.top||e.draggableArea?.bottom&&d>e.draggableArea?.bottom)}),st(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,c,"fox-root-navigator__item--moving",e.swipeDuration,e.resetDelay,s)}},a=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"hide":"leave";if(o==="hide"&&(s==="pop"||n!=="enter"||(i?l(i):"")==="pop"))return;o==="leave"&&(i=c,n="leave");const v=`fox-root-navigator--${s}-${o}-from`,h=`fox-root-navigator--${s}-${o}-active`;r.classList.add(v),r.classList.add(h)}},T=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"hide":"leave";if(o==="hide"&&(s==="pop"||n!=="enter"||(i?l(i):"")==="pop"))return;const v=`fox-root-navigator--${s}-${o}-from`,h=`fox-root-navigator--${s}-${o}-to`;r.classList.remove(v),r.classList.add(h)}},p=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"hide":"leave";if(o==="leave"&&(i=null,n=null),s!=="pop"){const v=`fox-root-navigator--${s}-${o}-active`,h=`fox-root-navigator--${s}-${o}-to`;r.classList.remove(v),r.classList.remove(h)}}m(c)&&!u&&ct(r)};return(r,u)=>{const c=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":g,enter:w,"after-enter":E,"before-leave":a,leave:T,"after-leave":p,multi:!0,name:t.routerViewName,"view-tag":t.viewTag,transition:t.transition,"transition-duration":t.transitionDuration},null,8,["view-class","name","view-tag","transition","transition-duration"])}}}),z=lt,dt=(0,f.defineComponent)({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,i)=>{const n=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(n,{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:t.transition,multi:!0,name:t.routerViewName},null,8,["transition","name"])}}}),U=dt,ut=15,ft=300,vt=200;function gt(t){t.stopPropagation()}function pt(t,e,i=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*i}function O(t,e=0,i,n=vt){i==="end"?t.style.transition=`transform ${n}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function V(t){t.style.transition="",t.style.transform=""}var mt=/^matrix\((.+)\)$/;function P(t){let e=0;const i=t,{transform:n}=window.getComputedStyle(i);if(n){const l=mt.exec(n);l&&(e=+l[1].split(/,\s*/)[4])}return e}var k=new WeakMap;function ht(t,e,i,n,l,m,g=600,w=60,E=null){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},T=t.previousSibling,p=S(),r=(o,v,h,L)=>{let d=v+a.startDistance;if(h==="end"){const y=N(o);let _=y.width*e;d<_?d=0:d=y.width,a.transitionEndTrigger=()=>{a.moving=!1,m&&o.classList.remove(m),setTimeout(()=>{T&&V(T),d==0?V(o):W($.FoxLeaveEnd,{},o),a.moving=!1},w)},T&&O(T,0,"",0),d>0&&typeof n=="function"&&n(l),O(o,d,"end",L)}else d<0&&(d=0),O(o,d,"",0)},u=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},c=o=>{if(p.start(o),a.draging=E?E(t,p.state.startX,p.state.startY):!0,!a.draging){p.reset();return}a.scrollDistance=0,a.moving&&(a.scrollDistance=P(t)),m&&t.classList.add(m),a.transitionEndTrigger=null,a.moving=!0},x=o=>{a.draging&&(a.moving=!0,p.move(o),!p.isVertical()&&(P(t)===0&&p.state.deltaX<0||(gt(o),r(t,p.state.deltaX,"",0))))},s=()=>{if(!a.draging||(a.draging=!1,p.isVertical())||P(t)===0&&p.state.deltaX<0)return;const o=p.state.deltaX;if(o===0){m&&t.classList.remove(m),a.moving=!1;return}const v=p.state.duration;v<ft&&Math.abs(o)>ut?r(t,pt(o,v,i),"end",g):r(t,o,"end",g)};t.addEventListener("transitionend",u),t.addEventListener("transitioncancel",u),t.addEventListener("touchstart",c),t.addEventListener("touchmove",x),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),k.set(t,{state:a,transitionend:u,transitioncancel:u,touchstart:c,touchmove:x,touchend:s,touchcancel:s})}function Tt(t){const e=k.get(t);e&&(k.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))}var wt=(0,f.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},transitionDuration:{},viewClass:{type:[Function,String],default:"fox-stack-navigator__item"}},setup(t){const e=t;let i=null,n=null;function l(r){return(r&&r.params&&r.params.animationType)??"slide"}function m(r){return(r&&r.params&&r.params.dragRemove)??e.dragRemove}const g=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"show":"enter";if(o==="show"&&(s==="pop"||n!=="leave"||(i?l(i):"")==="pop"))return;o==="enter"&&(i=c,n="enter");const v=`fox-stack-navigator--${s}-${o}-from`,h=`fox-stack-navigator--${s}-${o}-active`;r.classList.add(v),r.classList.add(h)}},w=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"show":"enter";if(o==="show"&&(s==="pop"||n!=="leave"||(i?l(i):"")==="pop"))return;const v=`fox-stack-navigator--${s}-${o}-from`,h=`fox-stack-navigator--${s}-${o}-to`;r.classList.remove(v),r.classList.add(h)}},E=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"show":"enter";if(o==="enter"&&(i=null,n=null),s!=="pop"){const v=`fox-stack-navigator--${s}-${o}-active`,h=`fox-stack-navigator--${s}-${o}-to`;r.classList.remove(v),r.classList.remove(h)}}if(m(c)===!0&&!u&&c?.opsType===$.OperationType.Append){let s=null;e.draggableArea&&(s=function(o,v,h){const L=v-o.offsetLeft,d=h-o.offsetTop;return!(e.draggableArea?.left&&L<e.draggableArea?.left||e.draggableArea?.right&&L>e.draggableArea?.right||e.draggableArea?.top&&d<e.draggableArea?.top||e.draggableArea?.bottom&&d>e.draggableArea?.bottom)}),ht(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,c,"fox-stack-navigator__item--moving",e.swipeDuration,e.resetDelay,s)}},a=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"hide":"leave";if(o==="hide"&&(s==="pop"||n!=="enter"||(i?l(i):"")==="pop"))return;o==="leave"&&(i=c,n="leave");const v=`fox-stack-navigator--${s}-${o}-from`,h=`fox-stack-navigator--${s}-${o}-active`;r.classList.add(v),r.classList.add(h)}},T=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"hide":"leave";if(o==="hide"&&(s==="pop"||n!=="enter"||(i?l(i):"")==="pop"))return;const v=`fox-stack-navigator--${s}-${o}-from`,h=`fox-stack-navigator--${s}-${o}-to`;r.classList.remove(v),r.classList.add(h)}},p=(r,u,c,x)=>{if(c?.opsType===$.OperationType.Append||u){const s=l(c),o=u?"hide":"leave";if(o==="leave"&&(i=null,n=null),s!=="pop"){const v=`fox-stack-navigator--${s}-${o}-active`,h=`fox-stack-navigator--${s}-${o}-to`;r.classList.remove(v),r.classList.remove(h)}}m(c)&&!u&&Tt(r)};return(r,u)=>{const c=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(c,{class:"fox-stack-navigator","view-class":t.viewClass,"before-enter":g,enter:w,"after-enter":E,"before-leave":a,leave:T,"after-leave":p,multi:!0,name:t.routerViewName,"view-tag":t.viewTag,transition:t.transition,"transition-duration":t.transitionDuration},null,8,["view-class","name","view-tag","transition","transition-duration"])}}}),q=wt,_t={class:"fox-swiper-navigator"},xt=(0,f.defineComponent)({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,i=(0,f.computed)(()=>{const n={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(n["transition-duration"]=`${e.scrollDuration}ms`),n});return(n,l)=>((0,f.openBlock)(),(0,f.createElementBlock)("div",_t,[(0,f.createElementVNode)("div",{class:"fox-swiper-navigator__inner",style:(0,f.normalizeStyle)(i.value)},[(0,f.renderSlot)(n.$slots,"default")],4)]))}}),yt=xt,$t=0;function Et(){return++$t}var Lt=15,Dt=300,bt=200;function Mt(t){t.stopPropagation()}function At(t,e,i=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*i}function Y(t,e=0,i,n=bt){i==="end"?t.style.transition=`transform ${n}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}var Ct=class{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(t,e,i,n,l,m){this.getStartDistance=t,this.openPage=e,this.isPageOpened=i,this.pageOpened=n,this.moveRatio=l,this.momentumReduceRatio=m}open(){const t=this.el,e=S(),i=(n,l,m,g)=>{let w=l+this.startDistance;const E=this.columnWidth*this.moveRatio;if(m==="end"){if(l==0){this.moving=!1;return}Math.abs(l)>E?l>0?w=this.startDistance+this.columnWidth:w=this.startDistance-this.columnWidth:w=this.startDistance;let a=-w;a<0?a=0:a>this.width-this.columnWidth&&(a=this.width-this.columnWidth);const T=Math.floor(a/this.columnWidth);this.isPageOpened(T)||this.openPage(T),w=-T*this.columnWidth,g&&g>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(T)}),Y(n,w,"end",g),this.scrollDistance=w}else{if(Math.abs(l)>E){let T=0;if(l>0?T=Math.abs(this.startDistance+this.columnWidth):T=Math.abs(this.startDistance-this.columnWidth),T>=0&&T<this.width){const p=Math.floor(T/this.columnWidth);this.isPageOpened(p)||this.openPage(p)}}let a=-w;a<this.min?a=this.min:a>this.max&&(a=this.max),Y(n,-a,"",0)}};this.transitionend=()=>{t.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=n=>{this.moving||(e.start(n),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=n=>{e.move(n),!e.isVertical()&&(Mt(n),i(t,e.state.deltaX,"",0))},this.touchend=()=>{if(e.isVertical())return;const n=e.state.deltaX;if(n==0)return;const l=e.state.duration;l<Dt&&Math.abs(n)>Lt?i(t,At(n,l,this.momentumReduceRatio),"end",this.swipeDuration):i(t,n,"end",this.swipeDuration)},t.addEventListener("transitionend",this.transitionend),t.addEventListener("touchstart",this.touchstart),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.touchend)}close(){const t=this.el;this.transitionend&&t.addEventListener("transitionend",this.transitionend),this.touchstart&&t.addEventListener("touchstart",this.touchstart),this.touchmove&&t.addEventListener("touchmove",this.touchmove),this.touchend&&t.addEventListener("touchend",this.touchend),this.touchcancel&&t.addEventListener("touchcancel",this.touchcancel),this.el=null}};function Rt(t,e,i,n,l,m){return new Ct(t,e,i,n,l,m)}function Ot(t){const e=(0,f.unref)(t),i=window.getComputedStyle(e,null),n=parseFloat(i.getPropertyValue("padding-left")),l=parseFloat(i.getPropertyValue("padding-right")),m=parseFloat(i.getPropertyValue("padding-top")),g=parseFloat(i.getPropertyValue("padding-bottom"));return{width:e.clientWidth-n-l,height:e.clientHeight-m-g}}var Pt=(0,f.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 i=t,n=(0,f.reactive)({scrollDistance:0,index:-1,openedIndexList:[],width:i.width,height:i.height}),l=e,m=()=>n.scrollDistance,g=d=>{if(n.openedIndexList.indexOf(d)===-1){n.openedIndexList.push(d);const y=i.routes[d];try{i.openViewPage(y,d)}catch(_){console.error(_)}}},w=d=>n.openedIndexList.indexOf(d)!==-1,E=d=>{n.index=d,n.width>0?n.scrollDistance=-n.index*n.width:n.scrollDistance=0;const y=i.routes[d];l("update:activePath",y.path)};let a=null;i.draggable&&(a=Rt(m,g,w,E,i.moveRatio,i.momentumReduceRatio));let T=null;(0,f.onMounted)(()=>{const d=s(),y=()=>{const _=Ot(d);p(i.activePath,i.routes,_.width,_.height,i.swipeDuration,i.direction)};if(window.ResizeObserver&&(T=new window.ResizeObserver(y),T.observe(d)),y(),a){const _=v();a.el=_,a.open()}}),(0,f.onBeforeUnmount)(()=>{T&&(T.disconnect(),T=null),a&&a.close()}),(0,f.watch)([()=>i.activePath,()=>i.routes,()=>i.width,()=>i.height,()=>i.swipeDuration,()=>i.direction],([d,y,_,b,M,A])=>{p(d,y,_<=0?n.width:_,b<=0?n.height:b,M,A)});const p=(d,y,_,b,M,A="horizontal")=>{const H=d;if(n.index=y.findIndex(D=>D.path===H),A==="horizontal"){const D=_;if(D>0){n.width=_;const G=D*i.routes.length,J=-D/3,K=D*(y.length-1)+D/3;a&&(a.columnWidth=D,a.width=G,a.min=J,a.max=K),n.index!==-1&&(n.openedIndexList.push(n.index),n.scrollDistance=-D*n.index)}}a&&(a.swipeDuration=M)},r=`fox-swiper-navigator-${Et()}`,u=(0,f.computed)(()=>{const d=[r];return i.customClass&&d.push(i.customClass),d}),c=(0,f.computed)(()=>{const d={},y=n.width>0?n.width:i.width;y>0&&(d.width=`${y}px`);const _=n.height>0?n.height:i.height;return _>0&&(d.height=`${_}px`),i.customStyle&&Object.assign(d,i.customStyle),d});let x=null;function s(){return x||(x=document.querySelector(`.${r}`),x)}let o=null;function v(){return o||(o=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),o)}const h=(0,f.computed)(()=>n.width>0?`${n.width*i.routes.length}px`:"100%"),L=(d,y)=>{const _=i.routes.findIndex(b=>{const M=d.path??d.name??"";return b.path==M});return n.width<=0?{}:{style:{left:`${_*n.width}px`,width:`${n.width}px`}}};return(d,y)=>{const _=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(_,{class:(0,f.normalizeClass)(u.value),style:(0,f.normalizeStyle)(c.value),"view-class":"fox-swiper-navigator__item",tag:yt,"view-tag-props":L,multi:!0,name:t.routerViewName,transition:t.transition,"scroll-distance":n.scrollDistance,"scroll-duration":t.scrollDuration,direction:t.direction,width:h.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),j=Pt,Xt={install(t,e="fox"){t.component(`${e}-default-navigator`,F),t.component(`${e}-root-navigator`,z),t.component(`${e}-card-navigator`,U),t.component(`${e}-stack-navigator`,q),t.component(`${e}-swiper-navigator`,j)}};exports.FoxCardNavigator=U;exports.FoxDefaultNavigator=F;exports.FoxRootNavigator=z;exports.FoxStackNavigator=q;exports.FoxSwiperNavigator=j;exports.default=Xt;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let f=require("vue"),$=require("@fox-js/fox");var Q=(0,f.defineComponent)({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,o)=>{const n=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(n,{transition:!1,multi:!1,name:t.routerViewName},{default:(0,f.withCtx)(({Component:l})=>[(0,f.createVNode)(f.Transition,{name:"fox-default-navigator__trans"},{default:(0,f.withCtx)(()=>[((0,f.openBlock)(),(0,f.createBlock)((0,f.resolveDynamicComponent)(l)))]),_:2},1024)]),_:1},8,["name"])}}}),N=Q,B=10;function Z(t,e){return t>e&&t>B?"horizontal":e>t&&e>B?"vertical":""}function I(){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",o=()=>t.direction==="horizontal",n=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:(m=>{if(m.touches){const w=m.touches[0];t.deltaX=w.clientX-t.startX,t.deltaY=w.clientY-t.startY,t.moveX=w.clientX,t.moveY=w.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=Z(t.offsetX,t.offsetY))}),start:(m=>{if(n(),m.touches){const w=m.touches[0];t.startX=w.clientX,t.startY=w.clientY}else t.startX=m.clientX,t.startY=m.clientY;t.startTime=Date.now()}),reset:n,isVertical:e,isHorizontal:o,state:t}}function tt(t){return t===window}var W=t=>{const e=(0,f.unref)(t);if(tt(e)){const o=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:o,bottom:n,width:o,height:n}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},z=(t,e,o)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const n=document.createEvent("Events");let l=!0,p=!0;for(let m in e)m==="bubbles"?l=!!e[m]:m==="cancelable"?p=!!e[m]:n[m]=e[m];n.initEvent(t,l,p),(o??document).dispatchEvent(n)},et=15,nt=300,ot=200;function it(t){t.stopPropagation()}function at(t,e,o=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*o}function R(t,e=0,o,n=ot){o==="end"?t.style.transition=`transform ${n}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function V(t){t.style.transition="",t.style.transform=""}var rt=/^matrix\((.+)\)$/;function O(t){let e=0;const o=t,{transform:n}=window.getComputedStyle(o);if(n){const l=rt.exec(n);l&&(e=+l[1].split(/,\s*/)[4])}return e}var k=new WeakMap;function st(t,e,o,n,l,p,m=600,w=60,E=null){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},T=t.previousSibling,h=I(),r=(i,v,g,L)=>{let u=v+a.startDistance;if(g==="end"){const y=W(i);let _=y.width*e;u<_?u=0:u=y.width,a.transitionEndTrigger=()=>{a.moving=!1,p&&i.classList.remove(p),setTimeout(()=>{T&&V(T),u==0?V(i):z($.FoxLeaveEnd,{},i),a.moving=!1},w)},T&&R(T,0,"",0),u>0&&typeof n=="function"&&n(l),R(i,u,"end",L)}else u<0&&(u=0),R(i,u,"",0)},d=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},c=i=>{if(h.start(i),a.draging=E?E(t,h.state.startX,h.state.startY):!0,!a.draging){h.reset();return}a.scrollDistance=0,a.moving&&(a.scrollDistance=O(t)),p&&t.classList.add(p),a.transitionEndTrigger=null,a.moving=!0},x=i=>{a.draging&&(a.moving=!0,h.move(i),!h.isVertical()&&(O(t)===0&&h.state.deltaX<0||(it(i),r(t,h.state.deltaX,"",0))))},s=()=>{if(!a.draging||(a.draging=!1,h.isVertical())||O(t)===0&&h.state.deltaX<0)return;const i=h.state.deltaX;if(i===0){p&&t.classList.remove(p),a.moving=!1;return}const v=h.state.duration;if(v<nt&&Math.abs(i)>et){const g=at(i,v,o);r(t,g,"end",m)}else r(t,i,"end",m)};t.addEventListener("transitionend",d),t.addEventListener("transitioncancel",d),t.addEventListener("touchstart",c),t.addEventListener("touchmove",x),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),k.set(t,{state:a,transitionend:d,transitioncancel:d,touchstart:c,touchmove:x,touchend:s,touchcancel:s})}function ct(t){const e=k.get(t);e&&(k.delete(t),t.removeEventListener("transitionend",e.transitionend),t.removeEventListener("transitioncancel",e.transitioncancel),t.removeEventListener("touchstart",e.touchstart),t.removeEventListener("touchmove",e.touchmove),t.removeEventListener("touchend",e.touchend),t.removeEventListener("touchcancel",e.touchcancel))}var lt=(0,f.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},transitionDuration:{},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let o=null,n=null;function l(r){return(r&&r.params&&r.params.animationType)??"slide"}function p(r){return(r&&r.params&&r.params.dragRemove)??e.dragRemove}const m=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="show"&&(s==="pop"||n!=="leave"||(o?l(o):"")==="pop"))return;i==="enter"&&(o=c,n="enter");const v=`fox-root-navigator--${s}-${i}-from`,g=`fox-root-navigator--${s}-${i}-active`;r.classList.add(v),r.classList.add(g)}},w=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="show"&&(s==="pop"||n!=="leave"||(o?l(o):"")==="pop"))return;const v=`fox-root-navigator--${s}-${i}-from`,g=`fox-root-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.add(g)}},E=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="enter"&&(o=null,n=null),s!=="pop"){const v=`fox-root-navigator--${s}-${i}-active`,g=`fox-root-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.remove(g)}}if(p(c)===!0&&!d&&c?.opsType===$.OperationType.Append){let s=null;e.draggableArea&&(s=function(i,v,g){const L=v-i.offsetLeft,u=g-i.offsetTop;return!(e.draggableArea?.left&&L<e.draggableArea?.left||e.draggableArea?.right&&L>e.draggableArea?.right||e.draggableArea?.top&&u<e.draggableArea?.top||e.draggableArea?.bottom&&u>e.draggableArea?.bottom)}),st(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,c,"fox-root-navigator__item--moving",e.swipeDuration,e.resetDelay,s)}},a=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="hide"&&(s==="pop"||n!=="enter"||(o?l(o):"")==="pop"))return;i==="leave"&&(o=c,n="leave");const v=`fox-root-navigator--${s}-${i}-from`,g=`fox-root-navigator--${s}-${i}-active`;r.classList.add(v),r.classList.add(g)}},T=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="hide"&&(s==="pop"||n!=="enter"||(o?l(o):"")==="pop"))return;const v=`fox-root-navigator--${s}-${i}-from`,g=`fox-root-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.add(g)}},h=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="leave"&&(o=null,n=null),s!=="pop"){const v=`fox-root-navigator--${s}-${i}-active`,g=`fox-root-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.remove(g)}}p(c)&&!d&&ct(r)};return(r,d)=>{const c=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":m,enter:w,"after-enter":E,"before-leave":a,leave:T,"after-leave":h,multi:!0,name:t.routerViewName,"view-tag":t.viewTag,transition:t.transition,"transition-duration":t.transitionDuration},null,8,["view-class","name","view-tag","transition","transition-duration"])}}}),U=lt,ut=(0,f.defineComponent)({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,o)=>{const n=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(n,{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:t.transition,multi:!0,name:t.routerViewName},null,8,["transition","name"])}}}),q=ut,dt=15,ft=300,vt=200;function gt(t){t.stopPropagation()}function mt(t,e,o=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*o}function P(t,e=0,o,n=vt){o==="end"?t.style.transition=`transform ${n}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function Y(t){t.style.transition="",t.style.transform=""}var pt=/^matrix\((.+)\)$/;function X(t){let e=0;const o=t,{transform:n}=window.getComputedStyle(o);if(n){const l=pt.exec(n);l&&(e=+l[1].split(/,\s*/)[4])}return e}var S=new WeakMap;function ht(t,e,o,n,l,p,m=600,w=60,E=null){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},T=t.previousSibling,h=I(),r=(i,v,g,L)=>{let u=v+a.startDistance;if(g==="end"){const y=W(i);let _=y.width*e;u<_?u=0:u=y.width,a.transitionEndTrigger=()=>{a.moving=!1,p&&i.classList.remove(p),setTimeout(()=>{T&&Y(T),u==0?Y(i):z($.FoxLeaveEnd,{},i),a.moving=!1},w)},T&&P(T,0,"",0),u>0&&typeof n=="function"&&n(l),P(i,u,"end",L)}else u<0&&(u=0),P(i,u,"",0)},d=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},c=i=>{if(h.start(i),a.draging=E?E(t,h.state.startX,h.state.startY):!0,!a.draging){h.reset();return}a.scrollDistance=0,a.moving&&(a.scrollDistance=X(t)),p&&t.classList.add(p),a.transitionEndTrigger=null,a.moving=!0},x=i=>{a.draging&&(a.moving=!0,h.move(i),!h.isVertical()&&(X(t)===0&&h.state.deltaX<0||(gt(i),r(t,h.state.deltaX,"",0))))},s=()=>{if(!a.draging||(a.draging=!1,h.isVertical())||X(t)===0&&h.state.deltaX<0)return;const i=h.state.deltaX;if(i===0){p&&t.classList.remove(p),a.moving=!1;return}const v=h.state.duration;if(v<ft&&Math.abs(i)>dt){const g=mt(i,v,o);r(t,g,"end",m)}else r(t,i,"end",m)};t.addEventListener("transitionend",d),t.addEventListener("transitioncancel",d),t.addEventListener("touchstart",c),t.addEventListener("touchmove",x),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),S.set(t,{state:a,transitionend:d,transitioncancel:d,touchstart:c,touchmove:x,touchend:s,touchcancel:s})}function Tt(t){const e=S.get(t);e&&(S.delete(t),t.removeEventListener("transitionend",e.transitionend),t.removeEventListener("transitioncancel",e.transitioncancel),t.removeEventListener("touchstart",e.touchstart),t.removeEventListener("touchmove",e.touchmove),t.removeEventListener("touchend",e.touchend),t.removeEventListener("touchcancel",e.touchcancel))}var wt=(0,f.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},transitionDuration:{},viewClass:{type:[Function,String],default:"fox-stack-navigator__item"}},setup(t){const e=t;let o=null,n=null;function l(r){return(r&&r.params&&r.params.animationType)??"slide"}function p(r){return(r&&r.params&&r.params.dragRemove)??e.dragRemove}const m=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="show"&&(s==="pop"||n!=="leave"||(o?l(o):"")==="pop"))return;i==="enter"&&(o=c,n="enter");const v=`fox-stack-navigator--${s}-${i}-from`,g=`fox-stack-navigator--${s}-${i}-active`;r.classList.add(v),r.classList.add(g)}},w=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="show"&&(s==="pop"||n!=="leave"||(o?l(o):"")==="pop"))return;const v=`fox-stack-navigator--${s}-${i}-from`,g=`fox-stack-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.add(g)}},E=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="enter"&&(o=null,n=null),s!=="pop"){const v=`fox-stack-navigator--${s}-${i}-active`,g=`fox-stack-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.remove(g)}}if(p(c)===!0&&!d&&c?.opsType===$.OperationType.Append){let s=null;e.draggableArea&&(s=function(i,v,g){const L=v-i.offsetLeft,u=g-i.offsetTop;return!(e.draggableArea?.left&&L<e.draggableArea?.left||e.draggableArea?.right&&L>e.draggableArea?.right||e.draggableArea?.top&&u<e.draggableArea?.top||e.draggableArea?.bottom&&u>e.draggableArea?.bottom)}),ht(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,c,"fox-stack-navigator__item--moving",e.swipeDuration,e.resetDelay,s)}},a=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="hide"&&(s==="pop"||n!=="enter"||(o?l(o):"")==="pop"))return;i==="leave"&&(o=c,n="leave");const v=`fox-stack-navigator--${s}-${i}-from`,g=`fox-stack-navigator--${s}-${i}-active`;r.classList.add(v),r.classList.add(g)}},T=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="hide"&&(s==="pop"||n!=="enter"||(o?l(o):"")==="pop"))return;const v=`fox-stack-navigator--${s}-${i}-from`,g=`fox-stack-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.add(g)}},h=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="leave"&&(o=null,n=null),s!=="pop"){const v=`fox-stack-navigator--${s}-${i}-active`,g=`fox-stack-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.remove(g)}}p(c)&&!d&&Tt(r)};return(r,d)=>{const c=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(c,{class:"fox-stack-navigator","view-class":t.viewClass,"before-enter":m,enter:w,"after-enter":E,"before-leave":a,leave:T,"after-leave":h,multi:!0,name:t.routerViewName,"view-tag":t.viewTag,transition:t.transition,"transition-duration":t.transitionDuration},null,8,["view-class","name","view-tag","transition","transition-duration"])}}}),j=wt,_t={class:"fox-swiper-navigator"},xt=(0,f.defineComponent)({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,o=(0,f.computed)(()=>{const n={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(n["transition-duration"]=`${e.scrollDuration}ms`),n});return(n,l)=>((0,f.openBlock)(),(0,f.createElementBlock)("div",_t,[(0,f.createElementVNode)("div",{class:"fox-swiper-navigator__inner",style:(0,f.normalizeStyle)(o.value)},[(0,f.renderSlot)(n.$slots,"default")],4)]))}}),yt=xt,$t=0;function Et(){return++$t}var Lt=15,Dt=300,bt=200;function Mt(t){t.stopPropagation()}function At(t,e,o=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*o}function F(t,e=0,o,n=bt){o==="end"?t.style.transition=`transform ${n}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}var Ct=class{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(t,e,o,n,l,p){this.getStartDistance=t,this.openPage=e,this.isPageOpened=o,this.pageOpened=n,this.moveRatio=l,this.momentumReduceRatio=p}open(){const t=this.el,e=I(),o=(n,l,p,m)=>{let w=l+this.startDistance;const E=this.columnWidth*this.moveRatio;if(p==="end"){if(l==0){this.moving=!1;return}Math.abs(l)>E?l>0?w=this.startDistance+this.columnWidth:w=this.startDistance-this.columnWidth:w=this.startDistance;let a=-w;a<0?a=0:a>this.width-this.columnWidth&&(a=this.width-this.columnWidth);const T=Math.floor(a/this.columnWidth);this.isPageOpened(T)||this.openPage(T),w=-T*this.columnWidth,m&&m>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(T)}),F(n,w,"end",m),this.scrollDistance=w}else{if(Math.abs(l)>E){let T=0;if(l>0?T=Math.abs(this.startDistance+this.columnWidth):T=Math.abs(this.startDistance-this.columnWidth),T>=0&&T<this.width){const h=Math.floor(T/this.columnWidth);this.isPageOpened(h)||this.openPage(h)}}let a=-w;a<this.min?a=this.min:a>this.max&&(a=this.max),F(n,-a,"",0)}};this.transitionend=()=>{t.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=n=>{this.moving||(e.start(n),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=n=>{e.move(n),!e.isVertical()&&(Mt(n),o(t,e.state.deltaX,"",0))},this.touchend=()=>{if(e.isVertical())return;const n=e.state.deltaX;if(n==0)return;const l=e.state.duration;if(l<Dt&&Math.abs(n)>Lt){const p=At(n,l,this.momentumReduceRatio);o(t,p,"end",this.swipeDuration)}else o(t,n,"end",this.swipeDuration)},t.addEventListener("transitionend",this.transitionend),t.addEventListener("touchstart",this.touchstart),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.touchend)}close(){const t=this.el;this.transitionend&&t.removeEventListener("transitionend",this.transitionend),this.touchstart&&t.removeEventListener("touchstart",this.touchstart),this.touchmove&&t.removeEventListener("touchmove",this.touchmove),this.touchend&&t.removeEventListener("touchend",this.touchend),this.touchcancel&&t.removeEventListener("touchcancel",this.touchcancel),this.el=null}};function Rt(t,e,o,n,l,p){return new Ct(t,e,o,n,l,p)}function Ot(t){const e=(0,f.unref)(t),o=window.getComputedStyle(e,null),n=parseFloat(o.getPropertyValue("padding-left")),l=parseFloat(o.getPropertyValue("padding-right")),p=parseFloat(o.getPropertyValue("padding-top")),m=parseFloat(o.getPropertyValue("padding-bottom"));return{width:e.clientWidth-n-l,height:e.clientHeight-p-m}}var Pt=(0,f.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 o=t,n=(0,f.reactive)({scrollDistance:0,index:-1,openedIndexList:[],width:o.width,height:o.height}),l=e,p=()=>n.scrollDistance,m=u=>{if(n.openedIndexList.indexOf(u)===-1){n.openedIndexList.push(u);const y=o.routes[u];try{o.openViewPage(y,u)}catch(_){console.error(_)}}},w=u=>n.openedIndexList.indexOf(u)!==-1,E=u=>{n.index=u,n.width>0?n.scrollDistance=-n.index*n.width:n.scrollDistance=0;const y=o.routes[u];l("update:activePath",y.path)};let a=null;o.draggable&&(a=Rt(p,m,w,E,o.moveRatio,o.momentumReduceRatio));let T=null;(0,f.onMounted)(()=>{const u=s(),y=()=>{const _=Ot(u);h(o.activePath,o.routes,_.width,_.height,o.swipeDuration,o.direction)};if(window.ResizeObserver&&(T=new window.ResizeObserver(y),T.observe(u)),y(),a){const _=v();a.el=_,a.open()}}),(0,f.onBeforeUnmount)(()=>{T&&(T.disconnect(),T=null),a&&a.close()}),(0,f.watch)([()=>o.activePath,()=>o.routes,()=>o.width,()=>o.height,()=>o.swipeDuration,()=>o.direction],([u,y,_,b,M,A])=>{const C=_<=0?n.width:_,D=b<=0?n.height:b;h(u,y,C,D,M,A)});const h=(u,y,_,b,M,A="horizontal")=>{const C=u;if(n.index=y.findIndex(D=>D.path===C),A==="horizontal"){const D=_;if(D>0){n.width=_;const G=D*o.routes.length,J=-D/3,K=D*(y.length-1)+D/3;a&&(a.columnWidth=D,a.width=G,a.min=J,a.max=K),n.index!==-1&&(n.openedIndexList.push(n.index),n.scrollDistance=-D*n.index)}}a&&(a.swipeDuration=M)},r=`fox-swiper-navigator-${Et()}`,d=(0,f.computed)(()=>{const u=[r];return o.customClass&&u.push(o.customClass),u}),c=(0,f.computed)(()=>{const u={},y=n.width>0?n.width:o.width;y>0&&(u.width=`${y}px`);const _=n.height>0?n.height:o.height;return _>0&&(u.height=`${_}px`),o.customStyle&&Object.assign(u,o.customStyle),u});let x=null;function s(){return x||(x=document.querySelector(`.${r}`),x)}let i=null;function v(){return i||(i=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),i)}const g=(0,f.computed)(()=>n.width>0?`${n.width*o.routes.length}px`:"100%"),L=(u,y)=>{const _=o.routes.findIndex(b=>{const M=u.path??u.name??"";return b.path==M});return n.width<=0?{}:{style:{left:`${_*n.width}px`,width:`${n.width}px`}}};return(u,y)=>{const _=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(_,{class:(0,f.normalizeClass)(d.value),style:(0,f.normalizeStyle)(c.value),"view-class":"fox-swiper-navigator__item",tag:yt,"view-tag-props":L,multi:!0,name:t.routerViewName,transition:t.transition,"scroll-distance":n.scrollDistance,"scroll-duration":t.scrollDuration,direction:t.direction,width:g.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),H=Pt,Xt={install(t,e="fox"){t.component(`${e}-default-navigator`,N),t.component(`${e}-root-navigator`,U),t.component(`${e}-card-navigator`,q),t.component(`${e}-stack-navigator`,j),t.component(`${e}-swiper-navigator`,H)}};exports.FoxCardNavigator=q;exports.FoxDefaultNavigator=N;exports.FoxRootNavigator=U;exports.FoxStackNavigator=j;exports.FoxSwiperNavigator=H;exports.default=Xt;