@fox-js/navigation 4.0.1-6 → 4.0.1-7
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 +2 -2
- package/dist/index.esm.js +202 -181
- package/dist/index.umd.js +3 -3
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";/*!
|
|
2
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
-
*/const o=require("vue"),C=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,s)=>{const h=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(h,{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"])}}}),R=Object.freeze(Object.defineProperty({__proto__:null,default:C},Symbol.toStringTag,{value:"Module"})),I=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(n,s)=>{const h=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(h,{transition:!1,multi:!1,name:e.routerViewName},{default:o.withCtx(({Component:m})=>[o.createVNode(o.Transition,{name:"fox-default-navigator__trans"},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(m)))]),_:2},1024)]),_:1},8,["name"])}}}),S=Object.freeze(Object.defineProperty({__proto__:null,default:I},Symbol.toStringTag,{value:"Module"})),b=10;function B(t,e){return t>e&&t>b?"horizontal":e>t&&e>b?"vertical":""}function M(){const t=o.ref(0),e=o.ref(0),n=o.ref(0),s=o.ref(0),h=o.ref(0),m=o.ref(0),g=o.ref(0),f=o.ref(0),u=o.ref(0),r=o.ref(0),i=o.ref(""),c=()=>i.value==="vertical",_=()=>i.value==="horizontal",d=()=>{g.value=0,f.value=0,u.value=0,r.value=0,i.value="",n.value=0};return{move:l=>{const p=l.touches[0];g.value=p.clientX-t.value,f.value=p.clientY-e.value,h.value=p.clientX,m.value=p.clientY,u.value=Math.abs(g.value),r.value=Math.abs(f.value),s.value=Date.now()-n.value,i.value||(i.value=B(u.value,r.value))},start:l=>{d(),t.value=l.touches[0].clientX,e.value=l.touches[0].clientY,n.value=Date.now()},reset:d,startX:t,startY:e,startTime:n,duration:s,moveX:h,moveY:m,deltaX:g,deltaY:f,offsetX:u,offsetY:r,direction:i,isVertical:c,isHorizontal:_}}function V(t){return t===window}const W=t=>{const e=o.unref(t);if(V(e)){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},z=15,N=300,k=200;function j(t){t.stopPropagation()}function X(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&j(t)}function A(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function y(t,e=0,n,s=k){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}const D=new WeakMap;function U(t,e,n,s,h=500,m,g=1e3){const f={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},u=t.previousSibling,r=M(),i=(a,l,p,w)=>{let x=l+f.startDistance;if(p==="end"){const T=W(a);let P=T.width*e;x<P?x=0:x=T.width;let E=!1;w&&w>0&&(E=!0,f.transitionEndTrigger=()=>{f.moving=!1,m&&a.classList.remove(m),x>0&&typeof s=="function"&&s()}),y(a,x,"end",w),u&&y(u,0,"",0),!E&&x>0&&typeof s=="function"&&s()}else x<0&&(x=0),y(a,x,"",0)},c=()=>{t.style.transform="",t.style.transition="",f.transitionEndTrigger?(f.transitionEndTrigger(),f.transitionEndTrigger=null,u&&setTimeout(()=>{u&&(u.style.transform="",u.style.transition="")},h)):u&&(u.style.transform="",u.style.transition="")},_=a=>{if(r.start(a),f.moving){const l=t,{transform:p}=window.getComputedStyle(l);f.scrollDistance=+p.slice(7,p.length-1).split(", ")[5]}m&&t.classList.add(m),f.startDistance=f.scrollDistance,f.transitionEndTrigger=null,f.moving=!0},d=a=>{f.moving=!0,r.move(a),r.isHorizontal()&&X(a,!0),i(t,r.deltaX.value,"",0)},v=()=>{const a=r.deltaX.value;if(a==0){m&&t.classList.remove(m);return}const l=r.duration.value;if(l<N&&Math.abs(a)>z){const w=A(a,l,n);i(t,w,"end",g)}else i(t,a,"end",g)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",_),t.addEventListener("touchmove",d),t.addEventListener("touchend",v),t.addEventListener("touchcancel",v),D.set(t,{state:f,transitionend:c,touchstart:_,touchmove:d,touchend:v,touchcancel:v})}function Y(t){const e=D.get(t);e&&(D.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const q=o.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},removeViewPageDuration:{default:500},routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;function n(r){return(r.params&&r.params.animationType)??"slide"}const s=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d==="pop"&&i)return;const v=i?"show":"enter",a=`fox-root-navigator__${d}-${v}-from`,l=`fox-root-navigator__${d}-${v}-active`;r.classList.add(a),r.classList.add(l)}},h=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d==="pop"&&i)return;const v=i?"show":"enter",a=`fox-root-navigator__${d}-${v}-from`,l=`fox-root-navigator__${d}-${v}-to`;r.classList.remove(a),r.classList.add(l)}},m=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d!=="pop"||!i){const v=i?"show":"enter",a=`fox-root-navigator__${d}-${v}-active`,l=`fox-root-navigator__${d}-${v}-to`;r.classList.remove(a),r.classList.remove(l)}}e.dragRemove&&!i&&c.opsType===3&&U(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},g=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d==="pop"&&i)return;const v=i?"hide":"leave",a=`fox-root-navigator__${d}-${v}-from`,l=`fox-root-navigator__${d}-${v}-active`;r.classList.add(a),r.classList.add(l)}},f=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d==="pop"&&i)return;const v=i?"hide":"leave",a=`fox-root-navigator__${d}-${v}-from`,l=`fox-root-navigator__${d}-${v}-to`;r.classList.remove(a),r.classList.add(l)}},u=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d!=="pop"||!i){const v=i?"hide":"leave",a=`fox-root-navigator__${d}-${v}-active`,l=`fox-root-navigator__${d}-${v}-to`;r.classList.remove(a),r.classList.remove(l)}}e.dragRemove&&!i&&Y(r)};return(r,i)=>{const c=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:h,"after-enter":m,"before-leave":g,leave:f,"after-leave":u,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}}),H=Object.freeze(Object.defineProperty({__proto__:null,default:q},Symbol.toStringTag,{value:"Module"})),F={class:"fox-swiper-navigator"},G=o.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=o.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,h)=>(o.openBlock(),o.createElementBlock("div",F,[o.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:o.normalizeStyle(o.unref(n))},[o.renderSlot(s.$slots,"default")],4)]))}});let J=0;function K(){return++J}const Q=15,Z=300,tt=200;function et(t){t.stopPropagation()}function nt(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&et(t)}function ot(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function L(t,e=0,n,s=tt){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}class it{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,s,h,m,g){this.getStartDistance=e,this.openPage=n,this.isPageOpened=s,this.pageOpened=h,this.moveRatio=m,this.momentumReduceRatio=g}open(){const e=this.el,n=M(),s=(h,m,g,f)=>{let u=m+this.startDistance;const r=this.columnWidth*this.moveRatio;if(g==="end"){if(u==0){this.moving=!1;return}Math.abs(m)>r&&(m>0?u=this.startDistance+this.columnWidth:u=this.startDistance-this.columnWidth);let i=-u;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const c=Math.floor(i/this.columnWidth);this.isPageOpened(c)||this.openPage(c),u=-c*this.columnWidth,f&&f>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(c)}),L(h,u,"end",f),this.scrollDistance=u}else{if(Math.abs(m)>r){let c=0;if(m>0?c=Math.abs(this.startDistance+this.columnWidth):c=Math.abs(this.startDistance-this.columnWidth),c>=0&&c<this.width){const _=Math.floor(c/this.columnWidth);this.isPageOpened(_)||this.openPage(_)}}let i=-u;i<this.min?i=this.min:i>this.max&&(i=this.max),L(h,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=h=>{this.moving||(n.start(h),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=h=>{n.move(h),n.isHorizontal()&&nt(h,!0),s(e,n.deltaX.value,"",0)},this.touchend=()=>{const h=n.deltaX.value;if(h==0)return;const m=n.duration.value;if(m<Z&&Math.abs(h)>Q){const f=ot(h,m,this.momentumReduceRatio);s(e,f,"end",this.swipeDuration)}else s(e,h,"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 st(t,e,n,s){return new it(t,e,n,s)}const at=o.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,moveRatio:{default:.5},momentumReduceRatio:{default:1},transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,s=o.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),u=st(()=>s.scrollDistance,a=>{if(s.openedIndexList.indexOf(a)===-1){s.openedIndexList.push(a);const l=n.routes[a];try{n.openViewPage(l,a)}catch(p){console.error(p)}}},a=>s.openedIndexList.indexOf(a)!==-1,a=>{s.index=a,s.scrollDistance=-s.index*n.width;const l=n.routes[a];e("update:activePath",l.path)});o.onMounted(()=>{const a=_();u.el=a,u.open()}),o.onUnmounted(()=>{u.close()}),o.watchEffect(()=>{const a=n.activePath;s.index=n.routes.findIndex(T=>T.path===a);const l=n.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-l*s.index);const p=l*n.routes.length,w=-l/3,x=l*(n.routes.length-1)+l/3;u.columnWidth=l,u.width=p,u.min=w,u.max=x,u.swipeDuration=n.swipeDuration});const r=`fox-swiper-navigator-${K()}`,i=o.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let c=null;function _(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const d=o.computed(()=>`${n.width*n.routes.length}px`),v=(a,l)=>({style:{left:`${n.routes.findIndex(w=>{const x=a.path??a.name??"";return w.path==x})*n.width}px`,width:`${n.width}px`}});return(a,l)=>{const p=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(p,{class:o.normalizeClass(r),style:o.normalizeStyle(o.unref(i)),"view-class":"fox-swiper-navigator__item",tag:G,"view-tag-props":v,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":s.scrollDistance,"scroll-time":n.scrollTime,width:o.unref(d)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}}),rt=Object.freeze(Object.defineProperty({__proto__:null,default:at},Symbol.toStringTag,{value:"Module"}));let ct="fox-";const lt=[],$=Object.assign({"/src/components/card-navigator/index.vue":R,"/src/components/default-navigator/index.vue":S,"/src/components/root-navigator/index.vue":H,"/src/components/swiper-navigator/index.vue":rt}),O=[];for(const t in $){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];lt.indexOf(e)===-1&&O.push({name:e,component:$[t].default})}const ut={install(t){O.forEach(e=>{t.component(`${ct}${e.name}`,e.component)})}};module.exports=ut;
|
|
2
|
+
* @fox-js/navigation v4.0.1-6 Wed Jan 03 2024 16:14:47 GMT+0800 (中国标准时间)
|
|
3
|
+
*/const o=require("vue"),R=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{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"])}}}),I=Object.freeze(Object.defineProperty({__proto__:null,default:R},Symbol.toStringTag,{value:"Module"})),S=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{transition:!1,multi:!1,name:e.routerViewName},{default:o.withCtx(({Component:h})=>[o.createVNode(o.Transition,{name:"fox-default-navigator__trans"},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(h)))]),_:2},1024)]),_:1},8,["name"])}}}),B=Object.freeze(Object.defineProperty({__proto__:null,default:S},Symbol.toStringTag,{value:"Module"})),$=10;function V(t,e){return t>e&&t>$?"horizontal":e>t&&e>$?"vertical":""}function O(){const t=o.ref(0),e=o.ref(0),n=o.ref(0),s=o.ref(0),m=o.ref(0),h=o.ref(0),g=o.ref(0),d=o.ref(0),u=o.ref(0),r=o.ref(0),i=o.ref(""),c=()=>i.value==="vertical",_=()=>i.value==="horizontal",f=()=>{g.value=0,d.value=0,u.value=0,r.value=0,i.value="",n.value=0};return{move:a=>{const p=a.touches[0];g.value=p.clientX-t.value,d.value=p.clientY-e.value,m.value=p.clientX,h.value=p.clientY,u.value=Math.abs(g.value),r.value=Math.abs(d.value),s.value=Date.now()-n.value,i.value||(i.value=V(u.value,r.value))},start:a=>{f(),t.value=a.touches[0].clientX,e.value=a.touches[0].clientY,n.value=Date.now()},reset:f,startX:t,startY:e,startTime:n,duration:s,moveX:m,moveY:h,deltaX:g,deltaY:d,offsetX:u,offsetY:r,direction:i,isVertical:c,isHorizontal:_}}function W(t){return t===window}const z=t=>{const e=o.unref(t);if(W(e)){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},N=15,k=300,j=200;function X(t){t.stopPropagation()}function A(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&X(t)}function U(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function D(t,e=0,n,s=j){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}const E=new WeakMap;function Y(t,e,n,s,m=500,h,g=1e3){const d={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},u=t.previousSibling,r=O(),i=(a,p,T,x)=>{let w=p+d.startDistance;if(T==="end"){const y=z(a);let C=y.width*e;w<C?w=0:w=y.width;let b=!1;x&&x>0&&(b=!0,d.transitionEndTrigger=()=>{d.moving=!1,h&&a.classList.remove(h),w>0&&typeof s=="function"&&s()}),D(a,w,"end",x),u&&D(u,0,"",0),!b&&w>0&&typeof s=="function"&&(d.moving=!1,s())}else w<0&&(w=0),D(a,w,"",0)},c=()=>{t.style.transform="",t.style.transition="",d.transitionEndTrigger?(d.transitionEndTrigger(),d.transitionEndTrigger=null,u&&setTimeout(()=>{u&&(u.style.transform="",u.style.transition="")},m)):u&&(u.style.transform="",u.style.transition="")},_=/^matrix\((.+)\)$/,f=a=>{if(r.start(a),d.scrollDistance=0,d.moving){const p=t,{transform:T}=window.getComputedStyle(p);if(T){const x=_.exec(T);if(x){const y=x[1].split(/,\s*/);d.scrollDistance=+y[4]}}}h&&t.classList.add(h),d.startDistance=d.scrollDistance,d.transitionEndTrigger=null,d.moving=!0},v=a=>{d.moving=!0,r.move(a),r.isHorizontal()&&A(a,!0),i(t,r.deltaX.value,"",0)},l=()=>{if(r.isVertical()){i(t,0,"end",g);return}const a=r.deltaX.value;if(a===0){h&&t.classList.remove(h),d.moving=!1;return}const p=r.duration.value;if(p<k&&Math.abs(a)>N){const x=U(a,p,n);i(t,x,"end",g)}else i(t,a,"end",g)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",f),t.addEventListener("touchmove",v),t.addEventListener("touchend",l),t.addEventListener("touchcancel",l),E.set(t,{state:d,transitionend:c,touchstart:f,touchmove:v,touchend:l,touchcancel:l})}function q(t){const e=E.get(t);e&&(E.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const H=o.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},removeViewPageDuration:{default:500},routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;function n(r){return(r.params&&r.params.animationType)??"slide"}const s=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-active`;r.classList.add(l),r.classList.add(a)}},m=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.add(a)}},h=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const v=i?"show":"enter",l=`fox-root-navigator__${f}-${v}-active`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&c.opsType===3&&Y(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},g=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-active`;r.classList.add(l),r.classList.add(a)}},d=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.add(a)}},u=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const v=i?"hide":"leave",l=`fox-root-navigator__${f}-${v}-active`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&q(r)};return(r,i)=>{const c=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:m,"after-enter":h,"before-leave":g,leave:d,"after-leave":u,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:H},Symbol.toStringTag,{value:"Module"})),G={class:"fox-swiper-navigator"},J=o.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=o.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,m)=>(o.openBlock(),o.createElementBlock("div",G,[o.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:o.normalizeStyle(o.unref(n))},[o.renderSlot(s.$slots,"default")],4)]))}});let K=0;function Q(){return++K}const Z=15,tt=300,et=200;function nt(t){t.stopPropagation()}function ot(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&nt(t)}function it(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function L(t,e=0,n,s=et){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}class st{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,s,m,h,g){this.getStartDistance=e,this.openPage=n,this.isPageOpened=s,this.pageOpened=m,this.moveRatio=h,this.momentumReduceRatio=g}open(){const e=this.el,n=O(),s=(m,h,g,d)=>{let u=h+this.startDistance;const r=this.columnWidth*this.moveRatio;if(g==="end"){if(u==0){this.moving=!1;return}Math.abs(h)>r&&(h>0?u=this.startDistance+this.columnWidth:u=this.startDistance-this.columnWidth);let i=-u;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const c=Math.floor(i/this.columnWidth);this.isPageOpened(c)||this.openPage(c),u=-c*this.columnWidth,d&&d>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(c)}),L(m,u,"end",d),this.scrollDistance=u}else{if(Math.abs(h)>r){let c=0;if(h>0?c=Math.abs(this.startDistance+this.columnWidth):c=Math.abs(this.startDistance-this.columnWidth),c>=0&&c<this.width){const _=Math.floor(c/this.columnWidth);this.isPageOpened(_)||this.openPage(_)}}let i=-u;i<this.min?i=this.min:i>this.max&&(i=this.max),L(m,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=m=>{this.moving||(n.start(m),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=m=>{n.move(m),n.isHorizontal()&&ot(m,!0),s(e,n.deltaX.value,"",0)},this.touchend=()=>{if(n.isVertical()){s(e,0,"end",this.swipeDuration);return}const m=n.deltaX.value;if(m==0)return;const h=n.duration.value;if(h<tt&&Math.abs(m)>Z){const d=it(m,h,this.momentumReduceRatio);s(e,d,"end",this.swipeDuration)}else s(e,m,"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 at(t,e,n,s,m,h){return new st(t,e,n,s,m,h)}const rt=o.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,moveRatio:{default:.5},momentumReduceRatio:{default:1},transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,s=o.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),u=at(()=>s.scrollDistance,l=>{if(s.openedIndexList.indexOf(l)===-1){s.openedIndexList.push(l);const a=n.routes[l];try{n.openViewPage(a,l)}catch(p){console.error(p)}}},l=>s.openedIndexList.indexOf(l)!==-1,l=>{s.index=l,s.scrollDistance=-s.index*n.width;const a=n.routes[l];e("update:activePath",a.path)},n.moveRatio,n.momentumReduceRatio);o.onMounted(()=>{const l=_();u.el=l,u.open()}),o.onUnmounted(()=>{u.close()}),o.watchEffect(()=>{const l=n.activePath;s.index=n.routes.findIndex(w=>w.path===l);const a=n.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-a*s.index);const p=a*n.routes.length,T=-a/3,x=a*(n.routes.length-1)+a/3;u.columnWidth=a,u.width=p,u.min=T,u.max=x,u.swipeDuration=n.swipeDuration});const r=`fox-swiper-navigator-${Q()}`,i=o.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let c=null;function _(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const f=o.computed(()=>`${n.width*n.routes.length}px`),v=(l,a)=>({style:{left:`${n.routes.findIndex(T=>{const x=l.path??l.name??"";return T.path==x})*n.width}px`,width:`${n.width}px`}});return(l,a)=>{const p=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(p,{class:o.normalizeClass(r),style:o.normalizeStyle(o.unref(i)),"view-class":"fox-swiper-navigator__item",tag:J,"view-tag-props":v,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":s.scrollDistance,"scroll-time":n.scrollTime,width:o.unref(f)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}}),ct=Object.freeze(Object.defineProperty({__proto__:null,default:rt},Symbol.toStringTag,{value:"Module"}));let lt="fox-";const ut=[],M=Object.assign({"/src/components/card-navigator/index.vue":I,"/src/components/default-navigator/index.vue":B,"/src/components/root-navigator/index.vue":F,"/src/components/swiper-navigator/index.vue":ct}),P=[];for(const t in M){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];ut.indexOf(e)===-1&&P.push({name:e,component:M[t].default})}const dt={install(t){P.forEach(e=>{t.component(`${lt}${e.name}`,e.component)})}};module.exports=dt;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as E, resolveComponent as L, openBlock as y, createBlock as D, withCtx as I, createVNode as B, Transition as X, resolveDynamicComponent as A, ref as w, unref as $, computed as O, createElementBlock as U, createElementVNode as Y, normalizeStyle as W, renderSlot as k, reactive as H, onMounted as q, onUnmounted as F, watchEffect as G, normalizeClass as J } from "vue";
|
|
2
2
|
/*!
|
|
3
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
+
* @fox-js/navigation v4.0.1-6 Wed Jan 03 2024 16:14:47 GMT+0800 (中国标准时间)
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const K = /* @__PURE__ */ E({
|
|
6
6
|
__name: "index",
|
|
7
7
|
props: {
|
|
8
8
|
routerViewName: null,
|
|
@@ -12,7 +12,7 @@ const J = /* @__PURE__ */ D({
|
|
|
12
12
|
const e = t;
|
|
13
13
|
return (n, i) => {
|
|
14
14
|
const f = L("fox-router-view");
|
|
15
|
-
return
|
|
15
|
+
return y(), D(f, {
|
|
16
16
|
class: "fox-card-navigator",
|
|
17
17
|
"view-class": "fox-card-navigator__item",
|
|
18
18
|
"view-active-class": "fox-card-navigator__item-active",
|
|
@@ -24,10 +24,10 @@ const J = /* @__PURE__ */ D({
|
|
|
24
24
|
}, null, 8, ["transition", "name"]);
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
}),
|
|
27
|
+
}), Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
28
28
|
__proto__: null,
|
|
29
|
-
default:
|
|
30
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
29
|
+
default: K
|
|
30
|
+
}, Symbol.toStringTag, { value: "Module" })), Z = /* @__PURE__ */ E({
|
|
31
31
|
__name: "index",
|
|
32
32
|
props: {
|
|
33
33
|
routerViewName: null,
|
|
@@ -37,15 +37,15 @@ const J = /* @__PURE__ */ D({
|
|
|
37
37
|
const e = t;
|
|
38
38
|
return (n, i) => {
|
|
39
39
|
const f = L("fox-router-view");
|
|
40
|
-
return
|
|
40
|
+
return y(), D(f, {
|
|
41
41
|
transition: !1,
|
|
42
42
|
multi: !1,
|
|
43
43
|
name: e.routerViewName
|
|
44
44
|
}, {
|
|
45
|
-
default:
|
|
46
|
-
|
|
47
|
-
default:
|
|
48
|
-
(
|
|
45
|
+
default: I(({ Component: h }) => [
|
|
46
|
+
B(X, { name: "fox-default-navigator__trans" }, {
|
|
47
|
+
default: I(() => [
|
|
48
|
+
(y(), D(A(h)))
|
|
49
49
|
]),
|
|
50
50
|
_: 2
|
|
51
51
|
}, 1024)
|
|
@@ -54,26 +54,26 @@ const J = /* @__PURE__ */ D({
|
|
|
54
54
|
}, 8, ["name"]);
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
}),
|
|
57
|
+
}), tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
58
58
|
__proto__: null,
|
|
59
|
-
default:
|
|
60
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
61
|
-
function
|
|
62
|
-
return t > e && t >
|
|
59
|
+
default: Z
|
|
60
|
+
}, Symbol.toStringTag, { value: "Module" })), S = 10;
|
|
61
|
+
function et(t, e) {
|
|
62
|
+
return t > e && t > S ? "horizontal" : e > t && e > S ? "vertical" : "";
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
const t =
|
|
66
|
-
p.value = 0,
|
|
64
|
+
function N() {
|
|
65
|
+
const t = w(0), e = w(0), n = w(0), i = w(0), f = w(0), h = w(0), p = w(0), u = w(0), l = w(0), a = w(0), o = w(""), r = () => o.value === "vertical", g = () => o.value === "horizontal", d = () => {
|
|
66
|
+
p.value = 0, u.value = 0, l.value = 0, a.value = 0, o.value = "", n.value = 0;
|
|
67
67
|
};
|
|
68
68
|
return {
|
|
69
|
-
move: (
|
|
70
|
-
const v =
|
|
71
|
-
p.value = v.clientX - t.value,
|
|
69
|
+
move: (s) => {
|
|
70
|
+
const v = s.touches[0];
|
|
71
|
+
p.value = v.clientX - t.value, u.value = v.clientY - e.value, f.value = v.clientX, h.value = v.clientY, l.value = Math.abs(p.value), a.value = Math.abs(u.value), i.value = Date.now() - n.value, o.value || (o.value = et(l.value, a.value));
|
|
72
72
|
},
|
|
73
|
-
start: (
|
|
74
|
-
|
|
73
|
+
start: (s) => {
|
|
74
|
+
d(), t.value = s.touches[0].clientX, e.value = s.touches[0].clientY, n.value = Date.now();
|
|
75
75
|
},
|
|
76
|
-
reset:
|
|
76
|
+
reset: d,
|
|
77
77
|
startX: t,
|
|
78
78
|
startY: e,
|
|
79
79
|
startTime: n,
|
|
@@ -81,7 +81,7 @@ function W() {
|
|
|
81
81
|
moveX: f,
|
|
82
82
|
moveY: h,
|
|
83
83
|
deltaX: p,
|
|
84
|
-
deltaY:
|
|
84
|
+
deltaY: u,
|
|
85
85
|
offsetX: l,
|
|
86
86
|
offsetY: a,
|
|
87
87
|
direction: o,
|
|
@@ -89,12 +89,12 @@ function W() {
|
|
|
89
89
|
isHorizontal: g
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function nt(t) {
|
|
93
93
|
return t === window;
|
|
94
94
|
}
|
|
95
|
-
const
|
|
96
|
-
const e =
|
|
97
|
-
if (
|
|
95
|
+
const ot = (t) => {
|
|
96
|
+
const e = $(t);
|
|
97
|
+
if (nt(e)) {
|
|
98
98
|
const n = e.innerWidth, i = e.innerHeight;
|
|
99
99
|
return {
|
|
100
100
|
top: 0,
|
|
@@ -113,79 +113,89 @@ const nt = (t) => {
|
|
|
113
113
|
width: 0,
|
|
114
114
|
height: 0
|
|
115
115
|
};
|
|
116
|
-
},
|
|
117
|
-
function
|
|
116
|
+
}, it = 15, st = 300, at = 200;
|
|
117
|
+
function rt(t) {
|
|
118
118
|
t.stopPropagation();
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e &&
|
|
120
|
+
function ct(t, e) {
|
|
121
|
+
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && rt(t);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function lt(t, e, n = 1) {
|
|
124
124
|
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t * n;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function M(t, e = 0, n, i = at) {
|
|
127
127
|
n === "end" ? t.style.transition = `transform ${i}ms cubic-bezier(0.17, 0.89, 0.45, 1)` : t.style.transition = "transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)", t.style.transform = `translate3d(${e}px, 0, 0)`;
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
function
|
|
131
|
-
const
|
|
129
|
+
const P = /* @__PURE__ */ new WeakMap();
|
|
130
|
+
function ut(t, e, n, i, f = 500, h, p = 1e3) {
|
|
131
|
+
const u = {
|
|
132
132
|
active: !0,
|
|
133
133
|
startDistance: 0,
|
|
134
134
|
scrollDistance: 0,
|
|
135
135
|
scrollTime: 0,
|
|
136
136
|
moving: !1,
|
|
137
137
|
transitionEndTrigger: null
|
|
138
|
-
}, l = t.previousSibling, a =
|
|
139
|
-
let
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
142
|
-
let
|
|
143
|
-
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}),
|
|
138
|
+
}, l = t.previousSibling, a = N(), o = (s, v, T, _) => {
|
|
139
|
+
let x = v + u.startDistance;
|
|
140
|
+
if (T === "end") {
|
|
141
|
+
const b = ot(s);
|
|
142
|
+
let j = b.width * e;
|
|
143
|
+
x < j ? x = 0 : x = b.width;
|
|
144
|
+
let R = !1;
|
|
145
|
+
_ && _ > 0 && (R = !0, u.transitionEndTrigger = () => {
|
|
146
|
+
u.moving = !1, h && s.classList.remove(h), x > 0 && typeof i == "function" && i();
|
|
147
|
+
}), M(s, x, "end", _), l && M(l, 0, "", 0), !R && x > 0 && typeof i == "function" && (u.moving = !1, i());
|
|
148
148
|
} else
|
|
149
|
-
|
|
149
|
+
x < 0 && (x = 0), M(s, x, "", 0);
|
|
150
150
|
}, r = () => {
|
|
151
|
-
t.style.transform = "", t.style.transition = "",
|
|
151
|
+
t.style.transform = "", t.style.transition = "", u.transitionEndTrigger ? (u.transitionEndTrigger(), u.transitionEndTrigger = null, l && setTimeout(() => {
|
|
152
152
|
l && (l.style.transform = "", l.style.transition = "");
|
|
153
153
|
}, f)) : l && (l.style.transform = "", l.style.transition = "");
|
|
154
|
-
}, g = (s) => {
|
|
155
|
-
if (a.start(s),
|
|
156
|
-
const
|
|
157
|
-
|
|
154
|
+
}, g = /^matrix\((.+)\)$/, d = (s) => {
|
|
155
|
+
if (a.start(s), u.scrollDistance = 0, u.moving) {
|
|
156
|
+
const v = t, { transform: T } = window.getComputedStyle(v);
|
|
157
|
+
if (T) {
|
|
158
|
+
const _ = g.exec(T);
|
|
159
|
+
if (_) {
|
|
160
|
+
const b = _[1].split(/,\s*/);
|
|
161
|
+
u.scrollDistance = +b[4];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
h && t.classList.add(h), u.startDistance = u.scrollDistance, u.transitionEndTrigger = null, u.moving = !0;
|
|
166
|
+
}, m = (s) => {
|
|
167
|
+
u.moving = !0, a.move(s), a.isHorizontal() && ct(s, !0), o(t, a.deltaX.value, "", 0);
|
|
168
|
+
}, c = () => {
|
|
169
|
+
if (a.isVertical()) {
|
|
170
|
+
o(t, 0, "end", p);
|
|
171
|
+
return;
|
|
158
172
|
}
|
|
159
|
-
h && t.classList.add(h), d.startDistance = d.scrollDistance, d.transitionEndTrigger = null, d.moving = !0;
|
|
160
|
-
}, u = (s) => {
|
|
161
|
-
d.moving = !0, a.move(s), a.isHorizontal() && rt(s, !0), o(t, a.deltaX.value, "", 0);
|
|
162
|
-
}, m = () => {
|
|
163
173
|
const s = a.deltaX.value;
|
|
164
|
-
if (s
|
|
165
|
-
h && t.classList.remove(h);
|
|
174
|
+
if (s === 0) {
|
|
175
|
+
h && t.classList.remove(h), u.moving = !1;
|
|
166
176
|
return;
|
|
167
177
|
}
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
const
|
|
171
|
-
o(t,
|
|
178
|
+
const v = a.duration.value;
|
|
179
|
+
if (v < st && Math.abs(s) > it) {
|
|
180
|
+
const _ = lt(s, v, n);
|
|
181
|
+
o(t, _, "end", p);
|
|
172
182
|
} else
|
|
173
183
|
o(t, s, "end", p);
|
|
174
184
|
};
|
|
175
|
-
t.addEventListener("transitionend", r), t.addEventListener("touchstart",
|
|
176
|
-
state:
|
|
185
|
+
t.addEventListener("transitionend", r), t.addEventListener("touchstart", d), t.addEventListener("touchmove", m), t.addEventListener("touchend", c), t.addEventListener("touchcancel", c), P.set(t, {
|
|
186
|
+
state: u,
|
|
177
187
|
transitionend: r,
|
|
178
|
-
touchstart:
|
|
179
|
-
touchmove:
|
|
180
|
-
touchend:
|
|
181
|
-
touchcancel:
|
|
188
|
+
touchstart: d,
|
|
189
|
+
touchmove: m,
|
|
190
|
+
touchend: c,
|
|
191
|
+
touchcancel: c
|
|
182
192
|
});
|
|
183
193
|
}
|
|
184
|
-
function
|
|
185
|
-
const e =
|
|
186
|
-
e && (
|
|
194
|
+
function dt(t) {
|
|
195
|
+
const e = P.get(t);
|
|
196
|
+
e && (P.delete(t), t.addEventListener("transitionend", e.transitionend), t.addEventListener("touchstart", e.touchstart), t.addEventListener("touchmove", e.touchmove), t.addEventListener("touchend", e.touchend), t.addEventListener("touchcancel", e.touchcancel));
|
|
187
197
|
}
|
|
188
|
-
const
|
|
198
|
+
const ft = /* @__PURE__ */ E({
|
|
189
199
|
__name: "index",
|
|
190
200
|
props: {
|
|
191
201
|
dragRemove: { type: Boolean, default: !0 },
|
|
@@ -205,29 +215,29 @@ const dt = /* @__PURE__ */ D({
|
|
|
205
215
|
}
|
|
206
216
|
const i = (a, o, r, g) => {
|
|
207
217
|
if (r.opsType === 3 || o) {
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
218
|
+
const d = n(r);
|
|
219
|
+
if (d === "pop" && o)
|
|
210
220
|
return;
|
|
211
|
-
const m = o ? "show" : "enter",
|
|
212
|
-
a.classList.add(
|
|
221
|
+
const m = o ? "show" : "enter", c = `fox-root-navigator__${d}-${m}-from`, s = `fox-root-navigator__${d}-${m}-active`;
|
|
222
|
+
a.classList.add(c), a.classList.add(s);
|
|
213
223
|
}
|
|
214
224
|
}, f = (a, o, r, g) => {
|
|
215
225
|
if (r.opsType === 3 || o) {
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
226
|
+
const d = n(r);
|
|
227
|
+
if (d === "pop" && o)
|
|
218
228
|
return;
|
|
219
|
-
const m = o ? "show" : "enter",
|
|
220
|
-
a.classList.remove(
|
|
229
|
+
const m = o ? "show" : "enter", c = `fox-root-navigator__${d}-${m}-from`, s = `fox-root-navigator__${d}-${m}-to`;
|
|
230
|
+
a.classList.remove(c), a.classList.add(s);
|
|
221
231
|
}
|
|
222
232
|
}, h = (a, o, r, g) => {
|
|
223
233
|
if (r.opsType === 3 || o) {
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
-
const m = o ? "show" : "enter",
|
|
227
|
-
a.classList.remove(
|
|
234
|
+
const d = n(r);
|
|
235
|
+
if (d !== "pop" || !o) {
|
|
236
|
+
const m = o ? "show" : "enter", c = `fox-root-navigator__${d}-${m}-active`, s = `fox-root-navigator__${d}-${m}-to`;
|
|
237
|
+
a.classList.remove(c), a.classList.remove(s);
|
|
228
238
|
}
|
|
229
239
|
}
|
|
230
|
-
e.dragRemove && !o && r.opsType === 3 &&
|
|
240
|
+
e.dragRemove && !o && r.opsType === 3 && ut(
|
|
231
241
|
a,
|
|
232
242
|
e.removeMoveRatio,
|
|
233
243
|
e.momentumReduceRatio,
|
|
@@ -238,40 +248,40 @@ const dt = /* @__PURE__ */ D({
|
|
|
238
248
|
);
|
|
239
249
|
}, p = (a, o, r, g) => {
|
|
240
250
|
if (r.opsType === 3 || o) {
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
251
|
+
const d = n(r);
|
|
252
|
+
if (d === "pop" && o)
|
|
243
253
|
return;
|
|
244
|
-
const m = o ? "hide" : "leave",
|
|
245
|
-
a.classList.add(
|
|
254
|
+
const m = o ? "hide" : "leave", c = `fox-root-navigator__${d}-${m}-from`, s = `fox-root-navigator__${d}-${m}-active`;
|
|
255
|
+
a.classList.add(c), a.classList.add(s);
|
|
246
256
|
}
|
|
247
|
-
},
|
|
257
|
+
}, u = (a, o, r, g) => {
|
|
248
258
|
if (r.opsType === 3 || o) {
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
259
|
+
const d = n(r);
|
|
260
|
+
if (d === "pop" && o)
|
|
251
261
|
return;
|
|
252
|
-
const m = o ? "hide" : "leave",
|
|
253
|
-
a.classList.remove(
|
|
262
|
+
const m = o ? "hide" : "leave", c = `fox-root-navigator__${d}-${m}-from`, s = `fox-root-navigator__${d}-${m}-to`;
|
|
263
|
+
a.classList.remove(c), a.classList.add(s);
|
|
254
264
|
}
|
|
255
265
|
}, l = (a, o, r, g) => {
|
|
256
266
|
if (r.opsType === 3 || o) {
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
259
|
-
const m = o ? "hide" : "leave",
|
|
260
|
-
a.classList.remove(
|
|
267
|
+
const d = n(r);
|
|
268
|
+
if (d !== "pop" || !o) {
|
|
269
|
+
const m = o ? "hide" : "leave", c = `fox-root-navigator__${d}-${m}-active`, s = `fox-root-navigator__${d}-${m}-to`;
|
|
270
|
+
a.classList.remove(c), a.classList.remove(s);
|
|
261
271
|
}
|
|
262
272
|
}
|
|
263
|
-
e.dragRemove && !o &&
|
|
273
|
+
e.dragRemove && !o && dt(a);
|
|
264
274
|
};
|
|
265
275
|
return (a, o) => {
|
|
266
276
|
const r = L("fox-router-view");
|
|
267
|
-
return
|
|
277
|
+
return y(), D(r, {
|
|
268
278
|
class: "fox-root-navigator",
|
|
269
279
|
"view-class": t.viewClass,
|
|
270
280
|
"before-enter": i,
|
|
271
281
|
enter: f,
|
|
272
282
|
"after-enter": h,
|
|
273
283
|
"before-leave": p,
|
|
274
|
-
leave:
|
|
284
|
+
leave: u,
|
|
275
285
|
"after-leave": l,
|
|
276
286
|
multi: !0,
|
|
277
287
|
name: e.routerViewName,
|
|
@@ -280,10 +290,10 @@ const dt = /* @__PURE__ */ D({
|
|
|
280
290
|
}, null, 8, ["view-class", "name", "view-tag", "transition"]);
|
|
281
291
|
};
|
|
282
292
|
}
|
|
283
|
-
}),
|
|
293
|
+
}), ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
284
294
|
__proto__: null,
|
|
285
|
-
default:
|
|
286
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
295
|
+
default: ft
|
|
296
|
+
}, Symbol.toStringTag, { value: "Module" })), mt = { class: "fox-swiper-navigator" }, vt = /* @__PURE__ */ E({
|
|
287
297
|
__name: "swiper",
|
|
288
298
|
props: {
|
|
289
299
|
width: null,
|
|
@@ -291,39 +301,39 @@ const dt = /* @__PURE__ */ D({
|
|
|
291
301
|
scrollTime: null
|
|
292
302
|
},
|
|
293
303
|
setup(t) {
|
|
294
|
-
const e = t, n =
|
|
304
|
+
const e = t, n = O(() => ({
|
|
295
305
|
// transition: `transform ${props.scrollTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
|
|
296
306
|
transform: `translate3d(${e.scrollDistance}px, 0, 0)`,
|
|
297
307
|
width: `${e.width}`
|
|
298
308
|
}));
|
|
299
|
-
return (i, f) => (
|
|
300
|
-
|
|
309
|
+
return (i, f) => (y(), U("div", mt, [
|
|
310
|
+
Y("div", {
|
|
301
311
|
class: "fox-swiper-navigator__inner",
|
|
302
|
-
style:
|
|
312
|
+
style: W($(n))
|
|
303
313
|
}, [
|
|
304
|
-
|
|
314
|
+
k(i.$slots, "default")
|
|
305
315
|
], 4)
|
|
306
316
|
]));
|
|
307
317
|
}
|
|
308
318
|
});
|
|
309
|
-
let
|
|
310
|
-
function
|
|
311
|
-
return ++
|
|
319
|
+
let pt = 0;
|
|
320
|
+
function gt() {
|
|
321
|
+
return ++pt;
|
|
312
322
|
}
|
|
313
|
-
const
|
|
314
|
-
function
|
|
323
|
+
const _t = 15, xt = 300, wt = 200;
|
|
324
|
+
function Tt(t) {
|
|
315
325
|
t.stopPropagation();
|
|
316
326
|
}
|
|
317
|
-
function
|
|
318
|
-
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e &&
|
|
327
|
+
function yt(t, e) {
|
|
328
|
+
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && Tt(t);
|
|
319
329
|
}
|
|
320
|
-
function
|
|
330
|
+
function Dt(t, e, n = 1) {
|
|
321
331
|
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t * n;
|
|
322
332
|
}
|
|
323
|
-
function
|
|
333
|
+
function C(t, e = 0, n, i = wt) {
|
|
324
334
|
n === "end" ? t.style.transition = `transform ${i}ms cubic-bezier(0.17, 0.89, 0.45, 1)` : t.style.transition = "transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)", t.style.transform = `translate3d(${e}px, 0, 0)`;
|
|
325
335
|
}
|
|
326
|
-
class
|
|
336
|
+
class Et {
|
|
327
337
|
/**
|
|
328
338
|
* width
|
|
329
339
|
*/
|
|
@@ -425,7 +435,7 @@ class Dt {
|
|
|
425
435
|
* 打开drag支持
|
|
426
436
|
*/
|
|
427
437
|
open() {
|
|
428
|
-
const e = this.el, n =
|
|
438
|
+
const e = this.el, n = N(), i = (f, h, p, u) => {
|
|
429
439
|
let l = h + this.startDistance;
|
|
430
440
|
const a = this.columnWidth * this.moveRatio;
|
|
431
441
|
if (p === "end") {
|
|
@@ -437,9 +447,9 @@ class Dt {
|
|
|
437
447
|
let o = -l;
|
|
438
448
|
o < 0 ? o = 0 : o > this.width - this.columnWidth && (o = this.width - this.columnWidth);
|
|
439
449
|
const r = Math.floor(o / this.columnWidth);
|
|
440
|
-
this.isPageOpened(r) || this.openPage(r), l = -r * this.columnWidth,
|
|
450
|
+
this.isPageOpened(r) || this.openPage(r), l = -r * this.columnWidth, u && u > 0 && (this.transitionEndTrigger = () => {
|
|
441
451
|
this.moving = !1, this.pageOpened(r);
|
|
442
|
-
}),
|
|
452
|
+
}), C(f, l, "end", u), this.scrollDistance = l;
|
|
443
453
|
} else {
|
|
444
454
|
if (Math.abs(h) > a) {
|
|
445
455
|
let r = 0;
|
|
@@ -449,7 +459,7 @@ class Dt {
|
|
|
449
459
|
}
|
|
450
460
|
}
|
|
451
461
|
let o = -l;
|
|
452
|
-
o < this.min ? o = this.min : o > this.max && (o = this.max),
|
|
462
|
+
o < this.min ? o = this.min : o > this.max && (o = this.max), C(f, -o, "", 0);
|
|
453
463
|
}
|
|
454
464
|
};
|
|
455
465
|
this.transitionend = () => {
|
|
@@ -457,15 +467,19 @@ class Dt {
|
|
|
457
467
|
}, this.touchstart = (f) => {
|
|
458
468
|
this.moving || (n.start(f), this.startDistance = this.getStartDistance(), this.transitionEndTrigger = null, this.moving = !0);
|
|
459
469
|
}, this.touchmove = (f) => {
|
|
460
|
-
n.move(f), n.isHorizontal() &&
|
|
470
|
+
n.move(f), n.isHorizontal() && yt(f, !0), i(e, n.deltaX.value, "", 0);
|
|
461
471
|
}, this.touchend = () => {
|
|
472
|
+
if (n.isVertical()) {
|
|
473
|
+
i(e, 0, "end", this.swipeDuration);
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
462
476
|
const f = n.deltaX.value;
|
|
463
477
|
if (f == 0)
|
|
464
478
|
return;
|
|
465
479
|
const h = n.duration.value;
|
|
466
|
-
if (h <
|
|
467
|
-
const
|
|
468
|
-
i(e,
|
|
480
|
+
if (h < xt && Math.abs(f) > _t) {
|
|
481
|
+
const u = Dt(f, h, this.momentumReduceRatio);
|
|
482
|
+
i(e, u, "end", this.swipeDuration);
|
|
469
483
|
} else
|
|
470
484
|
i(e, f, "end", this.swipeDuration);
|
|
471
485
|
}, 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);
|
|
@@ -478,10 +492,10 @@ class Dt {
|
|
|
478
492
|
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;
|
|
479
493
|
}
|
|
480
494
|
}
|
|
481
|
-
function
|
|
482
|
-
return new
|
|
495
|
+
function bt(t, e, n, i, f, h) {
|
|
496
|
+
return new Et(t, e, n, i, f, h);
|
|
483
497
|
}
|
|
484
|
-
const
|
|
498
|
+
const $t = /* @__PURE__ */ E({
|
|
485
499
|
__name: "index",
|
|
486
500
|
props: {
|
|
487
501
|
activePath: null,
|
|
@@ -499,93 +513,100 @@ const bt = /* @__PURE__ */ D({
|
|
|
499
513
|
},
|
|
500
514
|
emits: ["update:activePath"],
|
|
501
515
|
setup(t, { emit: e }) {
|
|
502
|
-
const n = t, i =
|
|
516
|
+
const n = t, i = H({
|
|
503
517
|
scrollDistance: 0,
|
|
504
518
|
index: -1,
|
|
505
519
|
openedIndexList: []
|
|
506
|
-
}), l =
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
n.
|
|
512
|
-
|
|
513
|
-
|
|
520
|
+
}), l = bt(
|
|
521
|
+
() => i.scrollDistance,
|
|
522
|
+
(c) => {
|
|
523
|
+
if (i.openedIndexList.indexOf(c) === -1) {
|
|
524
|
+
i.openedIndexList.push(c);
|
|
525
|
+
const s = n.routes[c];
|
|
526
|
+
try {
|
|
527
|
+
n.openViewPage(s, c);
|
|
528
|
+
} catch (v) {
|
|
529
|
+
console.error(v);
|
|
530
|
+
}
|
|
514
531
|
}
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
532
|
+
},
|
|
533
|
+
(c) => i.openedIndexList.indexOf(c) !== -1,
|
|
534
|
+
(c) => {
|
|
535
|
+
i.index = c, i.scrollDistance = -i.index * n.width;
|
|
536
|
+
const s = n.routes[c];
|
|
537
|
+
e("update:activePath", s.path);
|
|
538
|
+
},
|
|
539
|
+
n.moveRatio,
|
|
540
|
+
n.momentumReduceRatio
|
|
541
|
+
);
|
|
542
|
+
q(() => {
|
|
543
|
+
const c = g();
|
|
544
|
+
l.el = c, l.open();
|
|
526
545
|
}), F(() => {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const c = n.
|
|
530
|
-
i.index
|
|
531
|
-
const
|
|
532
|
-
|
|
546
|
+
l.close();
|
|
547
|
+
}), G(() => {
|
|
548
|
+
const c = n.activePath;
|
|
549
|
+
i.index = n.routes.findIndex((x) => x.path === c);
|
|
550
|
+
const s = n.width;
|
|
551
|
+
i.index !== -1 && (i.openedIndexList.push(i.index), i.scrollDistance = -s * i.index);
|
|
552
|
+
const v = s * n.routes.length, T = -s / 3, _ = s * (n.routes.length - 1) + s / 3;
|
|
553
|
+
l.columnWidth = s, l.width = v, l.min = T, l.max = _, l.swipeDuration = n.swipeDuration;
|
|
533
554
|
});
|
|
534
|
-
const a = `fox-swiper-navigator-${
|
|
555
|
+
const a = `fox-swiper-navigator-${gt()}`, o = O(() => ({ width: `${n.width}px`, height: `${n.height}px` }));
|
|
535
556
|
let r = null;
|
|
536
557
|
function g() {
|
|
537
558
|
return r || (r = document.querySelector(`.${a}>.fox-swiper-navigator__inner`), r);
|
|
538
559
|
}
|
|
539
|
-
const
|
|
560
|
+
const d = O(() => `${n.width * n.routes.length}px`), m = (c, s) => ({
|
|
540
561
|
style: {
|
|
541
|
-
left: `${n.routes.findIndex((
|
|
542
|
-
const _ =
|
|
543
|
-
return
|
|
562
|
+
left: `${n.routes.findIndex((T) => {
|
|
563
|
+
const _ = c.path ?? c.name ?? "";
|
|
564
|
+
return T.path == _;
|
|
544
565
|
}) * n.width}px`,
|
|
545
566
|
width: `${n.width}px`
|
|
546
567
|
}
|
|
547
568
|
});
|
|
548
|
-
return (
|
|
569
|
+
return (c, s) => {
|
|
549
570
|
const v = L("fox-router-view");
|
|
550
|
-
return
|
|
551
|
-
class:
|
|
552
|
-
style:
|
|
571
|
+
return y(), D(v, {
|
|
572
|
+
class: J(a),
|
|
573
|
+
style: W($(o)),
|
|
553
574
|
"view-class": "fox-swiper-navigator__item",
|
|
554
|
-
tag:
|
|
575
|
+
tag: vt,
|
|
555
576
|
"view-tag-props": m,
|
|
556
577
|
multi: !0,
|
|
557
578
|
name: n.routerViewName,
|
|
558
579
|
transition: n.transition,
|
|
559
580
|
"scroll-distance": i.scrollDistance,
|
|
560
581
|
"scroll-time": n.scrollTime,
|
|
561
|
-
width:
|
|
582
|
+
width: $(d)
|
|
562
583
|
}, null, 8, ["style", "name", "transition", "scroll-distance", "scroll-time", "width"]);
|
|
563
584
|
};
|
|
564
585
|
}
|
|
565
586
|
}), Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
566
587
|
__proto__: null,
|
|
567
|
-
default:
|
|
588
|
+
default: $t
|
|
568
589
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
569
|
-
let
|
|
570
|
-
const
|
|
571
|
-
for (const t in
|
|
590
|
+
let Mt = "fox-";
|
|
591
|
+
const Ot = [], V = /* @__PURE__ */ Object.assign({ "/src/components/card-navigator/index.vue": Q, "/src/components/default-navigator/index.vue": tt, "/src/components/root-navigator/index.vue": ht, "/src/components/swiper-navigator/index.vue": Lt }), z = [];
|
|
592
|
+
for (const t in V) {
|
|
572
593
|
let e = /src\/components\/(.*)\/index.vue/.exec(t)[1];
|
|
573
|
-
|
|
594
|
+
Ot.indexOf(e) === -1 && z.push({
|
|
574
595
|
name: e,
|
|
575
|
-
component:
|
|
596
|
+
component: V[t].default
|
|
576
597
|
});
|
|
577
598
|
}
|
|
578
|
-
const
|
|
599
|
+
const Rt = {
|
|
579
600
|
/**
|
|
580
601
|
* 安装
|
|
581
602
|
* @param app
|
|
582
603
|
*/
|
|
583
604
|
install(t) {
|
|
584
|
-
|
|
585
|
-
t.component(`${
|
|
605
|
+
z.forEach((e) => {
|
|
606
|
+
t.component(`${Mt}${e.name}`, e.component);
|
|
586
607
|
});
|
|
587
608
|
}
|
|
588
609
|
};
|
|
589
610
|
export {
|
|
590
|
-
|
|
611
|
+
Rt as default
|
|
591
612
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(o,
|
|
2
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
-
*/const C=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,s)=>{const h=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(h,{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"])}}})},Symbol.toStringTag,{value:"Module"})),R=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(n,s)=>{const h=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(h,{transition:!1,multi:!1,name:e.routerViewName},{default:o.withCtx(({Component:m})=>[o.createVNode(o.Transition,{name:"fox-default-navigator__trans"},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(m)))]),_:2},1024)]),_:1},8,["name"])}}})},Symbol.toStringTag,{value:"Module"})),E=10;function I(t,e){return t>e&&t>E?"horizontal":e>t&&e>E?"vertical":""}function b(){const t=o.ref(0),e=o.ref(0),n=o.ref(0),s=o.ref(0),h=o.ref(0),m=o.ref(0),v=o.ref(0),f=o.ref(0),u=o.ref(0),r=o.ref(0),i=o.ref(""),c=()=>i.value==="vertical",_=()=>i.value==="horizontal",d=()=>{v.value=0,f.value=0,u.value=0,r.value=0,i.value="",n.value=0};return{move:l=>{const g=l.touches[0];v.value=g.clientX-t.value,f.value=g.clientY-e.value,h.value=g.clientX,m.value=g.clientY,u.value=Math.abs(v.value),r.value=Math.abs(f.value),s.value=Date.now()-n.value,i.value||(i.value=I(u.value,r.value))},start:l=>{d(),t.value=l.touches[0].clientX,e.value=l.touches[0].clientY,n.value=Date.now()},reset:d,startX:t,startY:e,startTime:n,duration:s,moveX:h,moveY:m,deltaX:v,deltaY:f,offsetX:u,offsetY:r,direction:i,isVertical:c,isHorizontal:_}}function S(t){return t===window}const B=t=>{const e=o.unref(t);if(S(e)){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},V=15,W=300,N=200;function z(t){t.stopPropagation()}function j(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&z(t)}function k(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function D(t,e=0,n,s=N){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}const $=new WeakMap;function X(t,e,n,s,h=500,m,v=1e3){const f={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},u=t.previousSibling,r=b(),i=(a,l,g,w)=>{let x=l+f.startDistance;if(g==="end"){const y=B(a);let at=y.width*e;x<at?x=0:x=y.width;let P=!1;w&&w>0&&(P=!0,f.transitionEndTrigger=()=>{f.moving=!1,m&&a.classList.remove(m),x>0&&typeof s=="function"&&s()}),D(a,x,"end",w),u&&D(u,0,"",0),!P&&x>0&&typeof s=="function"&&s()}else x<0&&(x=0),D(a,x,"",0)},c=()=>{t.style.transform="",t.style.transition="",f.transitionEndTrigger?(f.transitionEndTrigger(),f.transitionEndTrigger=null,u&&setTimeout(()=>{u&&(u.style.transform="",u.style.transition="")},h)):u&&(u.style.transform="",u.style.transition="")},_=a=>{if(r.start(a),f.moving){const l=t,{transform:g}=window.getComputedStyle(l);f.scrollDistance=+g.slice(7,g.length-1).split(", ")[5]}m&&t.classList.add(m),f.startDistance=f.scrollDistance,f.transitionEndTrigger=null,f.moving=!0},d=a=>{f.moving=!0,r.move(a),r.isHorizontal()&&j(a,!0),i(t,r.deltaX.value,"",0)},p=()=>{const a=r.deltaX.value;if(a==0){m&&t.classList.remove(m);return}const l=r.duration.value;if(l<W&&Math.abs(a)>V){const w=k(a,l,n);i(t,w,"end",v)}else i(t,a,"end",v)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",_),t.addEventListener("touchmove",d),t.addEventListener("touchend",p),t.addEventListener("touchcancel",p),$.set(t,{state:f,transitionend:c,touchstart:_,touchmove:d,touchend:p,touchcancel:p})}function A(t){const e=$.get(t);e&&($.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const U=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},removeViewPageDuration:{default:500},routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;function n(r){return(r.params&&r.params.animationType)??"slide"}const s=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d==="pop"&&i)return;const p=i?"show":"enter",a=`fox-root-navigator__${d}-${p}-from`,l=`fox-root-navigator__${d}-${p}-active`;r.classList.add(a),r.classList.add(l)}},h=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d==="pop"&&i)return;const p=i?"show":"enter",a=`fox-root-navigator__${d}-${p}-from`,l=`fox-root-navigator__${d}-${p}-to`;r.classList.remove(a),r.classList.add(l)}},m=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d!=="pop"||!i){const p=i?"show":"enter",a=`fox-root-navigator__${d}-${p}-active`,l=`fox-root-navigator__${d}-${p}-to`;r.classList.remove(a),r.classList.remove(l)}}e.dragRemove&&!i&&c.opsType===3&&X(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},v=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d==="pop"&&i)return;const p=i?"hide":"leave",a=`fox-root-navigator__${d}-${p}-from`,l=`fox-root-navigator__${d}-${p}-active`;r.classList.add(a),r.classList.add(l)}},f=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d==="pop"&&i)return;const p=i?"hide":"leave",a=`fox-root-navigator__${d}-${p}-from`,l=`fox-root-navigator__${d}-${p}-to`;r.classList.remove(a),r.classList.add(l)}},u=(r,i,c,_)=>{if(c.opsType===3||i){const d=n(c);if(d!=="pop"||!i){const p=i?"hide":"leave",a=`fox-root-navigator__${d}-${p}-active`,l=`fox-root-navigator__${d}-${p}-to`;r.classList.remove(a),r.classList.remove(l)}}e.dragRemove&&!i&&A(r)};return(r,i)=>{const c=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:h,"after-enter":m,"before-leave":v,leave:f,"after-leave":u,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}})},Symbol.toStringTag,{value:"Module"})),Y={class:"fox-swiper-navigator"},q=o.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=o.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,h)=>(o.openBlock(),o.createElementBlock("div",Y,[o.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:o.normalizeStyle(o.unref(n))},[o.renderSlot(s.$slots,"default")],4)]))}});let F=0;function H(){return++F}const G=15,J=300,K=200;function Q(t){t.stopPropagation()}function Z(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&Q(t)}function tt(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function L(t,e=0,n,s=K){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}class et{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,s,h,m,v){this.getStartDistance=e,this.openPage=n,this.isPageOpened=s,this.pageOpened=h,this.moveRatio=m,this.momentumReduceRatio=v}open(){const e=this.el,n=b(),s=(h,m,v,f)=>{let u=m+this.startDistance;const r=this.columnWidth*this.moveRatio;if(v==="end"){if(u==0){this.moving=!1;return}Math.abs(m)>r&&(m>0?u=this.startDistance+this.columnWidth:u=this.startDistance-this.columnWidth);let i=-u;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const c=Math.floor(i/this.columnWidth);this.isPageOpened(c)||this.openPage(c),u=-c*this.columnWidth,f&&f>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(c)}),L(h,u,"end",f),this.scrollDistance=u}else{if(Math.abs(m)>r){let c=0;if(m>0?c=Math.abs(this.startDistance+this.columnWidth):c=Math.abs(this.startDistance-this.columnWidth),c>=0&&c<this.width){const _=Math.floor(c/this.columnWidth);this.isPageOpened(_)||this.openPage(_)}}let i=-u;i<this.min?i=this.min:i>this.max&&(i=this.max),L(h,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=h=>{this.moving||(n.start(h),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=h=>{n.move(h),n.isHorizontal()&&Z(h,!0),s(e,n.deltaX.value,"",0)},this.touchend=()=>{const h=n.deltaX.value;if(h==0)return;const m=n.duration.value;if(m<J&&Math.abs(h)>G){const f=tt(h,m,this.momentumReduceRatio);s(e,f,"end",this.swipeDuration)}else s(e,h,"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 nt(t,e,n,s){return new et(t,e,n,s)}const ot=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,moveRatio:{default:.5},momentumReduceRatio:{default:1},transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,s=o.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),u=nt(()=>s.scrollDistance,a=>{if(s.openedIndexList.indexOf(a)===-1){s.openedIndexList.push(a);const l=n.routes[a];try{n.openViewPage(l,a)}catch(g){console.error(g)}}},a=>s.openedIndexList.indexOf(a)!==-1,a=>{s.index=a,s.scrollDistance=-s.index*n.width;const l=n.routes[a];e("update:activePath",l.path)});o.onMounted(()=>{const a=_();u.el=a,u.open()}),o.onUnmounted(()=>{u.close()}),o.watchEffect(()=>{const a=n.activePath;s.index=n.routes.findIndex(y=>y.path===a);const l=n.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-l*s.index);const g=l*n.routes.length,w=-l/3,x=l*(n.routes.length-1)+l/3;u.columnWidth=l,u.width=g,u.min=w,u.max=x,u.swipeDuration=n.swipeDuration});const r=`fox-swiper-navigator-${H()}`,i=o.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let c=null;function _(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const d=o.computed(()=>`${n.width*n.routes.length}px`),p=(a,l)=>({style:{left:`${n.routes.findIndex(w=>{const x=a.path??a.name??"";return w.path==x})*n.width}px`,width:`${n.width}px`}});return(a,l)=>{const g=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(g,{class:o.normalizeClass(r),style:o.normalizeStyle(o.unref(i)),"view-class":"fox-swiper-navigator__item",tag:q,"view-tag-props":p,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":s.scrollDistance,"scroll-time":n.scrollTime,width:o.unref(d)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}})},Symbol.toStringTag,{value:"Module"}));let it="fox-";const st=[],M=Object.assign({"/src/components/card-navigator/index.vue":C,"/src/components/default-navigator/index.vue":R,"/src/components/root-navigator/index.vue":U,"/src/components/swiper-navigator/index.vue":ot}),O=[];for(const t in M){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];st.indexOf(e)===-1&&O.push({name:e,component:M[t].default})}return{install(t){O.forEach(e=>{t.component(`${it}${e.name}`,e.component)})}}});
|
|
1
|
+
(function(o,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("vue")):typeof define=="function"&&define.amd?define(["vue"],y):(o=typeof globalThis<"u"?globalThis:o||self,o.FoxNavigation=y(o.Vue))})(this,function(o){"use strict";/*!
|
|
2
|
+
* @fox-js/navigation v4.0.1-6 Wed Jan 03 2024 16:14:47 GMT+0800 (中国标准时间)
|
|
3
|
+
*/const R=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{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"])}}})},Symbol.toStringTag,{value:"Module"})),I=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{transition:!1,multi:!1,name:e.routerViewName},{default:o.withCtx(({Component:h})=>[o.createVNode(o.Transition,{name:"fox-default-navigator__trans"},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(h)))]),_:2},1024)]),_:1},8,["name"])}}})},Symbol.toStringTag,{value:"Module"})),b=10;function S(t,e){return t>e&&t>b?"horizontal":e>t&&e>b?"vertical":""}function L(){const t=o.ref(0),e=o.ref(0),n=o.ref(0),s=o.ref(0),m=o.ref(0),h=o.ref(0),v=o.ref(0),d=o.ref(0),u=o.ref(0),r=o.ref(0),i=o.ref(""),c=()=>i.value==="vertical",_=()=>i.value==="horizontal",f=()=>{v.value=0,d.value=0,u.value=0,r.value=0,i.value="",n.value=0};return{move:a=>{const g=a.touches[0];v.value=g.clientX-t.value,d.value=g.clientY-e.value,m.value=g.clientX,h.value=g.clientY,u.value=Math.abs(v.value),r.value=Math.abs(d.value),s.value=Date.now()-n.value,i.value||(i.value=S(u.value,r.value))},start:a=>{f(),t.value=a.touches[0].clientX,e.value=a.touches[0].clientY,n.value=Date.now()},reset:f,startX:t,startY:e,startTime:n,duration:s,moveX:m,moveY:h,deltaX:v,deltaY:d,offsetX:u,offsetY:r,direction:i,isVertical:c,isHorizontal:_}}function B(t){return t===window}const V=t=>{const e=o.unref(t);if(B(e)){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},W=15,N=300,z=200;function j(t){t.stopPropagation()}function k(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&j(t)}function X(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function $(t,e=0,n,s=z){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}const E=new WeakMap;function A(t,e,n,s,m=500,h,v=1e3){const d={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},u=t.previousSibling,r=L(),i=(a,g,T,x)=>{let w=g+d.startDistance;if(T==="end"){const D=V(a);let rt=D.width*e;w<rt?w=0:w=D.width;let C=!1;x&&x>0&&(C=!0,d.transitionEndTrigger=()=>{d.moving=!1,h&&a.classList.remove(h),w>0&&typeof s=="function"&&s()}),$(a,w,"end",x),u&&$(u,0,"",0),!C&&w>0&&typeof s=="function"&&(d.moving=!1,s())}else w<0&&(w=0),$(a,w,"",0)},c=()=>{t.style.transform="",t.style.transition="",d.transitionEndTrigger?(d.transitionEndTrigger(),d.transitionEndTrigger=null,u&&setTimeout(()=>{u&&(u.style.transform="",u.style.transition="")},m)):u&&(u.style.transform="",u.style.transition="")},_=/^matrix\((.+)\)$/,f=a=>{if(r.start(a),d.scrollDistance=0,d.moving){const g=t,{transform:T}=window.getComputedStyle(g);if(T){const x=_.exec(T);if(x){const D=x[1].split(/,\s*/);d.scrollDistance=+D[4]}}}h&&t.classList.add(h),d.startDistance=d.scrollDistance,d.transitionEndTrigger=null,d.moving=!0},p=a=>{d.moving=!0,r.move(a),r.isHorizontal()&&k(a,!0),i(t,r.deltaX.value,"",0)},l=()=>{if(r.isVertical()){i(t,0,"end",v);return}const a=r.deltaX.value;if(a===0){h&&t.classList.remove(h),d.moving=!1;return}const g=r.duration.value;if(g<N&&Math.abs(a)>W){const x=X(a,g,n);i(t,x,"end",v)}else i(t,a,"end",v)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",f),t.addEventListener("touchmove",p),t.addEventListener("touchend",l),t.addEventListener("touchcancel",l),E.set(t,{state:d,transitionend:c,touchstart:f,touchmove:p,touchend:l,touchcancel:l})}function U(t){const e=E.get(t);e&&(E.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const Y=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},removeViewPageDuration:{default:500},routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;function n(r){return(r.params&&r.params.animationType)??"slide"}const s=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const p=i?"show":"enter",l=`fox-root-navigator__${f}-${p}-from`,a=`fox-root-navigator__${f}-${p}-active`;r.classList.add(l),r.classList.add(a)}},m=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const p=i?"show":"enter",l=`fox-root-navigator__${f}-${p}-from`,a=`fox-root-navigator__${f}-${p}-to`;r.classList.remove(l),r.classList.add(a)}},h=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const p=i?"show":"enter",l=`fox-root-navigator__${f}-${p}-active`,a=`fox-root-navigator__${f}-${p}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&c.opsType===3&&A(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},v=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const p=i?"hide":"leave",l=`fox-root-navigator__${f}-${p}-from`,a=`fox-root-navigator__${f}-${p}-active`;r.classList.add(l),r.classList.add(a)}},d=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const p=i?"hide":"leave",l=`fox-root-navigator__${f}-${p}-from`,a=`fox-root-navigator__${f}-${p}-to`;r.classList.remove(l),r.classList.add(a)}},u=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const p=i?"hide":"leave",l=`fox-root-navigator__${f}-${p}-active`,a=`fox-root-navigator__${f}-${p}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&U(r)};return(r,i)=>{const c=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:m,"after-enter":h,"before-leave":v,leave:d,"after-leave":u,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}})},Symbol.toStringTag,{value:"Module"})),q={class:"fox-swiper-navigator"},F=o.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=o.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,m)=>(o.openBlock(),o.createElementBlock("div",q,[o.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:o.normalizeStyle(o.unref(n))},[o.renderSlot(s.$slots,"default")],4)]))}});let H=0;function G(){return++H}const J=15,K=300,Q=200;function Z(t){t.stopPropagation()}function tt(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&Z(t)}function et(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function M(t,e=0,n,s=Q){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}class nt{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,s,m,h,v){this.getStartDistance=e,this.openPage=n,this.isPageOpened=s,this.pageOpened=m,this.moveRatio=h,this.momentumReduceRatio=v}open(){const e=this.el,n=L(),s=(m,h,v,d)=>{let u=h+this.startDistance;const r=this.columnWidth*this.moveRatio;if(v==="end"){if(u==0){this.moving=!1;return}Math.abs(h)>r&&(h>0?u=this.startDistance+this.columnWidth:u=this.startDistance-this.columnWidth);let i=-u;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const c=Math.floor(i/this.columnWidth);this.isPageOpened(c)||this.openPage(c),u=-c*this.columnWidth,d&&d>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(c)}),M(m,u,"end",d),this.scrollDistance=u}else{if(Math.abs(h)>r){let c=0;if(h>0?c=Math.abs(this.startDistance+this.columnWidth):c=Math.abs(this.startDistance-this.columnWidth),c>=0&&c<this.width){const _=Math.floor(c/this.columnWidth);this.isPageOpened(_)||this.openPage(_)}}let i=-u;i<this.min?i=this.min:i>this.max&&(i=this.max),M(m,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=m=>{this.moving||(n.start(m),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=m=>{n.move(m),n.isHorizontal()&&tt(m,!0),s(e,n.deltaX.value,"",0)},this.touchend=()=>{if(n.isVertical()){s(e,0,"end",this.swipeDuration);return}const m=n.deltaX.value;if(m==0)return;const h=n.duration.value;if(h<K&&Math.abs(m)>J){const d=et(m,h,this.momentumReduceRatio);s(e,d,"end",this.swipeDuration)}else s(e,m,"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 ot(t,e,n,s,m,h){return new nt(t,e,n,s,m,h)}const it=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,moveRatio:{default:.5},momentumReduceRatio:{default:1},transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,s=o.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),u=ot(()=>s.scrollDistance,l=>{if(s.openedIndexList.indexOf(l)===-1){s.openedIndexList.push(l);const a=n.routes[l];try{n.openViewPage(a,l)}catch(g){console.error(g)}}},l=>s.openedIndexList.indexOf(l)!==-1,l=>{s.index=l,s.scrollDistance=-s.index*n.width;const a=n.routes[l];e("update:activePath",a.path)},n.moveRatio,n.momentumReduceRatio);o.onMounted(()=>{const l=_();u.el=l,u.open()}),o.onUnmounted(()=>{u.close()}),o.watchEffect(()=>{const l=n.activePath;s.index=n.routes.findIndex(w=>w.path===l);const a=n.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-a*s.index);const g=a*n.routes.length,T=-a/3,x=a*(n.routes.length-1)+a/3;u.columnWidth=a,u.width=g,u.min=T,u.max=x,u.swipeDuration=n.swipeDuration});const r=`fox-swiper-navigator-${G()}`,i=o.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let c=null;function _(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const f=o.computed(()=>`${n.width*n.routes.length}px`),p=(l,a)=>({style:{left:`${n.routes.findIndex(T=>{const x=l.path??l.name??"";return T.path==x})*n.width}px`,width:`${n.width}px`}});return(l,a)=>{const g=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(g,{class:o.normalizeClass(r),style:o.normalizeStyle(o.unref(i)),"view-class":"fox-swiper-navigator__item",tag:F,"view-tag-props":p,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":s.scrollDistance,"scroll-time":n.scrollTime,width:o.unref(f)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}})},Symbol.toStringTag,{value:"Module"}));let st="fox-";const at=[],O=Object.assign({"/src/components/card-navigator/index.vue":R,"/src/components/default-navigator/index.vue":I,"/src/components/root-navigator/index.vue":Y,"/src/components/swiper-navigator/index.vue":it}),P=[];for(const t in O){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];at.indexOf(e)===-1&&P.push({name:e,component:O[t].default})}return{install(t){P.forEach(e=>{t.component(`${st}${e.name}`,e.component)})}}});
|