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

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/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ <!--
2
+ * @version: 1.0
3
+ * @Author: 江成
4
+ * @Date: 2024-01-08 12:18:38
5
+ -->
6
+
7
+ ## 版本号
8
+
9
+ `时间`
10
+
11
+ Features
12
+
13
+ - xxx
14
+
15
+ Bug Fixes
16
+
17
+ - xxx
18
+
19
+ Other Changes
20
+
21
+ - xxx
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
  | 字段 | 说明 | 类型 | 默认值 |
@@ -58,6 +93,8 @@ const removePage = () => {
58
93
  | remove-page | 关闭顶层页面方法 | Function | |
59
94
  | router-view-name | router view名称 | String | `default` |
60
95
  | view-tag | view tag标签 | Function/String | `div` |
96
+ | remove-move-ratio | 触发移除页面的移动比例(相对页面宽度) | Number | 0.5 |
97
+ | momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
61
98
 
62
99
 
63
100
 
@@ -207,13 +244,13 @@ onMounted(() => {
207
244
 
208
245
  <template>
209
246
  <fox-page :content-padding="contentPadding" ref="pageRef">
210
- <fox-footer>
247
+ <fox-footer-bar>
211
248
  <fox-tabbar v-model="index" @change="onTabChange">
212
249
  <template v-for="tab in tabs" :key="tab.title">
213
250
  <fox-tabbar-item :title="tab.title" :icon="tab.icon"></fox-tabbar-item>
214
251
  </template>
215
252
  </fox-tabbar>
216
- </fox-footer>
253
+ </fox-footer-bar>
217
254
  <fox-content ref="contentRef">
218
255
  <fox-swiper-navigator
219
256
  v-model:activePath="activeRoutePath"
@@ -245,6 +282,8 @@ onMounted(() => {
245
282
  | drag | 是否支持拖曳 | Boolean | |
246
283
  | swipe-duration | 滑动页面动画时间 | Number ||
247
284
  | scroll-time | 切换页面动画时间 | Number | |
285
+ | move-ratio | 触发页面移动的比例(相对页面宽度) | Number | 0.5 |
286
+ | momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
248
287
 
249
288
 
250
289
 
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-9 Tue Feb 27 2024 11:12:56 GMT+0800 (中国标准时间)
3
+ */const s=require("vue"),L=require("@fox-js/fox"),W=s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,o)=>{const n=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(n,{class:"fox-card-navigator","view-class":"fox-card-navigator__item","view-active-class":"fox-card-navigator__item-active","view-inactive-class":"fox-card-navigator__item-inactive","transition-name":"fox-card-navigator__trans",transition:e.transition,multi:!0,name:e.routerViewName},null,8,["transition","name"])}}}),N=Object.freeze(Object.defineProperty({__proto__:null,default:W},Symbol.toStringTag,{value:"Module"})),k=s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,o)=>{const n=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(n,{transition:!1,multi:!1,name:e.routerViewName},{default:s.withCtx(({Component:r})=>[s.createVNode(s.Transition,{name:"fox-default-navigator__trans"},{default:s.withCtx(()=>[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(r)))]),_:2},1024)]),_:1},8,["name"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),S=10;function U(t,e){return t>e&&t>S?"horizontal":e>t&&e>S?"vertical":""}function V(){const t={startX:0,startY:0,startTime:0,duration:0,moveX:0,moveY:0,deltaX:0,deltaY:0,offsetX:0,offsetY:0,direction:""},e=()=>t.direction==="vertical",o=()=>t.direction==="horizontal",n=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:p=>{if(p.touches){const l=p.touches[0];t.deltaX=l.clientX-t.startX,t.deltaY=l.clientY-t.startY,t.moveX=l.clientX,t.moveY=l.clientY}else t.deltaX=p.clientX-t.startX,t.deltaY=p.clientY-t.startY,t.moveX=p.clientX,t.moveY=p.clientY;t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.duration=Date.now()-t.startTime,t.direction||(t.direction=U(t.offsetX,t.offsetY))},start:p=>{if(n(),p.touches){const l=p.touches[0];t.startX=l.clientX,t.startY=l.clientY}else t.startX=p.clientX,t.startY=p.clientY;t.startTime=Date.now()},reset:n,isVertical:e,isHorizontal:o,state:t}}function j(t){return t===window}const q=t=>{const e=s.unref(t);if(j(e)){const o=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:o,bottom:n,width:o,height:n}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},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,o=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*o}function P(t,e=0,o,n=J){o==="end"?t.style.transition=`transform ${n}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 C=new WeakMap;function tt(t,e,o,n,r=500,f,p=1e3){const l={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},_=t.previousSibling,m=V(),g=(a,v,y,x)=>{let D=v+l.startDistance;if(y==="end"){const c=q(a);let T=c.width*e;D<T?D=0:D=c.width;let w=!1;x&&x>0&&(w=!0,l.transitionEndTrigger=()=>{l.moving=!1,f&&a.classList.remove(f),D>0&&typeof n=="function"&&n()}),P(a,D,"end",x),_&&P(_,0,"",0),!w&&D>0&&typeof n=="function"&&(l.moving=!1,n())}else D<0&&(D=0),P(a,D,"",0)},i=()=>{t.style.transform="",t.style.transition="",l.transitionEndTrigger?(l.transitionEndTrigger(),l.transitionEndTrigger=null,_&&setTimeout(()=>{_&&(_.style.transform="",_.style.transition="")},r)):_&&(_.style.transform="",_.style.transition="")},u=/^matrix\((.+)\)$/,h=a=>{if(m.start(a),l.scrollDistance=0,l.moving){const v=t,{transform:y}=window.getComputedStyle(v);if(y){const x=u.exec(y);if(x){const c=x[1].split(/,\s*/);l.scrollDistance=+c[4]}}}f&&t.classList.add(f),l.startDistance=l.scrollDistance,l.transitionEndTrigger=null,l.moving=!0},b=a=>{l.moving=!0,m.move(a),!m.isVertical()&&(Q(a,!0),g(t,m.state.deltaX,"",0))},d=()=>{if(m.isVertical()){g(t,0,"end",p);return}const a=m.state.deltaX;if(a===0){f&&t.classList.remove(f),l.moving=!1;return}const v=m.state.duration;if(v<G&&Math.abs(a)>H){const x=Z(a,v,o);g(t,x,"end",p)}else g(t,a,"end",p)};t.addEventListener("transitionend",i),t.addEventListener("touchstart",h),t.addEventListener("touchmove",b),t.addEventListener("touchend",d),t.addEventListener("touchcancel",d),C.set(t,{state:l,transitionend:i,touchstart:h,touchmove:b,touchend:d,touchcancel:d})}function et(t){const e=C.get(t);e&&(C.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 nt=s.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},removeViewPageDuration:{default:500},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;let o=null,n=null;function r(i){return(i.params&&i.params.animationType)??"slide"}const f=(i,u,h,b)=>{if(h.opsType===L.OperationType.Append||u){const d=r(h);if(d==="pop"&&u)return;const a=u?"show":"enter";if(a==="enter"&&(o=h),a==="show"&&n&&r(n)==="pop")return;const v=`fox-root-navigator__${d}-${a}-from`,y=`fox-root-navigator__${d}-${a}-active`;i.classList.add(v),i.classList.add(y)}},p=(i,u,h,b)=>{if(h.opsType===L.OperationType.Append||u){const d=r(h);if(d==="pop"&&u)return;const a=u?"show":"enter";if(a==="show"&&n&&r(n)==="pop")return;const v=`fox-root-navigator__${d}-${a}-from`,y=`fox-root-navigator__${d}-${a}-to`;i.classList.remove(v),i.classList.add(y)}},l=(i,u,h,b)=>{if(h.opsType===L.OperationType.Append||u){const d=r(h);if(d!=="pop"||!u){const a=u?"show":"enter",v=`fox-root-navigator__${d}-${a}-active`,y=`fox-root-navigator__${d}-${a}-to`;i.classList.remove(v),i.classList.remove(y)}}e.dragRemove&&!u&&h.opsType===L.OperationType.Append&&tt(i,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},_=(i,u,h,b)=>{if(h.opsType===L.OperationType.Append||u){const d=r(h);if(d==="pop"&&u)return;const a=u?"hide":"leave";if(a==="leave"&&(n=h),a==="hide"&&o&&r(o)==="pop")return;const v=`fox-root-navigator__${d}-${a}-from`,y=`fox-root-navigator__${d}-${a}-active`;i.classList.add(v),i.classList.add(y)}},m=(i,u,h,b)=>{if(h.opsType===L.OperationType.Append||u){const d=r(h);if(d==="pop"&&u)return;const a=u?"hide":"leave";if(a==="hide"&&o&&r(o)==="pop")return;const v=`fox-root-navigator__${d}-${a}-from`,y=`fox-root-navigator__${d}-${a}-to`;i.classList.remove(v),i.classList.add(y)}},g=(i,u,h,b)=>{if(h.opsType===L.OperationType.Append||u){const d=r(h);if(d!=="pop"||!u){const a=u?"hide":"leave",v=`fox-root-navigator__${d}-${a}-active`,y=`fox-root-navigator__${d}-${a}-to`;i.classList.remove(v),i.classList.remove(y)}}e.dragRemove&&!u&&et(i)};return(i,u)=>{const h=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(h,{class:"fox-root-navigator","view-class":i.viewClass,"before-enter":f,enter:p,"after-enter":l,"before-leave":_,leave:m,"after-leave":g,multi:!0,name:i.routerViewName,"view-tag":i.viewTag,transition:i.transition},null,8,["view-class","name","view-tag","transition"])}}}),ot=Object.freeze(Object.defineProperty({__proto__:null,default:nt},Symbol.toStringTag,{value:"Module"})),it={class:"fox-swiper-navigator"},st=s.defineComponent({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,o=s.computed(()=>{const n={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(n["transition-duration"]=`${e.scrollDuration}ms`),n});return(n,r)=>(s.openBlock(),s.createElementBlock("div",it,[s.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:s.normalizeStyle(o.value)},[s.renderSlot(n.$slots,"default")],4)]))}});let at=0;function rt(){return++at}const ct=15,lt=300,ut=200;function dt(t){t.stopPropagation()}function ft(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&dt(t)}function ht(t,e,o=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*o}function X(t,e=0,o,n=ut){o==="end"?t.style.transition=`transform ${n}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 pt{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;moveRatio=.5;momentumReduceRatio=1;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,o,n,r,f,p){this.getStartDistance=e,this.openPage=o,this.isPageOpened=n,this.pageOpened=r,this.moveRatio=f,this.momentumReduceRatio=p}open(){const e=this.el,o=V(),n=(r,f,p,l)=>{let _=f+this.startDistance;const m=this.columnWidth*this.moveRatio;if(p==="end"){if(f==0){this.moving=!1;return}Math.abs(f)>m?f>0?_=this.startDistance+this.columnWidth:_=this.startDistance-this.columnWidth:_=this.startDistance;let g=-_;g<0?g=0:g>this.width-this.columnWidth&&(g=this.width-this.columnWidth);const i=Math.floor(g/this.columnWidth);this.isPageOpened(i)||this.openPage(i),_=-i*this.columnWidth,l&&l>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(i)}),X(r,_,"end",l),this.scrollDistance=_}else{if(Math.abs(f)>m){let i=0;if(f>0?i=Math.abs(this.startDistance+this.columnWidth):i=Math.abs(this.startDistance-this.columnWidth),i>=0&&i<this.width){const u=Math.floor(i/this.columnWidth);this.isPageOpened(u)||this.openPage(u)}}let g=-_;g<this.min?g=this.min:g>this.max&&(g=this.max),X(r,-g,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=r=>{this.moving||(o.start(r),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=r=>{o.move(r),!o.isVertical()&&(ft(r,!0),n(e,o.state.deltaX,"",0))},this.touchend=()=>{if(o.isVertical()){n(e,0,"end",this.swipeDuration);return}const r=o.state.deltaX;if(r==0)return;const f=o.state.duration;if(f<lt&&Math.abs(r)>ct){const l=ht(r,f,this.momentumReduceRatio);n(e,l,"end",this.swipeDuration)}else n(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 mt(t,e,o,n,r,f){return new pt(t,e,o,n,r,f)}function gt(t){const e=s.unref(t),o=window.getComputedStyle(e,null),n=parseFloat(o.getPropertyValue("padding-left")),r=parseFloat(o.getPropertyValue("padding-right")),f=parseFloat(o.getPropertyValue("padding-top")),p=parseFloat(o.getPropertyValue("padding-bottom"));return{width:e.clientWidth-n-r,height:e.clientHeight-f-p}}const vt=s.defineComponent({__name:"index",props:{activePath:{},routes:{},height:{default:-1},width:{default:-1},draggable:{type:Boolean,default:!0},openViewPage:{},routerViewName:{},moveRatio:{default:.5},momentumReduceRatio:{default:1},direction:{default:"horizontal"},transition:{type:[Function,Boolean],default:!0},swipeDuration:{default:360},scrollDuration:{},customClass:{},customStyle:{}},emits:["update:activePath"],setup(t,{emit:e}){const o=t,n=s.reactive({scrollDistance:0,index:-1,openedIndexList:[],width:o.width,height:o.height}),r=e,f=()=>n.scrollDistance,p=c=>{if(n.openedIndexList.indexOf(c)===-1){n.openedIndexList.push(c);const T=o.routes[c];try{o.openViewPage(T,c)}catch(w){console.error(w)}}},l=c=>n.openedIndexList.indexOf(c)!==-1,_=c=>{n.index=c,n.width>0?n.scrollDistance=-n.index*n.width:n.scrollDistance=0;const T=o.routes[c];r("update:activePath",T.path)};let m=null;o.draggable&&(m=mt(f,p,l,_,o.moveRatio,o.momentumReduceRatio));let g=null;s.onMounted(()=>{const c=a(),T=()=>{const w=gt(c);i(o.activePath,o.routes,w.width,w.height,o.swipeDuration,o.direction)};if(window.ResizeObserver&&(g=new window.ResizeObserver(T),g.observe(c)),T(),m){const w=y();m.el=w,m.open()}}),s.onBeforeUnmount(()=>{g&&(g.disconnect(),g=null),m&&m.close()}),s.watch([()=>o.activePath,()=>o.routes,()=>o.width,()=>o.height,()=>o.swipeDuration,()=>o.direction],([c,T,w,$,M,R])=>{const O=w<=0?n.width:w,E=$<=0?n.height:$;i(c,T,O,E,M,R)});const i=(c,T,w,$,M,R="horizontal")=>{const O=c;if(n.index=T.findIndex(E=>E.path===O),R==="horizontal"){const E=w;if(E>0){n.width=w;const B=E*o.routes.length,z=-E/3,Y=E*(T.length-1)+E/3;m&&(m.columnWidth=E,m.width=B,m.min=z,m.max=Y),n.index!==-1&&(n.openedIndexList.push(n.index),n.scrollDistance=-E*n.index)}}m&&(m.swipeDuration=M)},u=`fox-swiper-navigator-${rt()}`,h=s.computed(()=>{const c=[u];return o.customClass&&c.push(o.customClass),c}),b=s.computed(()=>{const c={},T=n.width>0?n.width:o.width;T>0&&(c.width=`${T}px`);const w=n.height>0?n.height:o.height;return w>0&&(c.height=`${w}px`),o.customStyle&&Object.assign(c,o.customStyle),c});let d=null;function a(){return d||(d=document.querySelector(`.${u}`),d)}let v=null;function y(){return v||(v=document.querySelector(`.${u}>.fox-swiper-navigator__inner`),v)}const x=s.computed(()=>n.width>0?`${n.width*o.routes.length}px`:"100%"),D=(c,T)=>{const w=o.routes.findIndex($=>{const M=c.path??c.name??"";return $.path==M});return n.width<=0?{}:{style:{left:`${w*n.width}px`,width:`${n.width}px`}}};return(c,T)=>{const w=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(w,{class:s.normalizeClass(h.value),style:s.normalizeStyle(b.value),"view-class":"fox-swiper-navigator__item",tag:st,"view-tag-props":D,multi:!0,name:c.routerViewName,transition:c.transition,"scroll-distance":n.scrollDistance,"scroll-duration":c.scrollDuration,direction:c.direction,width:x.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),_t=Object.freeze(Object.defineProperty({__proto__:null,default:vt},Symbol.toStringTag,{value:"Module"}));let wt="fox-";const yt=[],I=Object.assign({"/src/components/card-navigator/index.vue":N,"/src/components/default-navigator/index.vue":F,"/src/components/root-navigator/index.vue":ot,"/src/components/swiper-navigator/index.vue":_t}),A=[];for(const t in I){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];yt.indexOf(e)===-1&&A.push({name:e,component:I[t].default})}const Tt={install(t){A.forEach(e=>{t.component(`${wt}${e.name}`,e.component)})}};module.exports=Tt;
package/dist/index.d.ts CHANGED
@@ -5,8 +5,11 @@ declare const _default: {
5
5
  * 安装
6
6
  * @param app
7
7
  */
8
- install(app: App): void;
8
+ install(app: VueApp): void;
9
9
  };
10
10
  export default _default;
11
11
 
12
+ export declare interface VueApp extends App {
13
+ }
14
+
12
15
  export { }