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

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
@@ -50,6 +50,41 @@ const removePage = () => {
50
50
 
51
51
  ```
52
52
 
53
+ #### 设置页面加载动画
54
+
55
+ ##### 滑入方式
56
+
57
+ 通过route的params属性设置animationType:'slide'
58
+
59
+ ```ts
60
+ import { usePageHelper } from '@/utils/custom'
61
+
62
+ pageHelper.append({
63
+ path: target.route,
64
+ params: {
65
+ animationType:'slide'
66
+ }
67
+ })
68
+
69
+ ```
70
+
71
+ ##### 弹出方式
72
+
73
+ 通过route的params属性设置animationType:'pop'
74
+
75
+ ```ts
76
+ import { usePageHelper } from '@/utils/custom'
77
+
78
+ pageHelper.append({
79
+ path: target.route,
80
+ params: {
81
+ animationType:'pop'
82
+ }
83
+ })
84
+
85
+ ```
86
+
87
+
53
88
  #### Props
54
89
 
55
90
  | 字段 | 说明 | 类型 | 默认值 |
@@ -207,13 +242,13 @@ onMounted(() => {
207
242
 
208
243
  <template>
209
244
  <fox-page :content-padding="contentPadding" ref="pageRef">
210
- <fox-footer>
245
+ <fox-footer-bar>
211
246
  <fox-tabbar v-model="index" @change="onTabChange">
212
247
  <template v-for="tab in tabs" :key="tab.title">
213
248
  <fox-tabbar-item :title="tab.title" :icon="tab.icon"></fox-tabbar-item>
214
249
  </template>
215
250
  </fox-tabbar>
216
- </fox-footer>
251
+ </fox-footer-bar>
217
252
  <fox-content ref="contentRef">
218
253
  <fox-swiper-navigator
219
254
  v-model:activePath="activeRoutePath"
package/dist/index.cjs.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";/*!
2
- * @fox-js/navigation v4.0.1-0 Mon Sep 26 2022 15:23:38 GMT+0800 (中国标准时间)
3
- */const s=require("vue"),P=s.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,a)=>{const r=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(r,{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 O=Object.freeze(Object.defineProperty({__proto__:null,default:P},Symbol.toStringTag,{value:"Module"})),D=10;function I(t,e){return t>e&&t>D?"horizontal":e>t&&e>D?"vertical":""}function L(){const t=s.ref(0),e=s.ref(0),n=s.ref(0),a=s.ref(0),r=s.ref(0),p=s.ref(0),m=s.ref(0),g=s.ref(0),f=s.ref(0),l=s.ref(0),o=s.ref(""),i=()=>o.value==="vertical",h=()=>o.value==="horizontal",d=()=>{m.value=0,g.value=0,f.value=0,l.value=0,o.value="",n.value=0};return{move:c=>{const _=c.touches[0];m.value=_.clientX-t.value,g.value=_.clientY-e.value,r.value=_.clientX,p.value=_.clientY,f.value=Math.abs(m.value),l.value=Math.abs(g.value),a.value=Date.now()-n.value,o.value||(o.value=I(f.value,l.value))},start:c=>{d(),t.value=c.touches[0].clientX,e.value=c.touches[0].clientY,n.value=Date.now()},reset:d,startX:t,startY:e,startTime:n,duration:a,moveX:r,moveY:p,deltaX:m,deltaY:g,offsetX:f,offsetY:l,direction:o,isVertical:i,isHorizontal:h}}function C(t){return t===window}const S=t=>{const e=s.unref(t);if(C(e)){const n=e.innerWidth,a=e.innerHeight;return{top:0,left:0,right:n,bottom:a,width:n,height:a}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},W=15,B=300,z=200;function N(t){t.stopPropagation()}function X(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&N(t)}function j(t,e){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function T(t,e=0,n,a=z){n==="end"?t.style.transition=`transform ${a}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 y=new WeakMap;function k(t,e,n,a=1e3){const r={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},p=t.previousSibling,m=L(),g=(h,d,v,u)=>{let c=d+r.startDistance;if(v==="end"){const _=S(h);let x=_.width/3;c<x?c=0:c=_.width,u&&u>0&&(r.transitionEndTrigger=()=>{r.moving=!1,n&&h.classList.remove(n)}),T(h,c,"end",u),p&&T(p,0,"",0),c>0&&typeof e=="function"&&e()}else c<0&&(c=0),T(h,c,"",0)},f=()=>{t.style.transform="",t.style.transition="",p&&(p.style.transform="",p.style.transition=""),r.transitionEndTrigger&&(r.transitionEndTrigger(),r.transitionEndTrigger=null)},l=h=>{if(m.start(h),r.moving){const d=t,{transform:v}=window.getComputedStyle(d);r.scrollDistance=+v.slice(7,v.length-1).split(", ")[5]}n&&t.classList.add(n),r.startDistance=r.scrollDistance,r.transitionEndTrigger=null,r.moving=!0},o=h=>{if(r.moving=!0,m.move(h),m.isVertical()){X(h,!0);return}g(t,m.deltaX.value,"",0)},i=()=>{const h=m.deltaX.value;if(h==0){n&&t.classList.remove(n);return}const d=m.duration.value;if(d<B&&Math.abs(h)>W){const u=j(h,d);g(t,u,"end",a)}else g(t,h,"end",a)};t.addEventListener("transitionend",f),t.addEventListener("touchstart",l),t.addEventListener("touchmove",o),t.addEventListener("touchend",i),t.addEventListener("touchcancel",i),y.set(t,{state:r,transitionend:f,touchstart:l,touchmove:o,touchend:i,touchcancel:i})}function A(t){const e=y.get(t);e&&(y.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=s.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removePage:null,routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;function n(l){return(l.params&&l.params.animationType)??"slide"}const a=(l,o,i,h)=>{if(i.opsType===3||o){const d=n(i);if(d==="pop"&&o)return;const v=o?"show":"enter",u=`fox-root-navigator__${d}-${v}-from`,c=`fox-root-navigator__${d}-${v}-active`;l.classList.add(u),l.classList.add(c)}},r=(l,o,i,h)=>{if(i.opsType===3||o){const d=n(i);if(d==="pop"&&o)return;const v=o?"show":"enter",u=`fox-root-navigator__${d}-${v}-from`,c=`fox-root-navigator__${d}-${v}-to`;l.classList.remove(u),l.classList.add(c)}},p=(l,o,i,h)=>{if(i.opsType===3||o){const d=n(i);if(d!=="pop"||!o){const v=o?"show":"enter",u=`fox-root-navigator__${d}-${v}-active`,c=`fox-root-navigator__${d}-${v}-to`;l.classList.remove(u),l.classList.remove(c)}}e.dragRemove&&!o&&i.opsType===3&&k(l,e.removePage,"fox-root-navigator__item-moving",1e3)},m=(l,o,i,h)=>{if(i.opsType===3||o){const d=n(i);if(d==="pop"&&o)return;const v=o?"hide":"leave",u=`fox-root-navigator__${d}-${v}-from`,c=`fox-root-navigator__${d}-${v}-active`;l.classList.add(u),l.classList.add(c)}},g=(l,o,i,h)=>{if(i.opsType===3||o){const d=n(i);if(d==="pop"&&o)return;const v=o?"hide":"leave",u=`fox-root-navigator__${d}-${v}-from`,c=`fox-root-navigator__${d}-${v}-to`;l.classList.remove(u),l.classList.add(c)}},f=(l,o,i,h)=>{if(i.opsType===3||o){const d=n(i);if(d!=="pop"||!o){const v=o?"hide":"leave",u=`fox-root-navigator__${d}-${v}-active`,c=`fox-root-navigator__${d}-${v}-to`;l.classList.remove(u),l.classList.remove(c)}}e.dragRemove&&!o&&A(l)};return(l,o)=>{const i=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(i,{class:"fox-root-navigator","view-class":"fox-root-navigator__item","before-enter":a,enter:r,"after-enter":p,"before-leave":m,leave:g,"after-leave":f,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["name","view-tag","transition"])}}});const V=Object.freeze(Object.defineProperty({__proto__:null,default:U},Symbol.toStringTag,{value:"Module"})),R={class:"fox-swiper-navigator"},Y=s.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=s.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(a,r)=>(s.openBlock(),s.createElementBlock("div",R,[s.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:s.normalizeStyle(s.unref(n))},[s.renderSlot(a.$slots,"default")],4)]))}});let q=0;function F(){return++q}const H=15,G=300,J=200;function K(t){t.stopPropagation()}function Q(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&K(t)}function Z(t,e){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function E(t,e=0,n,a=J){n==="end"?t.style.transition=`transform ${a}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 tt{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,a,r){this.getStartDistance=e,this.openPage=n,this.isPageOpened=a,this.pageOpened=r}open(){const e=this.el,n=L(),a=(r,p,m,g)=>{let f=p+this.startDistance;const l=this.columnWidth/3;if(m==="end"){if(f==0){this.moving=!1;return}Math.abs(p)>l&&(p>0?f=this.startDistance+this.columnWidth:f=this.startDistance-this.columnWidth);let o=-f;o<0?o=0:o>this.width-this.columnWidth&&(o=this.width-this.columnWidth);const i=Math.floor(o/this.columnWidth);this.isPageOpened(i)||this.openPage(i),f=-i*this.columnWidth,g&&g>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(i)}),E(r,f,"end",g),this.scrollDistance=f}else{if(Math.abs(p)>l){let i=0;if(p>0?i=Math.abs(this.startDistance+this.columnWidth):i=Math.abs(this.startDistance-this.columnWidth),i>=0&&i<this.width){const h=Math.floor(i/this.columnWidth);this.isPageOpened(h)||this.openPage(h)}}let o=-f;o<this.min?o=this.min:o>this.max&&(o=this.max),E(r,-o,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=r=>{this.moving||(n.start(r),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=r=>{if(n.move(r),n.isVertical()){Q(r,!0);return}a(e,n.deltaX.value,"",0)},this.touchend=()=>{const r=n.deltaX.value;if(r==0)return;const p=n.duration.value;if(p<G&&Math.abs(r)>H){const g=Z(r,p);a(e,g,"end",this.swipeDuration)}else a(e,r,"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 et(t,e,n,a){return new tt(t,e,n,a)}const nt=s.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openPage: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,a=s.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),f=et(()=>a.scrollDistance,u=>{if(a.openedIndexList.indexOf(u)===-1){a.openedIndexList.push(u);const c=n.routes[u];try{n.openPage(c,u)}catch(_){console.error(_)}}},u=>a.openedIndexList.indexOf(u)!==-1,u=>{a.index=u,a.scrollDistance=-a.index*n.width;const c=n.routes[u];e("update:activePath",c.path)});s.onMounted(()=>{const u=h();f.el=u,f.open()}),s.onUnmounted(()=>{f.close()}),s.watchEffect(()=>{const u=n.activePath;a.index=n.routes.findIndex(M=>M.path===u);const c=n.width;a.index!==-1&&(a.openedIndexList.push(a.index),a.scrollDistance=-c*a.index);const _=c*n.routes.length,x=-c/3,w=c*(n.routes.length-1)+c/3;f.columnWidth=c,f.width=_,f.min=x,f.max=w,f.swipeDuration=n.swipeDuration});const l=`fox-swiper-navigator-${F()}`,o=s.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let i=null;function h(){return i||(i=document.querySelector(`.${l}>.fox-swiper-navigator__inner`),i)}const d=s.computed(()=>`${n.width*n.routes.length}px`),v=(u,c)=>({style:{left:`${n.routes.findIndex(x=>{const w=u.path??u.name??"";return x.path==w})*n.width}px`,width:`${n.width}px`}});return(u,c)=>{const _=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(_,{class:s.normalizeClass(l),style:s.normalizeStyle(s.unref(o)),"view-class":"fox-swiper-navigator__item",tag:Y,"view-tag-props":v,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":a.scrollDistance,"scroll-time":n.scrollTime,width:s.unref(d)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}});const ot=Object.freeze(Object.defineProperty({__proto__:null,default:nt},Symbol.toStringTag,{value:"Module"}));let it="fox-";const st=[],$=Object.assign({"/src/components/card-navigator/index.vue":O,"/src/components/root-navigator/index.vue":V,"/src/components/swiper-navigator/index.vue":ot}),b=[];for(const t in $){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];st.indexOf(e)===-1&&b.push({name:e,component:$[t].default})}const at={install(t){b.forEach(e=>{t.component(`${it}${e.name}`,e.component)})}};module.exports=at;
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;
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
- import { defineComponent as T, resolveComponent as b, openBlock as y, createBlock as M, ref as _, unref as w, computed as $, createElementBlock as z, createElementVNode as B, normalizeStyle as S, renderSlot as X, reactive as j, onMounted as A, onUnmounted as U, watchEffect as V, normalizeClass as R } from "vue";
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";
2
2
  /*!
3
- * @fox-js/navigation v4.0.1-0 Mon Sep 26 2022 15:23:38 GMT+0800 (中国标准时间)
3
+ * @fox-js/navigation v4.0.1-3 Mon Dec 26 2022 11:59:21 GMT+0800 (中国标准时间)
4
4
  */
5
- const Y = /* @__PURE__ */ T({
5
+ const F = /* @__PURE__ */ D({
6
6
  __name: "index",
7
7
  props: {
8
8
  routerViewName: null,
@@ -10,9 +10,9 @@ const Y = /* @__PURE__ */ T({
10
10
  },
11
11
  setup(t) {
12
12
  const e = t;
13
- return (n, s) => {
14
- const a = b("fox-router-view");
15
- return y(), M(a, {
13
+ return (n, i) => {
14
+ const d = b("fox-router-view");
15
+ return w(), T(d, {
16
16
  class: "fox-card-navigator",
17
17
  "view-class": "fox-card-navigator__item",
18
18
  "view-active-class": "fox-card-navigator__item-active",
@@ -25,55 +25,86 @@ const Y = /* @__PURE__ */ T({
25
25
  };
26
26
  }
27
27
  });
28
- const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
28
+ const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
29
+ __proto__: null,
30
+ default: F
31
+ }, Symbol.toStringTag, { value: "Module" })), J = /* @__PURE__ */ D({
32
+ __name: "index",
33
+ props: {
34
+ routerViewName: null,
35
+ transition: { type: [Object, Boolean], default: !0 }
36
+ },
37
+ setup(t) {
38
+ const e = t;
39
+ return (n, i) => {
40
+ const d = b("fox-router-view");
41
+ return w(), T(d, {
42
+ transition: !1,
43
+ multi: !1,
44
+ name: e.routerViewName
45
+ }, {
46
+ default: P(({ Component: u }) => [
47
+ z(j, { name: "fox-default-navigator__trans" }, {
48
+ default: P(() => [
49
+ (w(), T(B(u)))
50
+ ]),
51
+ _: 2
52
+ }, 1024)
53
+ ]),
54
+ _: 1
55
+ }, 8, ["name"]);
56
+ };
57
+ }
58
+ });
59
+ const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
29
60
  __proto__: null,
30
- default: Y
31
- }, Symbol.toStringTag, { value: "Module" })), P = 10;
32
- function q(t, e) {
33
- return t > e && t > P ? "horizontal" : e > t && e > P ? "vertical" : "";
61
+ default: J
62
+ }, Symbol.toStringTag, { value: "Module" })), I = 10;
63
+ function Q(t, e) {
64
+ return t > e && t > I ? "horizontal" : e > t && e > I ? "vertical" : "";
34
65
  }
35
66
  function W() {
36
- const t = _(0), e = _(0), n = _(0), s = _(0), a = _(0), v = _(0), p = _(0), m = _(0), d = _(0), c = _(0), o = _(""), i = () => o.value === "vertical", h = () => o.value === "horizontal", u = () => {
37
- p.value = 0, m.value = 0, d.value = 0, c.value = 0, o.value = "", n.value = 0;
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;
38
69
  };
39
70
  return {
40
- move: (r) => {
41
- const g = r.touches[0];
42
- p.value = g.clientX - t.value, m.value = g.clientY - e.value, a.value = g.clientX, v.value = g.clientY, d.value = Math.abs(p.value), c.value = Math.abs(m.value), s.value = Date.now() - n.value, o.value || (o.value = q(d.value, c.value));
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));
43
74
  },
44
- start: (r) => {
45
- u(), t.value = r.touches[0].clientX, e.value = r.touches[0].clientY, n.value = Date.now();
75
+ start: (l) => {
76
+ s(), t.value = l.touches[0].clientX, e.value = l.touches[0].clientY, n.value = Date.now();
46
77
  },
47
- reset: u,
78
+ reset: s,
48
79
  startX: t,
49
80
  startY: e,
50
81
  startTime: n,
51
- duration: s,
52
- moveX: a,
53
- moveY: v,
54
- deltaX: p,
55
- deltaY: m,
56
- offsetX: d,
57
- offsetY: c,
82
+ duration: i,
83
+ moveX: d,
84
+ moveY: u,
85
+ deltaX: m,
86
+ deltaY: p,
87
+ offsetX: f,
88
+ offsetY: r,
58
89
  direction: o,
59
- isVertical: i,
60
- isHorizontal: h
90
+ isVertical: a,
91
+ isHorizontal: _
61
92
  };
62
93
  }
63
- function F(t) {
94
+ function Z(t) {
64
95
  return t === window;
65
96
  }
66
- const H = (t) => {
67
- const e = w(t);
68
- if (F(e)) {
69
- const n = e.innerWidth, s = e.innerHeight;
97
+ const tt = (t) => {
98
+ const e = E(t);
99
+ if (Z(e)) {
100
+ const n = e.innerWidth, i = e.innerHeight;
70
101
  return {
71
102
  top: 0,
72
103
  left: 0,
73
104
  right: n,
74
- bottom: s,
105
+ bottom: i,
75
106
  width: n,
76
- height: s
107
+ height: i
77
108
  };
78
109
  }
79
110
  return e && e.getBoundingClientRect ? e.getBoundingClientRect() : {
@@ -84,166 +115,168 @@ const H = (t) => {
84
115
  width: 0,
85
116
  height: 0
86
117
  };
87
- }, G = 15, J = 300, K = 200;
88
- function Q(t) {
118
+ }, et = 15, nt = 300, ot = 200;
119
+ function it(t) {
89
120
  t.stopPropagation();
90
121
  }
91
- function Z(t, e) {
92
- (typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && Q(t);
122
+ function st(t, e) {
123
+ (typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && it(t);
93
124
  }
94
- function tt(t, e) {
125
+ function at(t, e) {
95
126
  return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t;
96
127
  }
97
- function E(t, e = 0, n, s = K) {
98
- 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)`;
128
+ function L(t, e = 0, n, i = ot) {
129
+ 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)`;
99
130
  }
100
- const L = /* @__PURE__ */ new WeakMap();
101
- function et(t, e, n, s = 1e3) {
102
- const a = {
131
+ const O = /* @__PURE__ */ new WeakMap();
132
+ function rt(t, e, n = 500, i, d = 1e3) {
133
+ const u = {
103
134
  active: !0,
104
135
  startDistance: 0,
105
136
  scrollDistance: 0,
106
137
  scrollTime: 0,
107
138
  moving: !1,
108
139
  transitionEndTrigger: null
109
- }, v = t.previousSibling, p = W(), m = (h, u, f, l) => {
110
- let r = u + a.startDistance;
111
- if (f === "end") {
112
- const g = H(h);
113
- let x = g.width / 3;
114
- r < x ? r = 0 : r = g.width, l && l > 0 && (a.transitionEndTrigger = () => {
115
- a.moving = !1, n && h.classList.remove(n);
116
- }), E(h, r, "end", l), v && E(v, 0, "", 0), r > 0 && typeof e == "function" && e();
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();
117
150
  } else
118
- r < 0 && (r = 0), E(h, r, "", 0);
119
- }, d = () => {
120
- t.style.transform = "", t.style.transition = "", v && (v.style.transform = "", v.style.transition = ""), a.transitionEndTrigger && (a.transitionEndTrigger(), a.transitionEndTrigger = null);
121
- }, c = (h) => {
122
- if (p.start(h), a.moving) {
123
- const u = t, { transform: f } = window.getComputedStyle(u);
124
- a.scrollDistance = +f.slice(7, f.length - 1).split(", ")[5];
125
- }
126
- n && t.classList.add(n), a.startDistance = a.scrollDistance, a.transitionEndTrigger = null, a.moving = !0;
127
- }, o = (h) => {
128
- if (a.moving = !0, p.move(h), p.isVertical()) {
129
- Z(h, !0);
130
- return;
151
+ v < 0 && (v = 0), L(s, v, "", 0);
152
+ }, 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];
131
160
  }
132
- m(t, p.deltaX.value, "", 0);
133
- }, i = () => {
134
- const h = p.deltaX.value;
135
- if (h == 0) {
136
- n && t.classList.remove(n);
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;
166
+ if (s == 0) {
167
+ i && t.classList.remove(i);
137
168
  return;
138
169
  }
139
- const u = p.duration.value;
140
- if (u < J && Math.abs(h) > G) {
141
- const l = tt(h, u);
142
- m(t, l, "end", s);
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);
143
174
  } else
144
- m(t, h, "end", s);
175
+ f(t, s, "end", d);
145
176
  };
146
- t.addEventListener("transitionend", d), t.addEventListener("touchstart", c), t.addEventListener("touchmove", o), t.addEventListener("touchend", i), t.addEventListener("touchcancel", i), L.set(t, {
147
- state: a,
148
- transitionend: d,
149
- touchstart: c,
150
- touchmove: o,
151
- touchend: i,
152
- touchcancel: i
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,
179
+ transitionend: r,
180
+ touchstart: o,
181
+ touchmove: a,
182
+ touchend: _,
183
+ touchcancel: _
153
184
  });
154
185
  }
155
- function nt(t) {
156
- const e = L.get(t);
157
- e && (L.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));
186
+ function ct(t) {
187
+ const e = O.get(t);
188
+ 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));
158
189
  }
159
- const ot = /* @__PURE__ */ T({
190
+ const lt = /* @__PURE__ */ D({
160
191
  __name: "index",
161
192
  props: {
162
193
  dragRemove: { type: Boolean, default: !0 },
163
- removePage: null,
194
+ removeViewPage: null,
195
+ removeViewPageDuration: { default: 500 },
164
196
  routerViewName: null,
165
197
  viewTag: { default: "div" },
166
- transition: { type: [Object, Boolean], default: !0 }
198
+ transition: { type: [Object, Boolean], default: !0 },
199
+ viewClass: { default: "fox-root-navigator__item" }
167
200
  },
168
201
  setup(t) {
169
202
  const e = t;
170
- function n(c) {
171
- return (c.params && c.params.animationType) ?? "slide";
203
+ function n(r) {
204
+ return (r.params && r.params.animationType) ?? "slide";
172
205
  }
173
- const s = (c, o, i, h) => {
174
- if (i.opsType === 3 || o) {
175
- const u = n(i);
176
- if (u === "pop" && o)
206
+ const i = (r, o, a, _) => {
207
+ if (a.opsType === 3 || o) {
208
+ const s = n(a);
209
+ if (s === "pop" && o)
177
210
  return;
178
- const f = o ? "show" : "enter", l = `fox-root-navigator__${u}-${f}-from`, r = `fox-root-navigator__${u}-${f}-active`;
179
- c.classList.add(l), c.classList.add(r);
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);
180
213
  }
181
- }, a = (c, o, i, h) => {
182
- if (i.opsType === 3 || o) {
183
- const u = n(i);
184
- if (u === "pop" && o)
214
+ }, d = (r, o, a, _) => {
215
+ if (a.opsType === 3 || o) {
216
+ const s = n(a);
217
+ if (s === "pop" && o)
185
218
  return;
186
- const f = o ? "show" : "enter", l = `fox-root-navigator__${u}-${f}-from`, r = `fox-root-navigator__${u}-${f}-to`;
187
- c.classList.remove(l), c.classList.add(r);
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);
188
221
  }
189
- }, v = (c, o, i, h) => {
190
- if (i.opsType === 3 || o) {
191
- const u = n(i);
192
- if (u !== "pop" || !o) {
193
- const f = o ? "show" : "enter", l = `fox-root-navigator__${u}-${f}-active`, r = `fox-root-navigator__${u}-${f}-to`;
194
- c.classList.remove(l), c.classList.remove(r);
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);
195
228
  }
196
229
  }
197
- e.dragRemove && !o && i.opsType === 3 && et(c, e.removePage, "fox-root-navigator__item-moving", 1e3);
198
- }, p = (c, o, i, h) => {
199
- if (i.opsType === 3 || o) {
200
- const u = n(i);
201
- if (u === "pop" && o)
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)
202
235
  return;
203
- const f = o ? "hide" : "leave", l = `fox-root-navigator__${u}-${f}-from`, r = `fox-root-navigator__${u}-${f}-active`;
204
- c.classList.add(l), c.classList.add(r);
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);
205
238
  }
206
- }, m = (c, o, i, h) => {
207
- if (i.opsType === 3 || o) {
208
- const u = n(i);
209
- if (u === "pop" && o)
239
+ }, p = (r, o, a, _) => {
240
+ if (a.opsType === 3 || o) {
241
+ const s = n(a);
242
+ if (s === "pop" && o)
210
243
  return;
211
- const f = o ? "hide" : "leave", l = `fox-root-navigator__${u}-${f}-from`, r = `fox-root-navigator__${u}-${f}-to`;
212
- c.classList.remove(l), c.classList.add(r);
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);
213
246
  }
214
- }, d = (c, o, i, h) => {
215
- if (i.opsType === 3 || o) {
216
- const u = n(i);
217
- if (u !== "pop" || !o) {
218
- const f = o ? "hide" : "leave", l = `fox-root-navigator__${u}-${f}-active`, r = `fox-root-navigator__${u}-${f}-to`;
219
- c.classList.remove(l), c.classList.remove(r);
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);
220
253
  }
221
254
  }
222
- e.dragRemove && !o && nt(c);
255
+ e.dragRemove && !o && ct(r);
223
256
  };
224
- return (c, o) => {
225
- const i = b("fox-router-view");
226
- return y(), M(i, {
257
+ return (r, o) => {
258
+ const a = b("fox-router-view");
259
+ return w(), T(a, {
227
260
  class: "fox-root-navigator",
228
- "view-class": "fox-root-navigator__item",
229
- "before-enter": s,
230
- enter: a,
231
- "after-enter": v,
232
- "before-leave": p,
233
- leave: m,
234
- "after-leave": d,
261
+ "view-class": t.viewClass,
262
+ "before-enter": i,
263
+ enter: d,
264
+ "after-enter": u,
265
+ "before-leave": m,
266
+ leave: p,
267
+ "after-leave": f,
235
268
  multi: !0,
236
269
  name: e.routerViewName,
237
270
  "view-tag": e.viewTag,
238
271
  transition: e.transition
239
- }, null, 8, ["name", "view-tag", "transition"]);
272
+ }, null, 8, ["view-class", "name", "view-tag", "transition"]);
240
273
  };
241
274
  }
242
275
  });
243
- const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
276
+ const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
244
277
  __proto__: null,
245
- default: ot
246
- }, Symbol.toStringTag, { value: "Module" })), st = { class: "fox-swiper-navigator" }, at = /* @__PURE__ */ T({
278
+ default: lt
279
+ }, Symbol.toStringTag, { value: "Module" })), dt = { class: "fox-swiper-navigator" }, ft = /* @__PURE__ */ D({
247
280
  __name: "swiper",
248
281
  props: {
249
282
  width: null,
@@ -251,38 +284,38 @@ const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
251
284
  scrollTime: null
252
285
  },
253
286
  setup(t) {
254
- const e = t, n = $(() => ({
287
+ const e = t, n = M(() => ({
255
288
  transform: `translate3d(${e.scrollDistance}px, 0, 0)`,
256
289
  width: `${e.width}`
257
290
  }));
258
- return (s, a) => (y(), z("div", st, [
259
- B("div", {
291
+ return (i, d) => (w(), X("div", dt, [
292
+ A("div", {
260
293
  class: "fox-swiper-navigator__inner",
261
- style: S(w(n))
294
+ style: V(E(n))
262
295
  }, [
263
- X(s.$slots, "default")
296
+ U(i.$slots, "default")
264
297
  ], 4)
265
298
  ]));
266
299
  }
267
300
  });
268
- let rt = 0;
269
- function ct() {
270
- return ++rt;
301
+ let ht = 0;
302
+ function vt() {
303
+ return ++ht;
271
304
  }
272
- const lt = 15, ut = 300, dt = 200;
273
- function ht(t) {
305
+ const mt = 15, pt = 300, _t = 200;
306
+ function gt(t) {
274
307
  t.stopPropagation();
275
308
  }
276
- function ft(t, e) {
277
- (typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && ht(t);
309
+ function xt(t, e) {
310
+ (typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && gt(t);
278
311
  }
279
- function vt(t, e) {
312
+ function wt(t, e) {
280
313
  return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t;
281
314
  }
282
- function O(t, e = 0, n, s = dt) {
283
- 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)`;
315
+ function S(t, e = 0, n, i = _t) {
316
+ 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)`;
284
317
  }
285
- class pt {
318
+ class yt {
286
319
  width = 0;
287
320
  columnWidth = 0;
288
321
  max = 0;
@@ -302,57 +335,53 @@ class pt {
302
335
  touchmove = null;
303
336
  touchend = null;
304
337
  touchcancel = null;
305
- constructor(e, n, s, a) {
306
- this.getStartDistance = e, this.openPage = n, this.isPageOpened = s, this.pageOpened = a;
338
+ constructor(e, n, i, d) {
339
+ this.getStartDistance = e, this.openPage = n, this.isPageOpened = i, this.pageOpened = d;
307
340
  }
308
341
  open() {
309
- const e = this.el, n = W(), s = (a, v, p, m) => {
310
- let d = v + this.startDistance;
311
- const c = this.columnWidth / 3;
312
- if (p === "end") {
313
- if (d == 0) {
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) {
314
347
  this.moving = !1;
315
348
  return;
316
349
  }
317
- Math.abs(v) > c && (v > 0 ? d = this.startDistance + this.columnWidth : d = this.startDistance - this.columnWidth);
318
- let o = -d;
350
+ Math.abs(u) > r && (u > 0 ? f = this.startDistance + this.columnWidth : f = this.startDistance - this.columnWidth);
351
+ let o = -f;
319
352
  o < 0 ? o = 0 : o > this.width - this.columnWidth && (o = this.width - this.columnWidth);
320
- const i = Math.floor(o / this.columnWidth);
321
- this.isPageOpened(i) || this.openPage(i), d = -i * this.columnWidth, m && m > 0 && (this.transitionEndTrigger = () => {
322
- this.moving = !1, this.pageOpened(i);
323
- }), O(a, d, "end", m), this.scrollDistance = d;
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;
324
357
  } else {
325
- if (Math.abs(v) > c) {
326
- let i = 0;
327
- if (v > 0 ? i = Math.abs(this.startDistance + this.columnWidth) : i = Math.abs(this.startDistance - this.columnWidth), i >= 0 && i < this.width) {
328
- const h = Math.floor(i / this.columnWidth);
329
- this.isPageOpened(h) || this.openPage(h);
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(_);
330
363
  }
331
364
  }
332
- let o = -d;
333
- o < this.min ? o = this.min : o > this.max && (o = this.max), O(a, -o, "", 0);
365
+ let o = -f;
366
+ o < this.min ? o = this.min : o > this.max && (o = this.max), S(d, -o, "", 0);
334
367
  }
335
368
  };
336
369
  this.transitionend = () => {
337
370
  e.style.transition = "", this.transitionEndTrigger && (this.transitionEndTrigger(), this.transitionEndTrigger = null);
338
- }, this.touchstart = (a) => {
339
- this.moving || (n.start(a), this.startDistance = this.getStartDistance(), this.transitionEndTrigger = null, this.moving = !0);
340
- }, this.touchmove = (a) => {
341
- if (n.move(a), n.isVertical()) {
342
- ft(a, !0);
343
- return;
344
- }
345
- s(e, n.deltaX.value, "", 0);
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);
346
375
  }, this.touchend = () => {
347
- const a = n.deltaX.value;
348
- if (a == 0)
376
+ const d = n.deltaX.value;
377
+ if (d == 0)
349
378
  return;
350
- const v = n.duration.value;
351
- if (v < ut && Math.abs(a) > lt) {
352
- const m = vt(a, v);
353
- s(e, m, "end", this.swipeDuration);
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);
354
383
  } else
355
- s(e, a, "end", this.swipeDuration);
384
+ i(e, d, "end", this.swipeDuration);
356
385
  }, 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);
357
386
  }
358
387
  close() {
@@ -360,10 +389,10 @@ class pt {
360
389
  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;
361
390
  }
362
391
  }
363
- function mt(t, e, n, s) {
364
- return new pt(t, e, n, s);
392
+ function Tt(t, e, n, i) {
393
+ return new yt(t, e, n, i);
365
394
  }
366
- const gt = /* @__PURE__ */ T({
395
+ const Dt = /* @__PURE__ */ D({
367
396
  __name: "index",
368
397
  props: {
369
398
  activePath: null,
@@ -371,7 +400,7 @@ const gt = /* @__PURE__ */ T({
371
400
  height: null,
372
401
  width: null,
373
402
  drag: { type: Boolean, default: !0 },
374
- openPage: null,
403
+ openViewPage: null,
375
404
  routerViewName: null,
376
405
  transition: { type: [Object, Boolean], default: !0 },
377
406
  swipeDuration: { default: 360 },
@@ -379,90 +408,90 @@ const gt = /* @__PURE__ */ T({
379
408
  },
380
409
  emits: ["update:activePath"],
381
410
  setup(t, { emit: e }) {
382
- const n = t, s = j({
411
+ const n = t, i = R({
383
412
  scrollDistance: 0,
384
413
  index: -1,
385
414
  openedIndexList: []
386
- }), d = mt(() => s.scrollDistance, (l) => {
387
- if (s.openedIndexList.indexOf(l) === -1) {
388
- s.openedIndexList.push(l);
389
- const r = n.routes[l];
415
+ }), f = Tt(() => i.scrollDistance, (c) => {
416
+ if (i.openedIndexList.indexOf(c) === -1) {
417
+ i.openedIndexList.push(c);
418
+ const l = n.routes[c];
390
419
  try {
391
- n.openPage(r, l);
392
- } catch (g) {
393
- console.error(g);
420
+ n.openViewPage(l, c);
421
+ } catch (v) {
422
+ console.error(v);
394
423
  }
395
424
  }
396
- }, (l) => s.openedIndexList.indexOf(l) !== -1, (l) => {
397
- s.index = l, s.scrollDistance = -s.index * n.width;
398
- const r = n.routes[l];
399
- e("update:activePath", r.path);
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);
400
429
  });
401
- A(() => {
402
- const l = h();
403
- d.el = l, d.open();
404
- }), U(() => {
405
- d.close();
406
- }), V(() => {
407
- const l = n.activePath;
408
- s.index = n.routes.findIndex((N) => N.path === l);
409
- const r = n.width;
410
- s.index !== -1 && (s.openedIndexList.push(s.index), s.scrollDistance = -r * s.index);
411
- const g = r * n.routes.length, x = -r / 3, D = r * (n.routes.length - 1) + r / 3;
412
- d.columnWidth = r, d.width = g, d.min = x, d.max = D, d.swipeDuration = n.swipeDuration;
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;
413
442
  });
414
- const c = `fox-swiper-navigator-${ct()}`, o = $(() => ({ width: `${n.width}px`, height: `${n.height}px` }));
415
- let i = null;
416
- function h() {
417
- return i || (i = document.querySelector(`.${c}>.fox-swiper-navigator__inner`), i);
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);
418
447
  }
419
- const u = $(() => `${n.width * n.routes.length}px`), f = (l, r) => ({
448
+ const s = M(() => `${n.width * n.routes.length}px`), h = (c, l) => ({
420
449
  style: {
421
450
  left: `${n.routes.findIndex((x) => {
422
- const D = l.path ?? l.name ?? "";
423
- return x.path == D;
451
+ const y = c.path ?? c.name ?? "";
452
+ return x.path == y;
424
453
  }) * n.width}px`,
425
454
  width: `${n.width}px`
426
455
  }
427
456
  });
428
- return (l, r) => {
429
- const g = b("fox-router-view");
430
- return y(), M(g, {
431
- class: R(c),
432
- style: S(w(o)),
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)),
433
462
  "view-class": "fox-swiper-navigator__item",
434
- tag: at,
435
- "view-tag-props": f,
463
+ tag: ft,
464
+ "view-tag-props": h,
436
465
  multi: !0,
437
466
  name: n.routerViewName,
438
467
  transition: n.transition,
439
- "scroll-distance": s.scrollDistance,
468
+ "scroll-distance": i.scrollDistance,
440
469
  "scroll-time": n.scrollTime,
441
- width: w(u)
470
+ width: E(s)
442
471
  }, null, 8, ["style", "name", "transition", "scroll-distance", "scroll-time", "width"]);
443
472
  };
444
473
  }
445
474
  });
446
- const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
475
+ const $t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
447
476
  __proto__: null,
448
- default: gt
477
+ default: Dt
449
478
  }, Symbol.toStringTag, { value: "Module" }));
450
- let xt = "fox-";
451
- const wt = [], I = /* @__PURE__ */ Object.assign({ "/src/components/card-navigator/index.vue": k, "/src/components/root-navigator/index.vue": it, "/src/components/swiper-navigator/index.vue": _t }), C = [];
452
- for (const t in I) {
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 = [];
481
+ for (const t in C) {
453
482
  let e = /src\/components\/(.*)\/index.vue/.exec(t)[1];
454
- wt.indexOf(e) === -1 && C.push({
483
+ bt.indexOf(e) === -1 && N.push({
455
484
  name: e,
456
- component: I[t].default
485
+ component: C[t].default
457
486
  });
458
487
  }
459
- const yt = {
488
+ const Mt = {
460
489
  install(t) {
461
- C.forEach((e) => {
462
- t.component(`${xt}${e.name}`, e.component);
490
+ N.forEach((e) => {
491
+ t.component(`${Et}${e.name}`, e.component);
463
492
  });
464
493
  }
465
494
  };
466
495
  export {
467
- yt as default
496
+ Mt as default
468
497
  };
package/dist/index.umd.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(i,x){typeof exports=="object"&&typeof module<"u"?module.exports=x(require("vue")):typeof define=="function"&&define.amd?define(["vue"],x):(i=typeof globalThis<"u"?globalThis:i||self,i.navigation=x(i.Vue))})(this,function(i){"use strict";/*!
2
- * @fox-js/navigation v4.0.1-0 Mon Sep 26 2022 15:23:38 GMT+0800 (中国标准时间)
3
- */const x=i.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,a)=>{const r=i.resolveComponent("fox-router-view");return i.openBlock(),i.createBlock(r,{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"])}}}),at="",P=Object.freeze(Object.defineProperty({__proto__:null,default:x},Symbol.toStringTag,{value:"Module"})),E=10;function O(t,e){return t>e&&t>E?"horizontal":e>t&&e>E?"vertical":""}function $(){const t=i.ref(0),e=i.ref(0),n=i.ref(0),a=i.ref(0),r=i.ref(0),m=i.ref(0),g=i.ref(0),v=i.ref(0),f=i.ref(0),l=i.ref(0),o=i.ref(""),s=()=>o.value==="vertical",h=()=>o.value==="horizontal",d=()=>{g.value=0,v.value=0,f.value=0,l.value=0,o.value="",n.value=0};return{move:c=>{const _=c.touches[0];g.value=_.clientX-t.value,v.value=_.clientY-e.value,r.value=_.clientX,m.value=_.clientY,f.value=Math.abs(g.value),l.value=Math.abs(v.value),a.value=Date.now()-n.value,o.value||(o.value=O(f.value,l.value))},start:c=>{d(),t.value=c.touches[0].clientX,e.value=c.touches[0].clientY,n.value=Date.now()},reset:d,startX:t,startY:e,startTime:n,duration:a,moveX:r,moveY:m,deltaX:g,deltaY:v,offsetX:f,offsetY:l,direction:o,isVertical:s,isHorizontal:h}}function I(t){return t===window}const C=t=>{const e=i.unref(t);if(I(e)){const n=e.innerWidth,a=e.innerHeight;return{top:0,left:0,right:n,bottom:a,width:n,height:a}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},S=15,W=300,B=200;function z(t){t.stopPropagation()}function N(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&z(t)}function j(t,e){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function T(t,e=0,n,a=B){n==="end"?t.style.transition=`transform ${a}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 y=new WeakMap;function V(t,e,n,a=1e3){const r={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},m=t.previousSibling,g=$(),v=(h,d,p,u)=>{let c=d+r.startDistance;if(p==="end"){const _=C(h);let w=_.width/3;c<w?c=0:c=_.width,u&&u>0&&(r.transitionEndTrigger=()=>{r.moving=!1,n&&h.classList.remove(n)}),T(h,c,"end",u),m&&T(m,0,"",0),c>0&&typeof e=="function"&&e()}else c<0&&(c=0),T(h,c,"",0)},f=()=>{t.style.transform="",t.style.transition="",m&&(m.style.transform="",m.style.transition=""),r.transitionEndTrigger&&(r.transitionEndTrigger(),r.transitionEndTrigger=null)},l=h=>{if(g.start(h),r.moving){const d=t,{transform:p}=window.getComputedStyle(d);r.scrollDistance=+p.slice(7,p.length-1).split(", ")[5]}n&&t.classList.add(n),r.startDistance=r.scrollDistance,r.transitionEndTrigger=null,r.moving=!0},o=h=>{if(r.moving=!0,g.move(h),g.isVertical()){N(h,!0);return}v(t,g.deltaX.value,"",0)},s=()=>{const h=g.deltaX.value;if(h==0){n&&t.classList.remove(n);return}const d=g.duration.value;if(d<W&&Math.abs(h)>S){const u=j(h,d);v(t,u,"end",a)}else v(t,h,"end",a)};t.addEventListener("transitionend",f),t.addEventListener("touchstart",l),t.addEventListener("touchmove",o),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),y.set(t,{state:r,transitionend:f,touchstart:l,touchmove:o,touchend:s,touchcancel:s})}function X(t){const e=y.get(t);e&&(y.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 k=i.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removePage:null,routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;function n(l){return(l.params&&l.params.animationType)??"slide"}const a=(l,o,s,h)=>{if(s.opsType===3||o){const d=n(s);if(d==="pop"&&o)return;const p=o?"show":"enter",u=`fox-root-navigator__${d}-${p}-from`,c=`fox-root-navigator__${d}-${p}-active`;l.classList.add(u),l.classList.add(c)}},r=(l,o,s,h)=>{if(s.opsType===3||o){const d=n(s);if(d==="pop"&&o)return;const p=o?"show":"enter",u=`fox-root-navigator__${d}-${p}-from`,c=`fox-root-navigator__${d}-${p}-to`;l.classList.remove(u),l.classList.add(c)}},m=(l,o,s,h)=>{if(s.opsType===3||o){const d=n(s);if(d!=="pop"||!o){const p=o?"show":"enter",u=`fox-root-navigator__${d}-${p}-active`,c=`fox-root-navigator__${d}-${p}-to`;l.classList.remove(u),l.classList.remove(c)}}e.dragRemove&&!o&&s.opsType===3&&V(l,e.removePage,"fox-root-navigator__item-moving",1e3)},g=(l,o,s,h)=>{if(s.opsType===3||o){const d=n(s);if(d==="pop"&&o)return;const p=o?"hide":"leave",u=`fox-root-navigator__${d}-${p}-from`,c=`fox-root-navigator__${d}-${p}-active`;l.classList.add(u),l.classList.add(c)}},v=(l,o,s,h)=>{if(s.opsType===3||o){const d=n(s);if(d==="pop"&&o)return;const p=o?"hide":"leave",u=`fox-root-navigator__${d}-${p}-from`,c=`fox-root-navigator__${d}-${p}-to`;l.classList.remove(u),l.classList.add(c)}},f=(l,o,s,h)=>{if(s.opsType===3||o){const d=n(s);if(d!=="pop"||!o){const p=o?"hide":"leave",u=`fox-root-navigator__${d}-${p}-active`,c=`fox-root-navigator__${d}-${p}-to`;l.classList.remove(u),l.classList.remove(c)}}e.dragRemove&&!o&&X(l)};return(l,o)=>{const s=i.resolveComponent("fox-router-view");return i.openBlock(),i.createBlock(s,{class:"fox-root-navigator","view-class":"fox-root-navigator__item","before-enter":a,enter:r,"after-enter":m,"before-leave":g,leave:v,"after-leave":f,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["name","view-tag","transition"])}}}),rt="",A=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),U={class:"fox-swiper-navigator"},R=i.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=i.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(a,r)=>(i.openBlock(),i.createElementBlock("div",U,[i.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:i.normalizeStyle(i.unref(n))},[i.renderSlot(a.$slots,"default")],4)]))}});let Y=0;function q(){return++Y}const F=15,H=300,G=200;function J(t){t.stopPropagation()}function K(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&J(t)}function Q(t,e){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function L(t,e=0,n,a=G){n==="end"?t.style.transition=`transform ${a}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 Z{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,a,r){this.getStartDistance=e,this.openPage=n,this.isPageOpened=a,this.pageOpened=r}open(){const e=this.el,n=$(),a=(r,m,g,v)=>{let f=m+this.startDistance;const l=this.columnWidth/3;if(g==="end"){if(f==0){this.moving=!1;return}Math.abs(m)>l&&(m>0?f=this.startDistance+this.columnWidth:f=this.startDistance-this.columnWidth);let o=-f;o<0?o=0:o>this.width-this.columnWidth&&(o=this.width-this.columnWidth);const s=Math.floor(o/this.columnWidth);this.isPageOpened(s)||this.openPage(s),f=-s*this.columnWidth,v&&v>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(s)}),L(r,f,"end",v),this.scrollDistance=f}else{if(Math.abs(m)>l){let s=0;if(m>0?s=Math.abs(this.startDistance+this.columnWidth):s=Math.abs(this.startDistance-this.columnWidth),s>=0&&s<this.width){const h=Math.floor(s/this.columnWidth);this.isPageOpened(h)||this.openPage(h)}}let o=-f;o<this.min?o=this.min:o>this.max&&(o=this.max),L(r,-o,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=r=>{this.moving||(n.start(r),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=r=>{if(n.move(r),n.isVertical()){K(r,!0);return}a(e,n.deltaX.value,"",0)},this.touchend=()=>{const r=n.deltaX.value;if(r==0)return;const m=n.duration.value;if(m<H&&Math.abs(r)>F){const v=Q(r,m);a(e,v,"end",this.swipeDuration)}else a(e,r,"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 tt(t,e,n,a){return new Z(t,e,n,a)}const et=i.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openPage: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,a=i.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),f=tt(()=>a.scrollDistance,u=>{if(a.openedIndexList.indexOf(u)===-1){a.openedIndexList.push(u);const c=n.routes[u];try{n.openPage(c,u)}catch(_){console.error(_)}}},u=>a.openedIndexList.indexOf(u)!==-1,u=>{a.index=u,a.scrollDistance=-a.index*n.width;const c=n.routes[u];e("update:activePath",c.path)});i.onMounted(()=>{const u=h();f.el=u,f.open()}),i.onUnmounted(()=>{f.close()}),i.watchEffect(()=>{const u=n.activePath;a.index=n.routes.findIndex(st=>st.path===u);const c=n.width;a.index!==-1&&(a.openedIndexList.push(a.index),a.scrollDistance=-c*a.index);const _=c*n.routes.length,w=-c/3,D=c*(n.routes.length-1)+c/3;f.columnWidth=c,f.width=_,f.min=w,f.max=D,f.swipeDuration=n.swipeDuration});const l=`fox-swiper-navigator-${q()}`,o=i.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let s=null;function h(){return s||(s=document.querySelector(`.${l}>.fox-swiper-navigator__inner`),s)}const d=i.computed(()=>`${n.width*n.routes.length}px`),p=(u,c)=>({style:{left:`${n.routes.findIndex(w=>{const D=u.path??u.name??"";return w.path==D})*n.width}px`,width:`${n.width}px`}});return(u,c)=>{const _=i.resolveComponent("fox-router-view");return i.openBlock(),i.createBlock(_,{class:i.normalizeClass(l),style:i.normalizeStyle(i.unref(o)),"view-class":"fox-swiper-navigator__item",tag:R,"view-tag-props":p,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":a.scrollDistance,"scroll-time":n.scrollTime,width:i.unref(d)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}}),ct="",nt=Object.freeze(Object.defineProperty({__proto__:null,default:et},Symbol.toStringTag,{value:"Module"}));let ot="fox-";const it=[],b=Object.assign({"/src/components/card-navigator/index.vue":P,"/src/components/root-navigator/index.vue":A,"/src/components/swiper-navigator/index.vue":nt}),M=[];for(const t in b){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];it.indexOf(e)===-1&&M.push({name:e,component:b[t].default})}return{install(t){M.forEach(e=>{t.component(`${ot}${e.name}`,e.component)})}}});
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)})}}});
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .fox-card-navigator{position:relative;overflow:hidden;width:100%}.fox-card-navigator__item{position:fixed;width:100%}.fox-card-navigator__item-active{z-index:1}.fox-card-navigator__item-inactive{display:none;z-index:0}.fox-card-navigator__trans-enter-from,.fox-card-navigator__trans-show-from{-webkit-transform:translate3d(50%,0%,0);transform:translate3d(50%,0,0)}.fox-card-navigator__trans-enter-to,.fox-card-navigator__trans-show-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0%,0,0);transform:translateZ(0)}.fox-card-navigator__trans-hide-active{position:absolute;display:block}.fox-card-navigator__trans-leave-to,.fox-card-navigator__trans-hide-to{-webkit-transition:opacity .36s cubic-bezier(.17,.89,.45,1);transition:opacity .36s cubic-bezier(.17,.89,.45,1);opacity:0}.fox-root-navigator{position:relative;overflow:hidden;width:100%}.fox-root-navigator__item{position:fixed;left:0;top:0;width:100%;z-index:120;-webkit-box-sizing:border-box;box-sizing:border-box}.fox-root-navigator__item-moving{-webkit-box-shadow:0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);box-shadow:0 4px 8px #0003,0 6px 20px #00000030}.fox-root-navigator__slide-enter-from{-webkit-transform:translate3d(103%,0,0);transform:translate3d(103%,0,0)}.fox-root-navigator__slide-enter-active{-webkit-transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1),-webkit-transform .3s cubic-bezier(.17,.89,.45,1)}.fox-root-navigator__slide-enter-to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}.fox-root-navigator__slide-leave-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(103%,0,0);transform:translate3d(103%,0,0)}.fox-root-navigator__slide-show-from{-webkit-transform:translate3d(-50%,0%,0);transform:translate3d(-50%,0,0)}.fox-root-navigator__slide-show-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0%,0,0);transform:translateZ(0)}.fox-root-navigator__slide-hide-from{-webkit-transform:translate3d(0%,0%,0);transform:translateZ(0)}.fox-root-navigator__slide-hide-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.fox-root-navigator__pop-enter-from{-webkit-transform:translate3d(0,103%,0);transform:translate3d(0,103%,0)}.fox-root-navigator__pop-enter-active{-webkit-transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1),-webkit-transform .3s cubic-bezier(.17,.89,.45,1)}.fox-root-navigator__pop-enter-to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}.fox-root-navigator__pop-leave-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0,103%,0);transform:translate3d(0,103%,0)}.fox-swiper-navigator{position:relative;overflow:hidden;width:100%}.fox-swiper-navigator__item,.fox-swiper-navigator__inner{position:absolute;top:0;bottom:0}.fox-swiper-navigator__slide-enter-from{-webkit-transform:translate3d(103%,0,0);transform:translate3d(103%,0,0)}.fox-swiper-navigator__slide-enter-active{-webkit-transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1),-webkit-transform .3s cubic-bezier(.17,.89,.45,1)}.fox-swiper-navigator__slide-enter-to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}.fox-swiper-navigator__slide-leave-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(103%,0,0);transform:translate3d(103%,0,0)}.fox-swiper-navigator__slide-show-from{-webkit-transform:translate3d(-50%,0%,0);transform:translate3d(-50%,0,0)}.fox-swiper-navigator__slide-show-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0%,0,0);transform:translateZ(0)}.fox-swiper-navigator__slide-hide-from{-webkit-transform:translate3d(0%,0%,0);transform:translateZ(0)}.fox-swiper-navigator__slide-hide-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.fox-swiper-navigator__pop-enter-from{-webkit-transform:translate3d(0,103%,0);transform:translate3d(0,103%,0)}.fox-swiper-navigator__pop-enter-active{-webkit-transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1),-webkit-transform .3s cubic-bezier(.17,.89,.45,1)}.fox-swiper-navigator__pop-enter-to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}.fox-swiper-navigator__pop-leave-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0,103%,0);transform:translate3d(0,103%,0)}.fox-swiper-navigator .fox-header{position:absolute}
1
+ .fox-card-navigator{position:relative;overflow:hidden;width:100%}.fox-card-navigator__item{position:relative;width:100%}.fox-card-navigator__item-active{z-index:1}.fox-card-navigator__item-inactive{display:none;z-index:0}.fox-card-navigator__trans-enter-from,.fox-card-navigator__trans-show-from{-webkit-transform:translate3d(50%,0%,0);transform:translate3d(50%,0,0)}.fox-card-navigator__trans-enter-to,.fox-card-navigator__trans-show-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0%,0,0);transform:translateZ(0)}.fox-card-navigator__trans-hide-active{position:absolute;display:block;-webkit-transition:opacity .36s cubic-bezier(.17,.89,.45,1);transition:opacity .36s cubic-bezier(.17,.89,.45,1)}.fox-card-navigator__trans-leave-to,.fox-card-navigator__trans-hide-to{opacity:0}.fox-default-navigator__trans-enter,.fox-default-navigator__trans-show{-webkit-transform:translate3d(50%,0%,0);transform:translate3d(50%,0,0)}.fox-default-navigator__trans-enter-to,.fox-default-navigator__trans-show-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0%,0,0);transform:translateZ(0)}.fox-default-navigator__trans-hide-active{position:absolute;display:block;-webkit-transition:opacity .36s cubic-bezier(.17,.89,.45,1);transition:opacity .36s cubic-bezier(.17,.89,.45,1)}.fox-default-navigator__trans-leave-to,.fox-default-navigator__trans-hide-to{opacity:0}.fox-root-navigator{position:relative;overflow:hidden;width:100%}.fox-root-navigator__item{position:fixed;left:0;top:0;width:100%;z-index:120;-webkit-box-sizing:border-box;box-sizing:border-box}.fox-root-navigator__item-moving{-webkit-box-shadow:0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);box-shadow:0 4px 8px #0003,0 6px 20px #00000030}.fox-root-navigator__slide-enter-from{-webkit-transform:translate3d(103%,0,0);transform:translate3d(103%,0,0)}.fox-root-navigator__slide-enter-active{-webkit-transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1),-webkit-transform .3s cubic-bezier(.17,.89,.45,1)}.fox-root-navigator__slide-enter-to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}.fox-root-navigator__slide-leave-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(103%,0,0);transform:translate3d(103%,0,0)}.fox-root-navigator__slide-show-from{-webkit-transform:translate3d(-50%,0%,0);transform:translate3d(-50%,0,0)}.fox-root-navigator__slide-show-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0%,0,0);transform:translateZ(0)}.fox-root-navigator__slide-hide-from{-webkit-transform:translate3d(0%,0%,0);transform:translateZ(0)}.fox-root-navigator__slide-hide-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.fox-root-navigator__pop-enter-from{-webkit-transform:translate3d(0,103%,0);transform:translate3d(0,103%,0)}.fox-root-navigator__pop-enter-active{-webkit-transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1),-webkit-transform .3s cubic-bezier(.17,.89,.45,1)}.fox-root-navigator__pop-enter-to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}.fox-root-navigator__pop-leave-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0,103%,0);transform:translate3d(0,103%,0)}.fox-swiper-navigator{position:relative;overflow:hidden;width:100%}.fox-swiper-navigator__item,.fox-swiper-navigator__inner{position:absolute;top:0;bottom:0}.fox-swiper-navigator__slide-enter-from{-webkit-transform:translate3d(103%,0,0);transform:translate3d(103%,0,0)}.fox-swiper-navigator__slide-enter-active{-webkit-transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1),-webkit-transform .3s cubic-bezier(.17,.89,.45,1)}.fox-swiper-navigator__slide-enter-to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}.fox-swiper-navigator__slide-leave-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(103%,0,0);transform:translate3d(103%,0,0)}.fox-swiper-navigator__slide-show-from{-webkit-transform:translate3d(-50%,0%,0);transform:translate3d(-50%,0,0)}.fox-swiper-navigator__slide-show-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0%,0,0);transform:translateZ(0)}.fox-swiper-navigator__slide-hide-from{-webkit-transform:translate3d(0%,0%,0);transform:translateZ(0)}.fox-swiper-navigator__slide-hide-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(-50%,0,0);transform:translate3d(-50%,0,0)}.fox-swiper-navigator__pop-enter-from{-webkit-transform:translate3d(0,103%,0);transform:translate3d(0,103%,0)}.fox-swiper-navigator__pop-enter-active{-webkit-transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1);transition:transform .3s cubic-bezier(.17,.89,.45,1),-webkit-transform .3s cubic-bezier(.17,.89,.45,1)}.fox-swiper-navigator__pop-enter-to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}.fox-swiper-navigator__pop-leave-to{-webkit-transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:-webkit-transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1);transition:transform .36s cubic-bezier(.17,.89,.45,1),-webkit-transform .36s cubic-bezier(.17,.89,.45,1);-webkit-transform:translate3d(0,103%,0);transform:translate3d(0,103%,0)}.fox-swiper-navigator .fox-header-bar,.fox-swiper-navigator .fox-footer-bar{position:absolute!important}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fox-js/navigation",
3
- "version": "4.0.1-0",
3
+ "version": "4.0.1-4",
4
4
  "description": "fox navigation",
5
5
  "author": "jiangcheng",
6
6
  "keywords": [
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "scripts": {
32
- "publish:next": "npm version prerelease & npm publish --tag next",
32
+ "publish:next": "npm version prerelease && npm publish --tag next",
33
33
  "build:dev": "vue-tsc --noEmit && vite build --config scripts/vite.config.ts --mode development",
34
34
  "build:prod": "vue-tsc --noEmit && vite build --config scripts/vite.config.ts --mode production"
35
35
  },