@fox-js/navigation 4.0.1-4 → 4.0.1-6

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/README.md CHANGED
@@ -93,6 +93,8 @@ pageHelper.append({
93
93
  | remove-page | 关闭顶层页面方法 | Function | |
94
94
  | router-view-name | router view名称 | String | `default` |
95
95
  | view-tag | view tag标签 | Function/String | `div` |
96
+ | remove-move-ratio | 触发移除页面的移动比例(相对页面宽度) | Number | 0.5 |
97
+ | momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
96
98
 
97
99
 
98
100
 
@@ -280,6 +282,8 @@ onMounted(() => {
280
282
  | drag | 是否支持拖曳 | Boolean | |
281
283
  | swipe-duration | 滑动页面动画时间 | Number ||
282
284
  | scroll-time | 切换页面动画时间 | Number | |
285
+ | move-ratio | 触发页面移动的比例(相对页面宽度) | Number | 0.5 |
286
+ | momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
283
287
 
284
288
 
285
289
 
package/dist/index.cjs.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";/*!
2
- * @fox-js/navigation v4.0.1-3 Mon Dec 26 2022 11:59:21 GMT+0800 (中国标准时间)
3
- */const o=require("vue"),O=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,s)=>{const f=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(f,{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"])}}});const P=Object.freeze(Object.defineProperty({__proto__:null,default:O},Symbol.toStringTag,{value:"Module"})),C=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(n,s)=>{const f=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(f,{transition:!1,multi:!1,name:e.routerViewName},{default:o.withCtx(({Component:d})=>[o.createVNode(o.Transition,{name:"fox-default-navigator__trans"},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(d)))]),_:2},1024)]),_:1},8,["name"])}}});const I=Object.freeze(Object.defineProperty({__proto__:null,default:C},Symbol.toStringTag,{value:"Module"})),$=10;function S(t,e){return t>e&&t>$?"horizontal":e>t&&e>$?"vertical":""}function L(){const t=o.ref(0),e=o.ref(0),n=o.ref(0),s=o.ref(0),f=o.ref(0),d=o.ref(0),m=o.ref(0),_=o.ref(0),h=o.ref(0),c=o.ref(0),i=o.ref(""),r=()=>i.value==="vertical",g=()=>i.value==="horizontal",a=()=>{m.value=0,_.value=0,h.value=0,c.value=0,i.value="",n.value=0};return{move:u=>{const p=u.touches[0];m.value=p.clientX-t.value,_.value=p.clientY-e.value,f.value=p.clientX,d.value=p.clientY,h.value=Math.abs(m.value),c.value=Math.abs(_.value),s.value=Date.now()-n.value,i.value||(i.value=S(h.value,c.value))},start:u=>{a(),t.value=u.touches[0].clientX,e.value=u.touches[0].clientY,n.value=Date.now()},reset:a,startX:t,startY:e,startTime:n,duration:s,moveX:f,moveY:d,deltaX:m,deltaY:_,offsetX:h,offsetY:c,direction:i,isVertical:r,isHorizontal:g}}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,z=300,N=200;function k(t){t.stopPropagation()}function j(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&k(t)}function X(t,e){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function T(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 D=new WeakMap;function A(t,e,n=500,s,f=1e3){const d={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},m=t.previousSibling,_=L(),h=(a,v,l,u)=>{let p=v+d.startDistance;if(l==="end"){const x=V(a);let w=x.width/3;p<w?p=0:p=x.width;let y=!1;u&&u>0&&(y=!0,d.transitionEndTrigger=()=>{d.moving=!1,s&&a.classList.remove(s),p>0&&typeof e=="function"&&e()}),T(a,p,"end",u),m&&T(m,0,"",0),!y&&p>0&&typeof e=="function"&&e()}else p<0&&(p=0),T(a,p,"",0)},c=()=>{t.style.transform="",t.style.transition="",d.transitionEndTrigger?(d.transitionEndTrigger(),d.transitionEndTrigger=null,m&&setTimeout(()=>{!m||(m.style.transform="",m.style.transition="")},n)):m&&(m.style.transform="",m.style.transition="")},i=a=>{if(_.start(a),d.moving){const v=t,{transform:l}=window.getComputedStyle(v);d.scrollDistance=+l.slice(7,l.length-1).split(", ")[5]}s&&t.classList.add(s),d.startDistance=d.scrollDistance,d.transitionEndTrigger=null,d.moving=!0},r=a=>{d.moving=!0,_.move(a),_.isHorizontal()&&j(a,!0),h(t,_.deltaX.value,"",0)},g=()=>{const a=_.deltaX.value;if(a==0){s&&t.classList.remove(s);return}const v=_.duration.value;if(v<z&&Math.abs(a)>W){const u=X(a,v);h(t,u,"end",f)}else h(t,a,"end",f)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",i),t.addEventListener("touchmove",r),t.addEventListener("touchend",g),t.addEventListener("touchcancel",g),D.set(t,{state:d,transitionend:c,touchstart:i,touchmove:r,touchend:g,touchcancel:g})}function U(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 R=o.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,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(c){return(c.params&&c.params.animationType)??"slide"}const s=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${a}-${v}-from`,u=`fox-root-navigator__${a}-${v}-active`;c.classList.add(l),c.classList.add(u)}},f=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${a}-${v}-from`,u=`fox-root-navigator__${a}-${v}-to`;c.classList.remove(l),c.classList.add(u)}},d=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a!=="pop"||!i){const v=i?"show":"enter",l=`fox-root-navigator__${a}-${v}-active`,u=`fox-root-navigator__${a}-${v}-to`;c.classList.remove(l),c.classList.remove(u)}}e.dragRemove&&!i&&r.opsType===3&&A(c,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},m=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${a}-${v}-from`,u=`fox-root-navigator__${a}-${v}-active`;c.classList.add(l),c.classList.add(u)}},_=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${a}-${v}-from`,u=`fox-root-navigator__${a}-${v}-to`;c.classList.remove(l),c.classList.add(u)}},h=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a!=="pop"||!i){const v=i?"hide":"leave",l=`fox-root-navigator__${a}-${v}-active`,u=`fox-root-navigator__${a}-${v}-to`;c.classList.remove(l),c.classList.remove(u)}}e.dragRemove&&!i&&U(c)};return(c,i)=>{const r=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(r,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:f,"after-enter":d,"before-leave":m,leave:_,"after-leave":h,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}});const Y=Object.freeze(Object.defineProperty({__proto__:null,default:R},Symbol.toStringTag,{value:"Module"})),q={class:"fox-swiper-navigator"},H=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,f)=>(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 F=0;function G(){return++F}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){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function E(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;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,n,s,f){this.getStartDistance=e,this.openPage=n,this.isPageOpened=s,this.pageOpened=f}open(){const e=this.el,n=L(),s=(f,d,m,_)=>{let h=d+this.startDistance;const c=this.columnWidth/3;if(m==="end"){if(h==0){this.moving=!1;return}Math.abs(d)>c&&(d>0?h=this.startDistance+this.columnWidth:h=this.startDistance-this.columnWidth);let i=-h;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const r=Math.floor(i/this.columnWidth);this.isPageOpened(r)||this.openPage(r),h=-r*this.columnWidth,_&&_>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(r)}),E(f,h,"end",_),this.scrollDistance=h}else{if(Math.abs(d)>c){let r=0;if(d>0?r=Math.abs(this.startDistance+this.columnWidth):r=Math.abs(this.startDistance-this.columnWidth),r>=0&&r<this.width){const g=Math.floor(r/this.columnWidth);this.isPageOpened(g)||this.openPage(g)}}let i=-h;i<this.min?i=this.min:i>this.max&&(i=this.max),E(f,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=f=>{this.moving||(n.start(f),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=f=>{n.move(f),n.isHorizontal()&&tt(f,!0),s(e,n.deltaX.value,"",0)},this.touchend=()=>{const f=n.deltaX.value;if(f==0)return;const d=n.duration.value;if(d<K&&Math.abs(f)>J){const _=et(f,d);s(e,_,"end",this.swipeDuration)}else s(e,f,"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){return new nt(t,e,n,s)}const it=o.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,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:[]}),h=ot(()=>s.scrollDistance,l=>{if(s.openedIndexList.indexOf(l)===-1){s.openedIndexList.push(l);const u=n.routes[l];try{n.openViewPage(u,l)}catch(p){console.error(p)}}},l=>s.openedIndexList.indexOf(l)!==-1,l=>{s.index=l,s.scrollDistance=-s.index*n.width;const u=n.routes[l];e("update:activePath",u.path)});o.onMounted(()=>{const l=g();h.el=l,h.open()}),o.onUnmounted(()=>{h.close()}),o.watchEffect(()=>{const l=n.activePath;s.index=n.routes.findIndex(y=>y.path===l);const u=n.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-u*s.index);const p=u*n.routes.length,x=-u/3,w=u*(n.routes.length-1)+u/3;h.columnWidth=u,h.width=p,h.min=x,h.max=w,h.swipeDuration=n.swipeDuration});const c=`fox-swiper-navigator-${G()}`,i=o.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let r=null;function g(){return r||(r=document.querySelector(`.${c}>.fox-swiper-navigator__inner`),r)}const a=o.computed(()=>`${n.width*n.routes.length}px`),v=(l,u)=>({style:{left:`${n.routes.findIndex(x=>{const w=l.path??l.name??"";return x.path==w})*n.width}px`,width:`${n.width}px`}});return(l,u)=>{const p=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(p,{class:o.normalizeClass(c),style:o.normalizeStyle(o.unref(i)),"view-class":"fox-swiper-navigator__item",tag:H,"view-tag-props":v,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":s.scrollDistance,"scroll-time":n.scrollTime,width:o.unref(a)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}});const st=Object.freeze(Object.defineProperty({__proto__:null,default:it},Symbol.toStringTag,{value:"Module"}));let at="fox-";const rt=[],b=Object.assign({"/src/components/card-navigator/index.vue":P,"/src/components/default-navigator/index.vue":I,"/src/components/root-navigator/index.vue":Y,"/src/components/swiper-navigator/index.vue":st}),M=[];for(const t in b){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];rt.indexOf(e)===-1&&M.push({name:e,component:b[t].default})}const ct={install(t){M.forEach(e=>{t.component(`${at}${e.name}`,e.component)})}};module.exports=ct;
2
+ * @fox-js/navigation v4.0.1-5 Sat Dec 23 2023 22:28:42 GMT+0800 (中国标准时间)
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;
package/dist/index.d.ts CHANGED
@@ -5,8 +5,11 @@ declare const _default: {
5
5
  * 安装
6
6
  * @param app
7
7
  */
8
- install(app: App): void;
8
+ install(app: VueApp): void;
9
9
  };
10
10
  export default _default;
11
11
 
12
+ export declare interface VueApp extends App {
13
+ }
14
+
12
15
  export { }
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
- import { defineComponent as D, resolveComponent as b, openBlock as w, createBlock as T, withCtx as P, createVNode as z, Transition as j, resolveDynamicComponent as B, ref as g, unref as E, computed as M, createElementBlock as X, createElementVNode as A, normalizeStyle as V, renderSlot as U, reactive as R, onMounted as Y, onUnmounted as k, watchEffect as H, normalizeClass as q } from "vue";
1
+ import { defineComponent as D, resolveComponent as L, openBlock as T, createBlock as y, withCtx as R, createVNode as j, Transition as B, resolveDynamicComponent as X, ref as x, unref as b, computed as M, createElementBlock as A, createElementVNode as U, normalizeStyle as V, renderSlot as Y, reactive as k, onMounted as H, onUnmounted as q, watchEffect as F, normalizeClass as G } from "vue";
2
2
  /*!
3
- * @fox-js/navigation v4.0.1-3 Mon Dec 26 2022 11:59:21 GMT+0800 (中国标准时间)
3
+ * @fox-js/navigation v4.0.1-5 Sat Dec 23 2023 22:28:42 GMT+0800 (中国标准时间)
4
4
  */
5
- const F = /* @__PURE__ */ D({
5
+ const J = /* @__PURE__ */ D({
6
6
  __name: "index",
7
7
  props: {
8
8
  routerViewName: null,
@@ -11,8 +11,8 @@ const F = /* @__PURE__ */ D({
11
11
  setup(t) {
12
12
  const e = t;
13
13
  return (n, i) => {
14
- const d = b("fox-router-view");
15
- return w(), T(d, {
14
+ const f = L("fox-router-view");
15
+ return T(), y(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,11 +24,10 @@ const F = /* @__PURE__ */ D({
24
24
  }, null, 8, ["transition", "name"]);
25
25
  };
26
26
  }
27
- });
28
- const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
27
+ }), K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
29
28
  __proto__: null,
30
- default: F
31
- }, Symbol.toStringTag, { value: "Module" })), J = /* @__PURE__ */ D({
29
+ default: J
30
+ }, Symbol.toStringTag, { value: "Module" })), Q = /* @__PURE__ */ D({
32
31
  __name: "index",
33
32
  props: {
34
33
  routerViewName: null,
@@ -37,16 +36,16 @@ const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
37
36
  setup(t) {
38
37
  const e = t;
39
38
  return (n, i) => {
40
- const d = b("fox-router-view");
41
- return w(), T(d, {
39
+ const f = L("fox-router-view");
40
+ return T(), y(f, {
42
41
  transition: !1,
43
42
  multi: !1,
44
43
  name: e.routerViewName
45
44
  }, {
46
- default: P(({ Component: u }) => [
47
- z(j, { name: "fox-default-navigator__trans" }, {
48
- default: P(() => [
49
- (w(), T(B(u)))
45
+ default: R(({ Component: h }) => [
46
+ j(B, { name: "fox-default-navigator__trans" }, {
47
+ default: R(() => [
48
+ (T(), y(X(h)))
50
49
  ]),
51
50
  _: 2
52
51
  }, 1024)
@@ -55,48 +54,47 @@ const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
55
54
  }, 8, ["name"]);
56
55
  };
57
56
  }
58
- });
59
- const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
57
+ }), Z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
60
58
  __proto__: null,
61
- default: J
59
+ default: Q
62
60
  }, Symbol.toStringTag, { value: "Module" })), I = 10;
63
- function Q(t, e) {
61
+ function tt(t, e) {
64
62
  return t > e && t > I ? "horizontal" : e > t && e > I ? "vertical" : "";
65
63
  }
66
64
  function W() {
67
- const t = g(0), e = g(0), n = g(0), i = g(0), d = g(0), u = g(0), m = g(0), p = g(0), f = g(0), r = g(0), o = g(""), a = () => o.value === "vertical", _ = () => o.value === "horizontal", s = () => {
68
- m.value = 0, p.value = 0, f.value = 0, r.value = 0, o.value = "", n.value = 0;
65
+ const t = x(0), e = x(0), n = x(0), i = x(0), f = x(0), h = x(0), p = x(0), d = x(0), l = x(0), a = x(0), o = x(""), r = () => o.value === "vertical", g = () => o.value === "horizontal", u = () => {
66
+ p.value = 0, d.value = 0, l.value = 0, a.value = 0, o.value = "", n.value = 0;
69
67
  };
70
68
  return {
71
- move: (l) => {
72
- const v = l.touches[0];
73
- m.value = v.clientX - t.value, p.value = v.clientY - e.value, d.value = v.clientX, u.value = v.clientY, f.value = Math.abs(m.value), r.value = Math.abs(p.value), i.value = Date.now() - n.value, o.value || (o.value = Q(f.value, r.value));
69
+ move: (c) => {
70
+ const v = c.touches[0];
71
+ p.value = v.clientX - t.value, d.value = v.clientY - e.value, f.value = v.clientX, h.value = v.clientY, l.value = Math.abs(p.value), a.value = Math.abs(d.value), i.value = Date.now() - n.value, o.value || (o.value = tt(l.value, a.value));
74
72
  },
75
- start: (l) => {
76
- s(), t.value = l.touches[0].clientX, e.value = l.touches[0].clientY, n.value = Date.now();
73
+ start: (c) => {
74
+ u(), t.value = c.touches[0].clientX, e.value = c.touches[0].clientY, n.value = Date.now();
77
75
  },
78
- reset: s,
76
+ reset: u,
79
77
  startX: t,
80
78
  startY: e,
81
79
  startTime: n,
82
80
  duration: i,
83
- moveX: d,
84
- moveY: u,
85
- deltaX: m,
86
- deltaY: p,
87
- offsetX: f,
88
- offsetY: r,
81
+ moveX: f,
82
+ moveY: h,
83
+ deltaX: p,
84
+ deltaY: d,
85
+ offsetX: l,
86
+ offsetY: a,
89
87
  direction: o,
90
- isVertical: a,
91
- isHorizontal: _
88
+ isVertical: r,
89
+ isHorizontal: g
92
90
  };
93
91
  }
94
- function Z(t) {
92
+ function et(t) {
95
93
  return t === window;
96
94
  }
97
- const tt = (t) => {
98
- const e = E(t);
99
- if (Z(e)) {
95
+ const nt = (t) => {
96
+ const e = b(t);
97
+ if (et(e)) {
100
98
  const n = e.innerWidth, i = e.innerHeight;
101
99
  return {
102
100
  top: 0,
@@ -115,83 +113,85 @@ const tt = (t) => {
115
113
  width: 0,
116
114
  height: 0
117
115
  };
118
- }, et = 15, nt = 300, ot = 200;
119
- function it(t) {
116
+ }, ot = 15, it = 300, st = 200;
117
+ function at(t) {
120
118
  t.stopPropagation();
121
119
  }
122
- function st(t, e) {
123
- (typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && it(t);
120
+ function rt(t, e) {
121
+ (typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && at(t);
124
122
  }
125
- function at(t, e) {
126
- return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t;
123
+ function ct(t, e, n = 1) {
124
+ return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t * n;
127
125
  }
128
- function L(t, e = 0, n, i = ot) {
126
+ function $(t, e = 0, n, i = st) {
129
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)`;
130
128
  }
131
129
  const O = /* @__PURE__ */ new WeakMap();
132
- function rt(t, e, n = 500, i, d = 1e3) {
133
- const u = {
130
+ function lt(t, e, n, i, f = 500, h, p = 1e3) {
131
+ const d = {
134
132
  active: !0,
135
133
  startDistance: 0,
136
134
  scrollDistance: 0,
137
135
  scrollTime: 0,
138
136
  moving: !1,
139
137
  transitionEndTrigger: null
140
- }, m = t.previousSibling, p = W(), f = (s, h, c, l) => {
141
- let v = h + u.startDistance;
142
- if (c === "end") {
143
- const x = tt(s);
144
- let y = x.width / 3;
145
- v < y ? v = 0 : v = x.width;
146
- let $ = !1;
147
- l && l > 0 && ($ = !0, u.transitionEndTrigger = () => {
148
- u.moving = !1, i && s.classList.remove(i), v > 0 && typeof e == "function" && e();
149
- }), L(s, v, "end", l), m && L(m, 0, "", 0), !$ && v > 0 && typeof e == "function" && e();
138
+ }, l = t.previousSibling, a = W(), o = (s, c, v, w) => {
139
+ let _ = c + d.startDistance;
140
+ if (v === "end") {
141
+ const E = nt(s);
142
+ let z = E.width * e;
143
+ _ < z ? _ = 0 : _ = E.width;
144
+ let P = !1;
145
+ w && w > 0 && (P = !0, d.transitionEndTrigger = () => {
146
+ d.moving = !1, h && s.classList.remove(h), _ > 0 && typeof i == "function" && i();
147
+ }), $(s, _, "end", w), l && $(l, 0, "", 0), !P && _ > 0 && typeof i == "function" && i();
150
148
  } else
151
- v < 0 && (v = 0), L(s, v, "", 0);
149
+ _ < 0 && (_ = 0), $(s, _, "", 0);
152
150
  }, r = () => {
153
- t.style.transform = "", t.style.transition = "", u.transitionEndTrigger ? (u.transitionEndTrigger(), u.transitionEndTrigger = null, m && setTimeout(() => {
154
- !m || (m.style.transform = "", m.style.transition = "");
155
- }, n)) : m && (m.style.transform = "", m.style.transition = "");
156
- }, o = (s) => {
157
- if (p.start(s), u.moving) {
158
- const h = t, { transform: c } = window.getComputedStyle(h);
159
- u.scrollDistance = +c.slice(7, c.length - 1).split(", ")[5];
151
+ t.style.transform = "", t.style.transition = "", d.transitionEndTrigger ? (d.transitionEndTrigger(), d.transitionEndTrigger = null, l && setTimeout(() => {
152
+ l && (l.style.transform = "", l.style.transition = "");
153
+ }, f)) : l && (l.style.transform = "", l.style.transition = "");
154
+ }, g = (s) => {
155
+ if (a.start(s), d.moving) {
156
+ const c = t, { transform: v } = window.getComputedStyle(c);
157
+ d.scrollDistance = +v.slice(7, v.length - 1).split(", ")[5];
160
158
  }
161
- i && t.classList.add(i), u.startDistance = u.scrollDistance, u.transitionEndTrigger = null, u.moving = !0;
162
- }, a = (s) => {
163
- u.moving = !0, p.move(s), p.isHorizontal() && st(s, !0), f(t, p.deltaX.value, "", 0);
164
- }, _ = () => {
165
- const s = p.deltaX.value;
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
+ const s = a.deltaX.value;
166
164
  if (s == 0) {
167
- i && t.classList.remove(i);
165
+ h && t.classList.remove(h);
168
166
  return;
169
167
  }
170
- const h = p.duration.value;
171
- if (h < nt && Math.abs(s) > et) {
172
- const l = at(s, h);
173
- f(t, l, "end", d);
168
+ const c = a.duration.value;
169
+ if (c < it && Math.abs(s) > ot) {
170
+ const w = ct(s, c, n);
171
+ o(t, w, "end", p);
174
172
  } else
175
- f(t, s, "end", d);
173
+ o(t, s, "end", p);
176
174
  };
177
- t.addEventListener("transitionend", r), t.addEventListener("touchstart", o), t.addEventListener("touchmove", a), t.addEventListener("touchend", _), t.addEventListener("touchcancel", _), O.set(t, {
178
- state: u,
175
+ t.addEventListener("transitionend", r), t.addEventListener("touchstart", g), t.addEventListener("touchmove", u), t.addEventListener("touchend", m), t.addEventListener("touchcancel", m), O.set(t, {
176
+ state: d,
179
177
  transitionend: r,
180
- touchstart: o,
181
- touchmove: a,
182
- touchend: _,
183
- touchcancel: _
178
+ touchstart: g,
179
+ touchmove: u,
180
+ touchend: m,
181
+ touchcancel: m
184
182
  });
185
183
  }
186
- function ct(t) {
184
+ function ut(t) {
187
185
  const e = O.get(t);
188
186
  e && (O.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));
189
187
  }
190
- const lt = /* @__PURE__ */ D({
188
+ const dt = /* @__PURE__ */ D({
191
189
  __name: "index",
192
190
  props: {
193
191
  dragRemove: { type: Boolean, default: !0 },
194
192
  removeViewPage: null,
193
+ removeMoveRatio: { default: 0.5 },
194
+ momentumReduceRatio: { default: 1 },
195
195
  removeViewPageDuration: { default: 500 },
196
196
  routerViewName: null,
197
197
  viewTag: { default: "div" },
@@ -200,71 +200,79 @@ const lt = /* @__PURE__ */ D({
200
200
  },
201
201
  setup(t) {
202
202
  const e = t;
203
- function n(r) {
204
- return (r.params && r.params.animationType) ?? "slide";
203
+ function n(a) {
204
+ return (a.params && a.params.animationType) ?? "slide";
205
205
  }
206
- const i = (r, o, a, _) => {
207
- if (a.opsType === 3 || o) {
208
- const s = n(a);
209
- if (s === "pop" && o)
206
+ const i = (a, o, r, g) => {
207
+ if (r.opsType === 3 || o) {
208
+ const u = n(r);
209
+ if (u === "pop" && o)
210
210
  return;
211
- const h = o ? "show" : "enter", c = `fox-root-navigator__${s}-${h}-from`, l = `fox-root-navigator__${s}-${h}-active`;
212
- r.classList.add(c), r.classList.add(l);
211
+ const m = o ? "show" : "enter", s = `fox-root-navigator__${u}-${m}-from`, c = `fox-root-navigator__${u}-${m}-active`;
212
+ a.classList.add(s), a.classList.add(c);
213
213
  }
214
- }, d = (r, o, a, _) => {
215
- if (a.opsType === 3 || o) {
216
- const s = n(a);
217
- if (s === "pop" && o)
214
+ }, f = (a, o, r, g) => {
215
+ if (r.opsType === 3 || o) {
216
+ const u = n(r);
217
+ if (u === "pop" && o)
218
218
  return;
219
- const h = o ? "show" : "enter", c = `fox-root-navigator__${s}-${h}-from`, l = `fox-root-navigator__${s}-${h}-to`;
220
- r.classList.remove(c), r.classList.add(l);
219
+ const m = o ? "show" : "enter", s = `fox-root-navigator__${u}-${m}-from`, c = `fox-root-navigator__${u}-${m}-to`;
220
+ a.classList.remove(s), a.classList.add(c);
221
221
  }
222
- }, u = (r, o, a, _) => {
223
- if (a.opsType === 3 || o) {
224
- const s = n(a);
225
- if (s !== "pop" || !o) {
226
- const h = o ? "show" : "enter", c = `fox-root-navigator__${s}-${h}-active`, l = `fox-root-navigator__${s}-${h}-to`;
227
- r.classList.remove(c), r.classList.remove(l);
222
+ }, h = (a, o, r, g) => {
223
+ if (r.opsType === 3 || o) {
224
+ const u = n(r);
225
+ if (u !== "pop" || !o) {
226
+ const m = o ? "show" : "enter", s = `fox-root-navigator__${u}-${m}-active`, c = `fox-root-navigator__${u}-${m}-to`;
227
+ a.classList.remove(s), a.classList.remove(c);
228
228
  }
229
229
  }
230
- e.dragRemove && !o && a.opsType === 3 && rt(r, e.removeViewPage, e.removeViewPageDuration, "fox-root-navigator__item-moving", 1e3);
231
- }, m = (r, o, a, _) => {
232
- if (a.opsType === 3 || o) {
233
- const s = n(a);
234
- if (s === "pop" && o)
230
+ e.dragRemove && !o && r.opsType === 3 && lt(
231
+ a,
232
+ e.removeMoveRatio,
233
+ e.momentumReduceRatio,
234
+ e.removeViewPage,
235
+ e.removeViewPageDuration,
236
+ "fox-root-navigator__item-moving",
237
+ 1e3
238
+ );
239
+ }, p = (a, o, r, g) => {
240
+ if (r.opsType === 3 || o) {
241
+ const u = n(r);
242
+ if (u === "pop" && o)
235
243
  return;
236
- const h = o ? "hide" : "leave", c = `fox-root-navigator__${s}-${h}-from`, l = `fox-root-navigator__${s}-${h}-active`;
237
- r.classList.add(c), r.classList.add(l);
244
+ const m = o ? "hide" : "leave", s = `fox-root-navigator__${u}-${m}-from`, c = `fox-root-navigator__${u}-${m}-active`;
245
+ a.classList.add(s), a.classList.add(c);
238
246
  }
239
- }, p = (r, o, a, _) => {
240
- if (a.opsType === 3 || o) {
241
- const s = n(a);
242
- if (s === "pop" && o)
247
+ }, d = (a, o, r, g) => {
248
+ if (r.opsType === 3 || o) {
249
+ const u = n(r);
250
+ if (u === "pop" && o)
243
251
  return;
244
- const h = o ? "hide" : "leave", c = `fox-root-navigator__${s}-${h}-from`, l = `fox-root-navigator__${s}-${h}-to`;
245
- r.classList.remove(c), r.classList.add(l);
252
+ const m = o ? "hide" : "leave", s = `fox-root-navigator__${u}-${m}-from`, c = `fox-root-navigator__${u}-${m}-to`;
253
+ a.classList.remove(s), a.classList.add(c);
246
254
  }
247
- }, f = (r, o, a, _) => {
248
- if (a.opsType === 3 || o) {
249
- const s = n(a);
250
- if (s !== "pop" || !o) {
251
- const h = o ? "hide" : "leave", c = `fox-root-navigator__${s}-${h}-active`, l = `fox-root-navigator__${s}-${h}-to`;
252
- r.classList.remove(c), r.classList.remove(l);
255
+ }, l = (a, o, r, g) => {
256
+ if (r.opsType === 3 || o) {
257
+ const u = n(r);
258
+ if (u !== "pop" || !o) {
259
+ const m = o ? "hide" : "leave", s = `fox-root-navigator__${u}-${m}-active`, c = `fox-root-navigator__${u}-${m}-to`;
260
+ a.classList.remove(s), a.classList.remove(c);
253
261
  }
254
262
  }
255
- e.dragRemove && !o && ct(r);
263
+ e.dragRemove && !o && ut(a);
256
264
  };
257
- return (r, o) => {
258
- const a = b("fox-router-view");
259
- return w(), T(a, {
265
+ return (a, o) => {
266
+ const r = L("fox-router-view");
267
+ return T(), y(r, {
260
268
  class: "fox-root-navigator",
261
269
  "view-class": t.viewClass,
262
270
  "before-enter": i,
263
- enter: d,
264
- "after-enter": u,
265
- "before-leave": m,
266
- leave: p,
267
- "after-leave": f,
271
+ enter: f,
272
+ "after-enter": h,
273
+ "before-leave": p,
274
+ leave: d,
275
+ "after-leave": l,
268
276
  multi: !0,
269
277
  name: e.routerViewName,
270
278
  "view-tag": e.viewTag,
@@ -272,11 +280,10 @@ const lt = /* @__PURE__ */ D({
272
280
  }, null, 8, ["view-class", "name", "view-tag", "transition"]);
273
281
  };
274
282
  }
275
- });
276
- const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
283
+ }), ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
277
284
  __proto__: null,
278
- default: lt
279
- }, Symbol.toStringTag, { value: "Module" })), dt = { class: "fox-swiper-navigator" }, ft = /* @__PURE__ */ D({
285
+ default: dt
286
+ }, Symbol.toStringTag, { value: "Module" })), ht = { class: "fox-swiper-navigator" }, mt = /* @__PURE__ */ D({
280
287
  __name: "swiper",
281
288
  props: {
282
289
  width: null,
@@ -285,114 +292,196 @@ const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
285
292
  },
286
293
  setup(t) {
287
294
  const e = t, n = M(() => ({
295
+ // transition: `transform ${props.scrollTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
288
296
  transform: `translate3d(${e.scrollDistance}px, 0, 0)`,
289
297
  width: `${e.width}`
290
298
  }));
291
- return (i, d) => (w(), X("div", dt, [
292
- A("div", {
299
+ return (i, f) => (T(), A("div", ht, [
300
+ U("div", {
293
301
  class: "fox-swiper-navigator__inner",
294
- style: V(E(n))
302
+ style: V(b(n))
295
303
  }, [
296
- U(i.$slots, "default")
304
+ Y(i.$slots, "default")
297
305
  ], 4)
298
306
  ]));
299
307
  }
300
308
  });
301
- let ht = 0;
302
- function vt() {
303
- return ++ht;
309
+ let vt = 0;
310
+ function pt() {
311
+ return ++vt;
304
312
  }
305
- const mt = 15, pt = 300, _t = 200;
306
- function gt(t) {
313
+ const gt = 15, _t = 300, xt = 200;
314
+ function wt(t) {
307
315
  t.stopPropagation();
308
316
  }
309
- function xt(t, e) {
310
- (typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && gt(t);
317
+ function Tt(t, e) {
318
+ (typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && wt(t);
311
319
  }
312
- function wt(t, e) {
313
- return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t;
320
+ function yt(t, e, n = 1) {
321
+ return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t * n;
314
322
  }
315
- function S(t, e = 0, n, i = _t) {
323
+ function S(t, e = 0, n, i = xt) {
316
324
  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)`;
317
325
  }
318
- class yt {
326
+ class Dt {
327
+ /**
328
+ * width
329
+ */
319
330
  width = 0;
331
+ /**
332
+ * column width
333
+ */
320
334
  columnWidth = 0;
335
+ /**
336
+ * max
337
+ */
321
338
  max = 0;
339
+ /**
340
+ * min
341
+ */
322
342
  min = 0;
343
+ /**
344
+ * element
345
+ */
323
346
  el = null;
347
+ /**
348
+ * swipe duration
349
+ */
324
350
  swipeDuration = 360;
351
+ /**
352
+ * transitionEndTrigger
353
+ */
325
354
  transitionEndTrigger = null;
355
+ /**
356
+ * moving
357
+ */
326
358
  moving = !1;
359
+ /**
360
+ * start distance
361
+ */
327
362
  startDistance = 0;
363
+ /**
364
+ * scroll distance
365
+ */
328
366
  scrollDistance = 0;
367
+ /**
368
+ * 获取start distance
369
+ */
329
370
  getStartDistance;
371
+ /**
372
+ * open page
373
+ */
330
374
  openPage;
375
+ /**
376
+ * is page opened
377
+ */
331
378
  isPageOpened;
379
+ /**
380
+ * page opened
381
+ */
332
382
  pageOpened;
383
+ /**
384
+ *触发移动页面的移动比例(相对页面)
385
+ */
386
+ moveRatio = 0.5;
387
+ /**
388
+ * 惯性削减比例
389
+ */
390
+ momentumReduceRatio = 1;
391
+ /**
392
+ * transitionend
393
+ */
333
394
  transitionend = null;
395
+ /**
396
+ * touchstart
397
+ */
334
398
  touchstart = null;
399
+ /**
400
+ * touchmove
401
+ */
335
402
  touchmove = null;
403
+ /**
404
+ * touchend
405
+ */
336
406
  touchend = null;
407
+ /**
408
+ * touchcancel
409
+ */
337
410
  touchcancel = null;
338
- constructor(e, n, i, d) {
339
- this.getStartDistance = e, this.openPage = n, this.isPageOpened = i, this.pageOpened = d;
411
+ /**
412
+ * 构造函数
413
+ * @param getStartDistance
414
+ * @param openPage
415
+ * @param isPageOpened
416
+ * @param pageOpened
417
+ * @param moveRatio
418
+ * @param momentumReduceRatio
419
+ *
420
+ */
421
+ constructor(e, n, i, f, h, p) {
422
+ this.getStartDistance = e, this.openPage = n, this.isPageOpened = i, this.pageOpened = f, this.moveRatio = h, this.momentumReduceRatio = p;
340
423
  }
424
+ /**
425
+ * 打开drag支持
426
+ */
341
427
  open() {
342
- const e = this.el, n = W(), i = (d, u, m, p) => {
343
- let f = u + this.startDistance;
344
- const r = this.columnWidth / 3;
345
- if (m === "end") {
346
- if (f == 0) {
428
+ const e = this.el, n = W(), i = (f, h, p, d) => {
429
+ let l = h + this.startDistance;
430
+ const a = this.columnWidth * this.moveRatio;
431
+ if (p === "end") {
432
+ if (l == 0) {
347
433
  this.moving = !1;
348
434
  return;
349
435
  }
350
- Math.abs(u) > r && (u > 0 ? f = this.startDistance + this.columnWidth : f = this.startDistance - this.columnWidth);
351
- let o = -f;
436
+ Math.abs(h) > a && (h > 0 ? l = this.startDistance + this.columnWidth : l = this.startDistance - this.columnWidth);
437
+ let o = -l;
352
438
  o < 0 ? o = 0 : o > this.width - this.columnWidth && (o = this.width - this.columnWidth);
353
- const a = Math.floor(o / this.columnWidth);
354
- this.isPageOpened(a) || this.openPage(a), f = -a * this.columnWidth, p && p > 0 && (this.transitionEndTrigger = () => {
355
- this.moving = !1, this.pageOpened(a);
356
- }), S(d, f, "end", p), this.scrollDistance = f;
439
+ const r = Math.floor(o / this.columnWidth);
440
+ this.isPageOpened(r) || this.openPage(r), l = -r * this.columnWidth, d && d > 0 && (this.transitionEndTrigger = () => {
441
+ this.moving = !1, this.pageOpened(r);
442
+ }), S(f, l, "end", d), this.scrollDistance = l;
357
443
  } else {
358
- if (Math.abs(u) > r) {
359
- let a = 0;
360
- if (u > 0 ? a = Math.abs(this.startDistance + this.columnWidth) : a = Math.abs(this.startDistance - this.columnWidth), a >= 0 && a < this.width) {
361
- const _ = Math.floor(a / this.columnWidth);
362
- this.isPageOpened(_) || this.openPage(_);
444
+ if (Math.abs(h) > a) {
445
+ let r = 0;
446
+ if (h > 0 ? r = Math.abs(this.startDistance + this.columnWidth) : r = Math.abs(this.startDistance - this.columnWidth), r >= 0 && r < this.width) {
447
+ const g = Math.floor(r / this.columnWidth);
448
+ this.isPageOpened(g) || this.openPage(g);
363
449
  }
364
450
  }
365
- let o = -f;
366
- o < this.min ? o = this.min : o > this.max && (o = this.max), S(d, -o, "", 0);
451
+ let o = -l;
452
+ o < this.min ? o = this.min : o > this.max && (o = this.max), S(f, -o, "", 0);
367
453
  }
368
454
  };
369
455
  this.transitionend = () => {
370
456
  e.style.transition = "", this.transitionEndTrigger && (this.transitionEndTrigger(), this.transitionEndTrigger = null);
371
- }, this.touchstart = (d) => {
372
- this.moving || (n.start(d), this.startDistance = this.getStartDistance(), this.transitionEndTrigger = null, this.moving = !0);
373
- }, this.touchmove = (d) => {
374
- n.move(d), n.isHorizontal() && xt(d, !0), i(e, n.deltaX.value, "", 0);
457
+ }, this.touchstart = (f) => {
458
+ this.moving || (n.start(f), this.startDistance = this.getStartDistance(), this.transitionEndTrigger = null, this.moving = !0);
459
+ }, this.touchmove = (f) => {
460
+ n.move(f), n.isHorizontal() && Tt(f, !0), i(e, n.deltaX.value, "", 0);
375
461
  }, this.touchend = () => {
376
- const d = n.deltaX.value;
377
- if (d == 0)
462
+ const f = n.deltaX.value;
463
+ if (f == 0)
378
464
  return;
379
- const u = n.duration.value;
380
- if (u < pt && Math.abs(d) > mt) {
381
- const p = wt(d, u);
382
- i(e, p, "end", this.swipeDuration);
383
- } else
465
+ const h = n.duration.value;
466
+ if (h < _t && Math.abs(f) > gt) {
467
+ const d = yt(f, h, this.momentumReduceRatio);
384
468
  i(e, d, "end", this.swipeDuration);
469
+ } else
470
+ i(e, f, "end", this.swipeDuration);
385
471
  }, 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);
386
472
  }
473
+ /**
474
+ * 关闭drag支持
475
+ */
387
476
  close() {
388
477
  const e = this.el;
389
478
  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;
390
479
  }
391
480
  }
392
- function Tt(t, e, n, i) {
393
- return new yt(t, e, n, i);
481
+ function Et(t, e, n, i) {
482
+ return new Dt(t, e, n, i);
394
483
  }
395
- const Dt = /* @__PURE__ */ D({
484
+ const bt = /* @__PURE__ */ D({
396
485
  __name: "index",
397
486
  props: {
398
487
  activePath: null,
@@ -402,96 +491,101 @@ const Dt = /* @__PURE__ */ D({
402
491
  drag: { type: Boolean, default: !0 },
403
492
  openViewPage: null,
404
493
  routerViewName: null,
494
+ moveRatio: { default: 0.5 },
495
+ momentumReduceRatio: { default: 1 },
405
496
  transition: { type: [Object, Boolean], default: !0 },
406
497
  swipeDuration: { default: 360 },
407
498
  scrollTime: { default: 0 }
408
499
  },
409
500
  emits: ["update:activePath"],
410
501
  setup(t, { emit: e }) {
411
- const n = t, i = R({
502
+ const n = t, i = k({
412
503
  scrollDistance: 0,
413
504
  index: -1,
414
505
  openedIndexList: []
415
- }), f = Tt(() => i.scrollDistance, (c) => {
416
- if (i.openedIndexList.indexOf(c) === -1) {
417
- i.openedIndexList.push(c);
418
- const l = n.routes[c];
506
+ }), l = Et(() => i.scrollDistance, (s) => {
507
+ if (i.openedIndexList.indexOf(s) === -1) {
508
+ i.openedIndexList.push(s);
509
+ const c = n.routes[s];
419
510
  try {
420
- n.openViewPage(l, c);
511
+ n.openViewPage(c, s);
421
512
  } catch (v) {
422
513
  console.error(v);
423
514
  }
424
515
  }
425
- }, (c) => i.openedIndexList.indexOf(c) !== -1, (c) => {
426
- i.index = c, i.scrollDistance = -i.index * n.width;
427
- const l = n.routes[c];
428
- e("update:activePath", l.path);
516
+ }, (s) => i.openedIndexList.indexOf(s) !== -1, (s) => {
517
+ i.index = s, i.scrollDistance = -i.index * n.width;
518
+ const c = n.routes[s];
519
+ e("update:activePath", c.path);
429
520
  });
430
- Y(() => {
431
- const c = _();
432
- f.el = c, f.open();
433
- }), k(() => {
434
- f.close();
435
- }), H(() => {
436
- const c = n.activePath;
437
- i.index = n.routes.findIndex(($) => $.path === c);
438
- const l = n.width;
439
- i.index !== -1 && (i.openedIndexList.push(i.index), i.scrollDistance = -l * i.index);
440
- const v = l * n.routes.length, x = -l / 3, y = l * (n.routes.length - 1) + l / 3;
441
- f.columnWidth = l, f.width = v, f.min = x, f.max = y, f.swipeDuration = n.swipeDuration;
521
+ H(() => {
522
+ const s = g();
523
+ l.el = s, l.open();
524
+ }), q(() => {
525
+ l.close();
526
+ }), F(() => {
527
+ const s = n.activePath;
528
+ i.index = n.routes.findIndex((E) => E.path === s);
529
+ const c = n.width;
530
+ i.index !== -1 && (i.openedIndexList.push(i.index), i.scrollDistance = -c * i.index);
531
+ const v = c * n.routes.length, w = -c / 3, _ = c * (n.routes.length - 1) + c / 3;
532
+ l.columnWidth = c, l.width = v, l.min = w, l.max = _, l.swipeDuration = n.swipeDuration;
442
533
  });
443
- const r = `fox-swiper-navigator-${vt()}`, o = M(() => ({ width: `${n.width}px`, height: `${n.height}px` }));
444
- let a = null;
445
- function _() {
446
- return a || (a = document.querySelector(`.${r}>.fox-swiper-navigator__inner`), a);
534
+ const a = `fox-swiper-navigator-${pt()}`, o = M(() => ({ width: `${n.width}px`, height: `${n.height}px` }));
535
+ let r = null;
536
+ function g() {
537
+ return r || (r = document.querySelector(`.${a}>.fox-swiper-navigator__inner`), r);
447
538
  }
448
- const s = M(() => `${n.width * n.routes.length}px`), h = (c, l) => ({
539
+ const u = M(() => `${n.width * n.routes.length}px`), m = (s, c) => ({
449
540
  style: {
450
- left: `${n.routes.findIndex((x) => {
451
- const y = c.path ?? c.name ?? "";
452
- return x.path == y;
541
+ left: `${n.routes.findIndex((w) => {
542
+ const _ = s.path ?? s.name ?? "";
543
+ return w.path == _;
453
544
  }) * n.width}px`,
454
545
  width: `${n.width}px`
455
546
  }
456
547
  });
457
- return (c, l) => {
458
- const v = b("fox-router-view");
459
- return w(), T(v, {
460
- class: q(r),
461
- style: V(E(o)),
548
+ return (s, c) => {
549
+ const v = L("fox-router-view");
550
+ return T(), y(v, {
551
+ class: G(a),
552
+ style: V(b(o)),
462
553
  "view-class": "fox-swiper-navigator__item",
463
- tag: ft,
464
- "view-tag-props": h,
554
+ tag: mt,
555
+ "view-tag-props": m,
465
556
  multi: !0,
466
557
  name: n.routerViewName,
467
558
  transition: n.transition,
468
559
  "scroll-distance": i.scrollDistance,
469
560
  "scroll-time": n.scrollTime,
470
- width: E(s)
561
+ width: b(u)
471
562
  }, null, 8, ["style", "name", "transition", "scroll-distance", "scroll-time", "width"]);
472
563
  };
473
564
  }
474
- });
475
- const $t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
565
+ }), Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
476
566
  __proto__: null,
477
- default: Dt
567
+ default: bt
478
568
  }, Symbol.toStringTag, { value: "Module" }));
479
- let Et = "fox-";
480
- const bt = [], C = /* @__PURE__ */ Object.assign({ "/src/components/card-navigator/index.vue": G, "/src/components/default-navigator/index.vue": K, "/src/components/root-navigator/index.vue": ut, "/src/components/swiper-navigator/index.vue": $t }), N = [];
569
+ let $t = "fox-";
570
+ const Mt = [], C = /* @__PURE__ */ Object.assign({ "/src/components/card-navigator/index.vue": K, "/src/components/default-navigator/index.vue": Z, "/src/components/root-navigator/index.vue": ft, "/src/components/swiper-navigator/index.vue": Lt }), N = [];
481
571
  for (const t in C) {
482
572
  let e = /src\/components\/(.*)\/index.vue/.exec(t)[1];
483
- bt.indexOf(e) === -1 && N.push({
573
+ Mt.indexOf(e) === -1 && N.push({
484
574
  name: e,
485
575
  component: C[t].default
486
576
  });
487
577
  }
488
- const Mt = {
578
+ const Pt = {
579
+ /**
580
+ * 安装
581
+ * @param app
582
+ */
489
583
  install(t) {
490
584
  N.forEach((e) => {
491
- t.component(`${Et}${e.name}`, e.component);
585
+ t.component(`${$t}${e.name}`, e.component);
492
586
  });
493
587
  }
494
588
  };
495
589
  export {
496
- Mt as default
590
+ Pt as default
497
591
  };
package/dist/index.umd.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(n,w){typeof exports=="object"&&typeof module<"u"?module.exports=w(require("vue")):typeof define=="function"&&define.amd?define(["vue"],w):(n=typeof globalThis<"u"?globalThis:n||self,n.navigation=w(n.Vue))})(this,function(n){"use strict";/*!
2
- * @fox-js/navigation v4.0.1-3 Mon Dec 26 2022 11:59:21 GMT+0800 (中国标准时间)
3
- */const w=n.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(o,s)=>{const f=n.resolveComponent("fox-router-view");return n.openBlock(),n.createBlock(f,{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"])}}}),ct="",P=Object.freeze(Object.defineProperty({__proto__:null,default:w},Symbol.toStringTag,{value:"Module"})),C=n.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(o,s)=>{const f=n.resolveComponent("fox-router-view");return n.openBlock(),n.createBlock(f,{transition:!1,multi:!1,name:e.routerViewName},{default:n.withCtx(({Component:d})=>[n.createVNode(n.Transition,{name:"fox-default-navigator__trans"},{default:n.withCtx(()=>[(n.openBlock(),n.createBlock(n.resolveDynamicComponent(d)))]),_:2},1024)]),_:1},8,["name"])}}}),lt="",I=Object.freeze(Object.defineProperty({__proto__:null,default:C},Symbol.toStringTag,{value:"Module"})),E=10;function S(t,e){return t>e&&t>E?"horizontal":e>t&&e>E?"vertical":""}function b(){const t=n.ref(0),e=n.ref(0),o=n.ref(0),s=n.ref(0),f=n.ref(0),d=n.ref(0),_=n.ref(0),g=n.ref(0),h=n.ref(0),c=n.ref(0),i=n.ref(""),r=()=>i.value==="vertical",v=()=>i.value==="horizontal",a=()=>{_.value=0,g.value=0,h.value=0,c.value=0,i.value="",o.value=0};return{move:u=>{const m=u.touches[0];_.value=m.clientX-t.value,g.value=m.clientY-e.value,f.value=m.clientX,d.value=m.clientY,h.value=Math.abs(_.value),c.value=Math.abs(g.value),s.value=Date.now()-o.value,i.value||(i.value=S(h.value,c.value))},start:u=>{a(),t.value=u.touches[0].clientX,e.value=u.touches[0].clientY,o.value=Date.now()},reset:a,startX:t,startY:e,startTime:o,duration:s,moveX:f,moveY:d,deltaX:_,deltaY:g,offsetX:h,offsetY:c,direction:i,isVertical:r,isHorizontal:v}}function B(t){return t===window}const V=t=>{const e=n.unref(t);if(B(e)){const o=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:o,bottom:s,width:o,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},W=15,z=300,N=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){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function D(t,e=0,o,s=N){o==="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 A(t,e,o=500,s,f=1e3){const d={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},_=t.previousSibling,g=b(),h=(a,p,l,u)=>{let m=p+d.startDistance;if(l==="end"){const x=V(a);let y=x.width/3;m<y?m=0:m=x.width;let T=!1;u&&u>0&&(T=!0,d.transitionEndTrigger=()=>{d.moving=!1,s&&a.classList.remove(s),m>0&&typeof e=="function"&&e()}),D(a,m,"end",u),_&&D(_,0,"",0),!T&&m>0&&typeof e=="function"&&e()}else m<0&&(m=0),D(a,m,"",0)},c=()=>{t.style.transform="",t.style.transition="",d.transitionEndTrigger?(d.transitionEndTrigger(),d.transitionEndTrigger=null,_&&setTimeout(()=>{!_||(_.style.transform="",_.style.transition="")},o)):_&&(_.style.transform="",_.style.transition="")},i=a=>{if(g.start(a),d.moving){const p=t,{transform:l}=window.getComputedStyle(p);d.scrollDistance=+l.slice(7,l.length-1).split(", ")[5]}s&&t.classList.add(s),d.startDistance=d.scrollDistance,d.transitionEndTrigger=null,d.moving=!0},r=a=>{d.moving=!0,g.move(a),g.isHorizontal()&&k(a,!0),h(t,g.deltaX.value,"",0)},v=()=>{const a=g.deltaX.value;if(a==0){s&&t.classList.remove(s);return}const p=g.duration.value;if(p<z&&Math.abs(a)>W){const u=X(a,p);h(t,u,"end",f)}else h(t,a,"end",f)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",i),t.addEventListener("touchmove",r),t.addEventListener("touchend",v),t.addEventListener("touchcancel",v),$.set(t,{state:d,transitionend:c,touchstart:i,touchmove:r,touchend:v,touchcancel:v})}function U(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 R=n.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,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 o(c){return(c.params&&c.params.animationType)??"slide"}const s=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a==="pop"&&i)return;const p=i?"show":"enter",l=`fox-root-navigator__${a}-${p}-from`,u=`fox-root-navigator__${a}-${p}-active`;c.classList.add(l),c.classList.add(u)}},f=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a==="pop"&&i)return;const p=i?"show":"enter",l=`fox-root-navigator__${a}-${p}-from`,u=`fox-root-navigator__${a}-${p}-to`;c.classList.remove(l),c.classList.add(u)}},d=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a!=="pop"||!i){const p=i?"show":"enter",l=`fox-root-navigator__${a}-${p}-active`,u=`fox-root-navigator__${a}-${p}-to`;c.classList.remove(l),c.classList.remove(u)}}e.dragRemove&&!i&&r.opsType===3&&A(c,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},_=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a==="pop"&&i)return;const p=i?"hide":"leave",l=`fox-root-navigator__${a}-${p}-from`,u=`fox-root-navigator__${a}-${p}-active`;c.classList.add(l),c.classList.add(u)}},g=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a==="pop"&&i)return;const p=i?"hide":"leave",l=`fox-root-navigator__${a}-${p}-from`,u=`fox-root-navigator__${a}-${p}-to`;c.classList.remove(l),c.classList.add(u)}},h=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a!=="pop"||!i){const p=i?"hide":"leave",l=`fox-root-navigator__${a}-${p}-active`,u=`fox-root-navigator__${a}-${p}-to`;c.classList.remove(l),c.classList.remove(u)}}e.dragRemove&&!i&&U(c)};return(c,i)=>{const r=n.resolveComponent("fox-router-view");return n.openBlock(),n.createBlock(r,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:f,"after-enter":d,"before-leave":_,leave:g,"after-leave":h,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}}),ut="",Y=Object.freeze(Object.defineProperty({__proto__:null,default:R},Symbol.toStringTag,{value:"Module"})),q={class:"fox-swiper-navigator"},H=n.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,o=n.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,f)=>(n.openBlock(),n.createElementBlock("div",q,[n.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:n.normalizeStyle(n.unref(o))},[n.renderSlot(s.$slots,"default")],4)]))}});let F=0;function G(){return++F}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){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function L(t,e=0,o,s=Q){o==="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;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,o,s,f){this.getStartDistance=e,this.openPage=o,this.isPageOpened=s,this.pageOpened=f}open(){const e=this.el,o=b(),s=(f,d,_,g)=>{let h=d+this.startDistance;const c=this.columnWidth/3;if(_==="end"){if(h==0){this.moving=!1;return}Math.abs(d)>c&&(d>0?h=this.startDistance+this.columnWidth:h=this.startDistance-this.columnWidth);let i=-h;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const r=Math.floor(i/this.columnWidth);this.isPageOpened(r)||this.openPage(r),h=-r*this.columnWidth,g&&g>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(r)}),L(f,h,"end",g),this.scrollDistance=h}else{if(Math.abs(d)>c){let r=0;if(d>0?r=Math.abs(this.startDistance+this.columnWidth):r=Math.abs(this.startDistance-this.columnWidth),r>=0&&r<this.width){const v=Math.floor(r/this.columnWidth);this.isPageOpened(v)||this.openPage(v)}}let i=-h;i<this.min?i=this.min:i>this.max&&(i=this.max),L(f,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=f=>{this.moving||(o.start(f),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=f=>{o.move(f),o.isHorizontal()&&tt(f,!0),s(e,o.deltaX.value,"",0)},this.touchend=()=>{const f=o.deltaX.value;if(f==0)return;const d=o.duration.value;if(d<K&&Math.abs(f)>J){const g=et(f,d);s(e,g,"end",this.swipeDuration)}else s(e,f,"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,o,s){return new nt(t,e,o,s)}const it=n.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const o=t,s=n.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),h=ot(()=>s.scrollDistance,l=>{if(s.openedIndexList.indexOf(l)===-1){s.openedIndexList.push(l);const u=o.routes[l];try{o.openViewPage(u,l)}catch(m){console.error(m)}}},l=>s.openedIndexList.indexOf(l)!==-1,l=>{s.index=l,s.scrollDistance=-s.index*o.width;const u=o.routes[l];e("update:activePath",u.path)});n.onMounted(()=>{const l=v();h.el=l,h.open()}),n.onUnmounted(()=>{h.close()}),n.watchEffect(()=>{const l=o.activePath;s.index=o.routes.findIndex(T=>T.path===l);const u=o.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-u*s.index);const m=u*o.routes.length,x=-u/3,y=u*(o.routes.length-1)+u/3;h.columnWidth=u,h.width=m,h.min=x,h.max=y,h.swipeDuration=o.swipeDuration});const c=`fox-swiper-navigator-${G()}`,i=n.computed(()=>({width:`${o.width}px`,height:`${o.height}px`}));let r=null;function v(){return r||(r=document.querySelector(`.${c}>.fox-swiper-navigator__inner`),r)}const a=n.computed(()=>`${o.width*o.routes.length}px`),p=(l,u)=>({style:{left:`${o.routes.findIndex(x=>{const y=l.path??l.name??"";return x.path==y})*o.width}px`,width:`${o.width}px`}});return(l,u)=>{const m=n.resolveComponent("fox-router-view");return n.openBlock(),n.createBlock(m,{class:n.normalizeClass(c),style:n.normalizeStyle(n.unref(i)),"view-class":"fox-swiper-navigator__item",tag:H,"view-tag-props":p,multi:!0,name:o.routerViewName,transition:o.transition,"scroll-distance":s.scrollDistance,"scroll-time":o.scrollTime,width:n.unref(a)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}}),dt="",st=Object.freeze(Object.defineProperty({__proto__:null,default:it},Symbol.toStringTag,{value:"Module"}));let at="fox-";const rt=[],M=Object.assign({"/src/components/card-navigator/index.vue":P,"/src/components/default-navigator/index.vue":I,"/src/components/root-navigator/index.vue":Y,"/src/components/swiper-navigator/index.vue":st}),O=[];for(const t in M){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];rt.indexOf(e)===-1&&O.push({name:e,component:M[t].default})}return{install(t){O.forEach(e=>{t.component(`${at}${e.name}`,e.component)})}}});
1
+ (function(o,T){typeof exports=="object"&&typeof module<"u"?module.exports=T(require("vue")):typeof define=="function"&&define.amd?define(["vue"],T):(o=typeof globalThis<"u"?globalThis:o||self,o.FoxNavigation=T(o.Vue))})(this,function(o){"use strict";/*!
2
+ * @fox-js/navigation v4.0.1-5 Sat Dec 23 2023 22:28:42 GMT+0800 (中国标准时间)
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)})}}});
package/package.json CHANGED
@@ -1,29 +1,26 @@
1
1
  {
2
2
  "name": "@fox-js/navigation",
3
- "version": "4.0.1-4",
3
+ "type": "module",
4
+ "version": "4.0.1-6",
4
5
  "description": "fox navigation",
5
6
  "author": "jiangcheng",
6
7
  "keywords": [
7
8
  "fox",
8
9
  "navigation"
9
10
  ],
10
- "main": "dist/index.umd.js",
11
- "module": "dist/index.esm.js",
11
+ "main": "./dist/index.umd.js",
12
+ "module": "./dist/index.esm.js",
13
+ "types": "./dist/index.d.ts",
14
+ "style": "./dist/style.css",
12
15
  "exports": {
13
16
  ".": {
14
- "import": {
15
- "node": "./dist/index.cjs.js",
16
- "default": "./dist/index.esm.js"
17
- },
18
- "require": {
19
- "node": "./dist/index.cjs.js",
20
- "default": "./dist/index.umd.js"
21
- }
17
+ "types": "./dist/index.d.ts",
18
+ "require": "./dist/index.umd.js",
19
+ "import": "./dist/index.esm.js"
22
20
  },
23
- "./style.css": "./dist/style.css"
21
+ "./style.css": "./dist/style.css",
22
+ "./*": "./*"
24
23
  },
25
- "style": "dist/style.css",
26
- "typings": "dist/index.d.ts",
27
24
  "license": "",
28
25
  "publishConfig": {
29
26
  "access": "public"