@fox-js/navigation 4.0.1-8 → 4.0.1
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 +21 -0
- package/README.md +150 -8
- package/dist/index.cjs.js +1 -3
- package/dist/index.d.ts +486 -1
- package/dist/index.esm.js +655 -464
- package/dist/index.umd.js +1 -3
- package/dist/style.css +2 -1
- package/package.json +3 -5
- package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
### NPM
|
|
8
8
|
|
|
9
9
|
```shell
|
|
10
|
-
npm i @fox-js/navigation
|
|
10
|
+
npm i @fox-js/navigation@next
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
### YARN
|
|
14
14
|
|
|
15
15
|
```shell
|
|
16
|
-
yarn add @fox-js/navigation
|
|
16
|
+
yarn add @fox-js/navigation@next
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
### PNPM
|
|
20
20
|
|
|
21
21
|
```shell
|
|
22
|
-
pnpm add @fox-js/navigation
|
|
22
|
+
pnpm add @fox-js/navigation@next
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## 使用说明
|
|
@@ -89,12 +89,103 @@ pageHelper.append({
|
|
|
89
89
|
|
|
90
90
|
| 字段 | 说明 | 类型 | 默认值 |
|
|
91
91
|
|------------------|----------------------------------------|---------|-----------|
|
|
92
|
+
| router-view-name | router view名称 | String | `default` |
|
|
93
|
+
| view-tag | view tag标签 | Function/String | `div` |
|
|
94
|
+
| view-calss | view tag class | Function/String | - |
|
|
95
|
+
| transition | 动画支持 | Boolean | `true` |
|
|
92
96
|
| drag-remove | 是否支持拖曳关闭 | Boolean | true |
|
|
97
|
+
| draggable-area | 动拖曳区域 | Rect | |
|
|
93
98
|
| remove-page | 关闭顶层页面方法 | Function | |
|
|
99
|
+
| swipe-duration | 拖曳关闭动画时间(ms) | Number | `500` |
|
|
100
|
+
| remove-move-ratio | 触发删除动作的页面宽度比例 | Number | `0.5` |
|
|
101
|
+
| momentum-reduce-ratio | 惯性削减比例(0~1),1代表无削减 | Number | `1` |
|
|
102
|
+
| reset-delay | 动画完成后,重置状态延时(ms) | Number | `60` |
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## 插槽
|
|
107
|
+
|
|
108
|
+
| 名称 | 说明 |
|
|
109
|
+
|---------|------------------|
|
|
110
|
+
| default | 内容 |
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### fox-stack-navigator
|
|
114
|
+
|
|
115
|
+
stack导航组件,配合append方法使用,页面以堆栈的形式,新增的页面会盖在前一个页面上,支持新增页面的动画效果和拖曳关闭页面。
|
|
116
|
+
|
|
117
|
+
#### 基础用法
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
<script setup lang="ts">
|
|
121
|
+
import { usePageHelper } from '@/utils/custom'
|
|
122
|
+
// 获取page helper
|
|
123
|
+
const pageHelper = usePageHelper()
|
|
124
|
+
// 定义remove page函数
|
|
125
|
+
const removePage = () => {
|
|
126
|
+
pageHelper.remove()
|
|
127
|
+
}
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<template>
|
|
131
|
+
<fox-stack-navigator :remove-page="removePage"></fox-stack-navigator>
|
|
132
|
+
</template>
|
|
133
|
+
|
|
134
|
+
<style lang="scss">
|
|
135
|
+
</style>
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### 设置页面加载动画
|
|
140
|
+
|
|
141
|
+
##### 滑入方式
|
|
142
|
+
|
|
143
|
+
通过route的params属性设置animationType:'slide'
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { usePageHelper } from '@/utils/custom'
|
|
147
|
+
|
|
148
|
+
pageHelper.append({
|
|
149
|
+
path: target.route,
|
|
150
|
+
params: {
|
|
151
|
+
animationType:'slide'
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
##### 弹出方式
|
|
158
|
+
|
|
159
|
+
通过route的params属性设置animationType:'pop'
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import { usePageHelper } from '@/utils/custom'
|
|
163
|
+
|
|
164
|
+
pageHelper.append({
|
|
165
|
+
path: target.route,
|
|
166
|
+
params: {
|
|
167
|
+
animationType:'pop'
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
#### Props
|
|
175
|
+
|
|
176
|
+
| 字段 | 说明 | 类型 | 默认值 |
|
|
177
|
+
|------------------|----------------------------------------|---------|-----------|
|
|
94
178
|
| router-view-name | router view名称 | String | `default` |
|
|
95
179
|
| view-tag | view tag标签 | Function/String | `div` |
|
|
96
|
-
|
|
|
97
|
-
|
|
|
180
|
+
| view-calss | view tag class | Function/String | - |
|
|
181
|
+
| transition | 动画支持 | Boolean | `true` |
|
|
182
|
+
| drag-remove | 是否支持拖曳关闭 | Boolean | true |
|
|
183
|
+
| draggable-area | 动拖曳区域 | Rect | |
|
|
184
|
+
| remove-page | 关闭顶层页面方法 | Function | |
|
|
185
|
+
| swipe-duration | 拖曳关闭动画时间(ms) | Number | `500` |
|
|
186
|
+
| remove-move-ratio | 触发删除动作的页面宽度比例 | Number | `0.5` |
|
|
187
|
+
| momentum-reduce-ratio | 惯性削减比例(0~1),1代表无削减 | Number | `1` |
|
|
188
|
+
| reset-delay | 动画完成后,重置状态延时(ms) | Number | `60` |
|
|
98
189
|
|
|
99
190
|
|
|
100
191
|
|
|
@@ -244,13 +335,13 @@ onMounted(() => {
|
|
|
244
335
|
|
|
245
336
|
<template>
|
|
246
337
|
<fox-page :content-padding="contentPadding" ref="pageRef">
|
|
247
|
-
<fox-footer
|
|
338
|
+
<fox-footer>
|
|
248
339
|
<fox-tabbar v-model="index" @change="onTabChange">
|
|
249
340
|
<template v-for="tab in tabs" :key="tab.title">
|
|
250
341
|
<fox-tabbar-item :title="tab.title" :icon="tab.icon"></fox-tabbar-item>
|
|
251
342
|
</template>
|
|
252
343
|
</fox-tabbar>
|
|
253
|
-
</fox-footer
|
|
344
|
+
</fox-footer>
|
|
254
345
|
<fox-content ref="contentRef">
|
|
255
346
|
<fox-swiper-navigator
|
|
256
347
|
v-model:activePath="activeRoutePath"
|
|
@@ -282,12 +373,63 @@ onMounted(() => {
|
|
|
282
373
|
| drag | 是否支持拖曳 | Boolean | |
|
|
283
374
|
| swipe-duration | 滑动页面动画时间 | Number ||
|
|
284
375
|
| scroll-time | 切换页面动画时间 | Number | |
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
## 插槽
|
|
380
|
+
|
|
381
|
+
| 名称 | 说明 |
|
|
382
|
+
|---------|------------------|
|
|
383
|
+
| default | 内容 |
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
### fox-stack-navigator
|
|
388
|
+
|
|
389
|
+
stack导航组件,支持动画(和fox-root-navigator类型),支持拖曳新打开新页面/切换页面
|
|
390
|
+
|
|
391
|
+
#### 基础用法
|
|
392
|
+
|
|
393
|
+
```
|
|
394
|
+
<script setup lang="ts">
|
|
395
|
+
import { usePageHelper } from '@/utils/custom'
|
|
396
|
+
// 获取page helper
|
|
397
|
+
const pageHelper = usePageHelper()
|
|
398
|
+
// 定义remove page函数
|
|
399
|
+
const removePage = () => {
|
|
400
|
+
pageHelper.remove()
|
|
401
|
+
}
|
|
402
|
+
</script>
|
|
403
|
+
|
|
404
|
+
<template>
|
|
405
|
+
<fox-stack-navigator :remove-page="removePage"></fox-stack-navigator>
|
|
406
|
+
</template>
|
|
407
|
+
|
|
408
|
+
<style lang="scss">
|
|
409
|
+
</style>
|
|
410
|
+
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### Props
|
|
414
|
+
|
|
415
|
+
| 字段 | 说明 | 类型 | 默认值 |
|
|
416
|
+
|------------------|----------------------------------------|---------|-----------|
|
|
417
|
+
| open-page | 打开页面方法 | Function | |
|
|
418
|
+
| router-view-name | router view名称 | String | `default` |
|
|
419
|
+
| routes | 路由列表 | Route[] | |
|
|
420
|
+
| active-path | 激活路径 | String | |
|
|
421
|
+
| height | 导航容器高度 | Number | |
|
|
422
|
+
| width | 导航容器宽度 | Number | |
|
|
423
|
+
| drag | 是否支持拖曳 | Boolean | |
|
|
424
|
+
| swipe-duration | 滑动页面动画时间 | Number ||
|
|
425
|
+
| scroll-time | 切换页面动画时间 | Number | |
|
|
285
426
|
| move-ratio | 触发页面移动的比例(相对页面宽度) | Number | 0.5 |
|
|
286
427
|
| momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
|
|
287
428
|
|
|
288
429
|
|
|
289
430
|
|
|
290
|
-
|
|
431
|
+
|
|
432
|
+
#### 插槽
|
|
291
433
|
|
|
292
434
|
| 名称 | 说明 |
|
|
293
435
|
|---------|------------------|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
"use strict";/*!
|
|
2
|
-
* @fox-js/navigation v4.0.1-7 Fri Jan 05 2024 00:43:18 GMT+0800 (中国标准时间)
|
|
3
|
-
*/const o=require("vue"),R=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{class:"fox-card-navigator","view-class":"fox-card-navigator__item","view-active-class":"fox-card-navigator__item-active","view-inactive-class":"fox-card-navigator__item-inactive","transition-name":"fox-card-navigator__trans",transition:e.transition,multi:!0,name:e.routerViewName},null,8,["transition","name"])}}}),I=Object.freeze(Object.defineProperty({__proto__:null,default:R},Symbol.toStringTag,{value:"Module"})),S=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{transition:!1,multi:!1,name:e.routerViewName},{default:o.withCtx(({Component:h})=>[o.createVNode(o.Transition,{name:"fox-default-navigator__trans"},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(h)))]),_:2},1024)]),_:1},8,["name"])}}}),B=Object.freeze(Object.defineProperty({__proto__:null,default:S},Symbol.toStringTag,{value:"Module"})),$=10;function V(t,e){return t>e&&t>$?"horizontal":e>t&&e>$?"vertical":""}function O(){const t=o.ref(0),e=o.ref(0),n=o.ref(0),s=o.ref(0),m=o.ref(0),h=o.ref(0),g=o.ref(0),d=o.ref(0),u=o.ref(0),r=o.ref(0),i=o.ref(""),c=()=>i.value==="vertical",_=()=>i.value==="horizontal",f=()=>{g.value=0,d.value=0,u.value=0,r.value=0,i.value="",n.value=0};return{move:a=>{const p=a.touches[0];g.value=p.clientX-t.value,d.value=p.clientY-e.value,m.value=p.clientX,h.value=p.clientY,u.value=Math.abs(g.value),r.value=Math.abs(d.value),s.value=Date.now()-n.value,i.value||(i.value=V(u.value,r.value))},start:a=>{f(),t.value=a.touches[0].clientX,e.value=a.touches[0].clientY,n.value=Date.now()},reset:f,startX:t,startY:e,startTime:n,duration:s,moveX:m,moveY:h,deltaX:g,deltaY:d,offsetX:u,offsetY:r,direction:i,isVertical:c,isHorizontal:_}}function W(t){return t===window}const z=t=>{const e=o.unref(t);if(W(e)){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},N=15,k=300,j=200;function X(t){t.stopPropagation()}function A(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&X(t)}function U(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function D(t,e=0,n,s=j){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}const E=new WeakMap;function Y(t,e,n,s,m=500,h,g=1e3){const d={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},u=t.previousSibling,r=O(),i=(a,p,T,x)=>{let w=p+d.startDistance;if(T==="end"){const y=z(a);let C=y.width*e;w<C?w=0:w=y.width;let b=!1;x&&x>0&&(b=!0,d.transitionEndTrigger=()=>{d.moving=!1,h&&a.classList.remove(h),w>0&&typeof s=="function"&&s()}),D(a,w,"end",x),u&&D(u,0,"",0),!b&&w>0&&typeof s=="function"&&(d.moving=!1,s())}else w<0&&(w=0),D(a,w,"",0)},c=()=>{t.style.transform="",t.style.transition="",d.transitionEndTrigger?(d.transitionEndTrigger(),d.transitionEndTrigger=null,u&&setTimeout(()=>{u&&(u.style.transform="",u.style.transition="")},m)):u&&(u.style.transform="",u.style.transition="")},_=/^matrix\((.+)\)$/,f=a=>{if(r.start(a),d.scrollDistance=0,d.moving){const p=t,{transform:T}=window.getComputedStyle(p);if(T){const x=_.exec(T);if(x){const y=x[1].split(/,\s*/);d.scrollDistance=+y[4]}}}h&&t.classList.add(h),d.startDistance=d.scrollDistance,d.transitionEndTrigger=null,d.moving=!0},v=a=>{d.moving=!0,r.move(a),r.isHorizontal()&&A(a,!0),i(t,r.deltaX.value,"",0)},l=()=>{if(r.isVertical()){i(t,0,"end",g);return}const a=r.deltaX.value;if(a===0){h&&t.classList.remove(h),d.moving=!1;return}const p=r.duration.value;if(p<k&&Math.abs(a)>N){const x=U(a,p,n);i(t,x,"end",g)}else i(t,a,"end",g)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",f),t.addEventListener("touchmove",v),t.addEventListener("touchend",l),t.addEventListener("touchcancel",l),E.set(t,{state:d,transitionend:c,touchstart:f,touchmove:v,touchend:l,touchcancel:l})}function q(t){const e=E.get(t);e&&(E.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const H=o.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},removeViewPageDuration:{default:500},routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;function n(r){return(r.params&&r.params.animationType)??"slide"}const s=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-active`;r.classList.add(l),r.classList.add(a)}},m=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.add(a)}},h=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const v=i?"show":"enter",l=`fox-root-navigator__${f}-${v}-active`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&c.opsType===3&&Y(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},g=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-active`;r.classList.add(l),r.classList.add(a)}},d=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.add(a)}},u=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const v=i?"hide":"leave",l=`fox-root-navigator__${f}-${v}-active`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&q(r)};return(r,i)=>{const c=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:m,"after-enter":h,"before-leave":g,leave:d,"after-leave":u,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:H},Symbol.toStringTag,{value:"Module"})),G={class:"fox-swiper-navigator"},J=o.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=o.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,m)=>(o.openBlock(),o.createElementBlock("div",G,[o.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:o.normalizeStyle(o.unref(n))},[o.renderSlot(s.$slots,"default")],4)]))}});let K=0;function Q(){return++K}const Z=15,tt=300,et=200;function nt(t){t.stopPropagation()}function ot(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&nt(t)}function it(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function L(t,e=0,n,s=et){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}class st{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;moveRatio=.5;momentumReduceRatio=1;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,n,s,m,h,g){this.getStartDistance=e,this.openPage=n,this.isPageOpened=s,this.pageOpened=m,this.moveRatio=h,this.momentumReduceRatio=g}open(){const e=this.el,n=O(),s=(m,h,g,d)=>{let u=h+this.startDistance;const r=this.columnWidth*this.moveRatio;if(g==="end"){if(u==0){this.moving=!1;return}Math.abs(h)>r&&(h>0?u=this.startDistance+this.columnWidth:u=this.startDistance-this.columnWidth);let i=-u;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const c=Math.floor(i/this.columnWidth);this.isPageOpened(c)||this.openPage(c),u=-c*this.columnWidth,d&&d>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(c)}),L(m,u,"end",d),this.scrollDistance=u}else{if(Math.abs(h)>r){let c=0;if(h>0?c=Math.abs(this.startDistance+this.columnWidth):c=Math.abs(this.startDistance-this.columnWidth),c>=0&&c<this.width){const _=Math.floor(c/this.columnWidth);this.isPageOpened(_)||this.openPage(_)}}let i=-u;i<this.min?i=this.min:i>this.max&&(i=this.max),L(m,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=m=>{this.moving||(n.start(m),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=m=>{n.move(m),n.isHorizontal()&&ot(m,!0),s(e,n.deltaX.value,"",0)},this.touchend=()=>{if(n.isVertical()){s(e,0,"end",this.swipeDuration);return}const m=n.deltaX.value;if(m==0)return;const h=n.duration.value;if(h<tt&&Math.abs(m)>Z){const d=it(m,h,this.momentumReduceRatio);s(e,d,"end",this.swipeDuration)}else s(e,m,"end",this.swipeDuration)},e.addEventListener("transitionend",this.transitionend),e.addEventListener("touchstart",this.touchstart),e.addEventListener("touchmove",this.touchmove),e.addEventListener("touchend",this.touchend),e.addEventListener("touchcancel",this.touchend)}close(){const e=this.el;this.transitionend&&e.addEventListener("transitionend",this.transitionend),this.touchstart&&e.addEventListener("touchstart",this.touchstart),this.touchmove&&e.addEventListener("touchmove",this.touchmove),this.touchend&&e.addEventListener("touchend",this.touchend),this.touchcancel&&e.addEventListener("touchcancel",this.touchcancel),this.el=null}}function at(t,e,n,s,m,h){return new st(t,e,n,s,m,h)}const rt=o.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,moveRatio:{default:.5},momentumReduceRatio:{default:1},transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,s=o.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),u=at(()=>s.scrollDistance,l=>{if(s.openedIndexList.indexOf(l)===-1){s.openedIndexList.push(l);const a=n.routes[l];try{n.openViewPage(a,l)}catch(p){console.error(p)}}},l=>s.openedIndexList.indexOf(l)!==-1,l=>{s.index=l,s.scrollDistance=-s.index*n.width;const a=n.routes[l];e("update:activePath",a.path)},n.moveRatio,n.momentumReduceRatio);o.onMounted(()=>{const l=_();u.el=l,u.open()}),o.onUnmounted(()=>{u.close()}),o.watchEffect(()=>{const l=n.activePath;s.index=n.routes.findIndex(w=>w.path===l);const a=n.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-a*s.index);const p=a*n.routes.length,T=-a/3,x=a*(n.routes.length-1)+a/3;u.columnWidth=a,u.width=p,u.min=T,u.max=x,u.swipeDuration=n.swipeDuration});const r=`fox-swiper-navigator-${Q()}`,i=o.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let c=null;function _(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const f=o.computed(()=>`${n.width*n.routes.length}px`),v=(l,a)=>({style:{left:`${n.routes.findIndex(T=>{const x=l.path??l.name??"";return T.path==x})*n.width}px`,width:`${n.width}px`}});return(l,a)=>{const p=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(p,{class:o.normalizeClass(r),style:o.normalizeStyle(o.unref(i)),"view-class":"fox-swiper-navigator__item",tag:J,"view-tag-props":v,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":s.scrollDistance,"scroll-time":n.scrollTime,width:o.unref(f)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}}),ct=Object.freeze(Object.defineProperty({__proto__:null,default:rt},Symbol.toStringTag,{value:"Module"}));let lt="fox-";const ut=[],M=Object.assign({"/src/components/card-navigator/index.vue":I,"/src/components/default-navigator/index.vue":B,"/src/components/root-navigator/index.vue":F,"/src/components/swiper-navigator/index.vue":ct}),P=[];for(const t in M){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];ut.indexOf(e)===-1&&P.push({name:e,component:M[t].default})}const dt={install(t){P.forEach(e=>{t.component(`${lt}${e.name}`,e.component)})}};module.exports=dt;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let f=require("vue"),$=require("@fox-js/fox");var Q=(0,f.defineComponent)({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,o)=>{const n=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(n,{transition:!1,multi:!1,name:t.routerViewName},{default:(0,f.withCtx)(({Component:l})=>[(0,f.createVNode)(f.Transition,{name:"fox-default-navigator__trans"},{default:(0,f.withCtx)(()=>[((0,f.openBlock)(),(0,f.createBlock)((0,f.resolveDynamicComponent)(l)))]),_:2},1024)]),_:1},8,["name"])}}}),N=Q,B=10;function Z(t,e){return t>e&&t>B?"horizontal":e>t&&e>B?"vertical":""}function I(){const t={startX:0,startY:0,startTime:0,duration:0,moveX:0,moveY:0,deltaX:0,deltaY:0,offsetX:0,offsetY:0,direction:""},e=()=>t.direction==="vertical",o=()=>t.direction==="horizontal",n=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:(m=>{if(m.touches){const w=m.touches[0];t.deltaX=w.clientX-t.startX,t.deltaY=w.clientY-t.startY,t.moveX=w.clientX,t.moveY=w.clientY}else t.deltaX=m.clientX-t.startX,t.deltaY=m.clientY-t.startY,t.moveX=m.clientX,t.moveY=m.clientY;t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.duration=Date.now()-t.startTime,t.direction||(t.direction=Z(t.offsetX,t.offsetY))}),start:(m=>{if(n(),m.touches){const w=m.touches[0];t.startX=w.clientX,t.startY=w.clientY}else t.startX=m.clientX,t.startY=m.clientY;t.startTime=Date.now()}),reset:n,isVertical:e,isHorizontal:o,state:t}}function tt(t){return t===window}var W=t=>{const e=(0,f.unref)(t);if(tt(e)){const o=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:o,bottom:n,width:o,height:n}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},z=(t,e,o)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const n=document.createEvent("Events");let l=!0,p=!0;for(let m in e)m==="bubbles"?l=!!e[m]:m==="cancelable"?p=!!e[m]:n[m]=e[m];n.initEvent(t,l,p),(o??document).dispatchEvent(n)},et=15,nt=300,ot=200;function it(t){t.stopPropagation()}function at(t,e,o=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*o}function R(t,e=0,o,n=ot){o==="end"?t.style.transition=`transform ${n}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function V(t){t.style.transition="",t.style.transform=""}var rt=/^matrix\((.+)\)$/;function O(t){let e=0;const o=t,{transform:n}=window.getComputedStyle(o);if(n){const l=rt.exec(n);l&&(e=+l[1].split(/,\s*/)[4])}return e}var k=new WeakMap;function st(t,e,o,n,l,p,m=600,w=60,E=null){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},T=t.previousSibling,h=I(),r=(i,v,g,L)=>{let u=v+a.startDistance;if(g==="end"){const y=W(i);let _=y.width*e;u<_?u=0:u=y.width,a.transitionEndTrigger=()=>{a.moving=!1,p&&i.classList.remove(p),setTimeout(()=>{T&&V(T),u==0?V(i):z($.FoxLeaveEnd,{},i),a.moving=!1},w)},T&&R(T,0,"",0),u>0&&typeof n=="function"&&n(l),R(i,u,"end",L)}else u<0&&(u=0),R(i,u,"",0)},d=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},c=i=>{if(h.start(i),a.draging=E?E(t,h.state.startX,h.state.startY):!0,!a.draging){h.reset();return}a.scrollDistance=0,a.moving&&(a.scrollDistance=O(t)),p&&t.classList.add(p),a.transitionEndTrigger=null,a.moving=!0},x=i=>{a.draging&&(a.moving=!0,h.move(i),!h.isVertical()&&(O(t)===0&&h.state.deltaX<0||(it(i),r(t,h.state.deltaX,"",0))))},s=()=>{if(!a.draging||(a.draging=!1,h.isVertical())||O(t)===0&&h.state.deltaX<0)return;const i=h.state.deltaX;if(i===0){p&&t.classList.remove(p),a.moving=!1;return}const v=h.state.duration;if(v<nt&&Math.abs(i)>et){const g=at(i,v,o);r(t,g,"end",m)}else r(t,i,"end",m)};t.addEventListener("transitionend",d),t.addEventListener("transitioncancel",d),t.addEventListener("touchstart",c),t.addEventListener("touchmove",x),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),k.set(t,{state:a,transitionend:d,transitioncancel:d,touchstart:c,touchmove:x,touchend:s,touchcancel:s})}function ct(t){const e=k.get(t);e&&(k.delete(t),t.removeEventListener("transitionend",e.transitionend),t.removeEventListener("transitioncancel",e.transitioncancel),t.removeEventListener("touchstart",e.touchstart),t.removeEventListener("touchmove",e.touchmove),t.removeEventListener("touchend",e.touchend),t.removeEventListener("touchcancel",e.touchcancel))}var lt=(0,f.defineComponent)({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},resetDelay:{default:120},swipeDuration:{default:60},draggableArea:{},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},transitionDuration:{},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let o=null,n=null;function l(r){return(r&&r.params&&r.params.animationType)??"slide"}function p(r){return(r&&r.params&&r.params.dragRemove)??e.dragRemove}const m=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="show"&&(s==="pop"||n!=="leave"||(o?l(o):"")==="pop"))return;i==="enter"&&(o=c,n="enter");const v=`fox-root-navigator--${s}-${i}-from`,g=`fox-root-navigator--${s}-${i}-active`;r.classList.add(v),r.classList.add(g)}},w=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="show"&&(s==="pop"||n!=="leave"||(o?l(o):"")==="pop"))return;const v=`fox-root-navigator--${s}-${i}-from`,g=`fox-root-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.add(g)}},E=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="enter"&&(o=null,n=null),s!=="pop"){const v=`fox-root-navigator--${s}-${i}-active`,g=`fox-root-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.remove(g)}}if(p(c)===!0&&!d&&c?.opsType===$.OperationType.Append){let s=null;e.draggableArea&&(s=function(i,v,g){const L=v-i.offsetLeft,u=g-i.offsetTop;return!(e.draggableArea?.left&&L<e.draggableArea?.left||e.draggableArea?.right&&L>e.draggableArea?.right||e.draggableArea?.top&&u<e.draggableArea?.top||e.draggableArea?.bottom&&u>e.draggableArea?.bottom)}),st(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,c,"fox-root-navigator__item--moving",e.swipeDuration,e.resetDelay,s)}},a=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="hide"&&(s==="pop"||n!=="enter"||(o?l(o):"")==="pop"))return;i==="leave"&&(o=c,n="leave");const v=`fox-root-navigator--${s}-${i}-from`,g=`fox-root-navigator--${s}-${i}-active`;r.classList.add(v),r.classList.add(g)}},T=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="hide"&&(s==="pop"||n!=="enter"||(o?l(o):"")==="pop"))return;const v=`fox-root-navigator--${s}-${i}-from`,g=`fox-root-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.add(g)}},h=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="leave"&&(o=null,n=null),s!=="pop"){const v=`fox-root-navigator--${s}-${i}-active`,g=`fox-root-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.remove(g)}}p(c)&&!d&&ct(r)};return(r,d)=>{const c=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":m,enter:w,"after-enter":E,"before-leave":a,leave:T,"after-leave":h,multi:!0,name:t.routerViewName,"view-tag":t.viewTag,transition:t.transition,"transition-duration":t.transitionDuration},null,8,["view-class","name","view-tag","transition","transition-duration"])}}}),U=lt,ut=(0,f.defineComponent)({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,o)=>{const n=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(n,{class:"fox-card-navigator","view-class":"fox-card-navigator__item","view-active-class":"fox-card-navigator__item-active","view-inactive-class":"fox-card-navigator__item-inactive","transition-name":"fox-card-navigator__trans",transition:t.transition,multi:!0,name:t.routerViewName},null,8,["transition","name"])}}}),q=ut,dt=15,ft=300,vt=200;function gt(t){t.stopPropagation()}function mt(t,e,o=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*o}function P(t,e=0,o,n=vt){o==="end"?t.style.transition=`transform ${n}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function Y(t){t.style.transition="",t.style.transform=""}var pt=/^matrix\((.+)\)$/;function X(t){let e=0;const o=t,{transform:n}=window.getComputedStyle(o);if(n){const l=pt.exec(n);l&&(e=+l[1].split(/,\s*/)[4])}return e}var S=new WeakMap;function ht(t,e,o,n,l,p,m=600,w=60,E=null){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},T=t.previousSibling,h=I(),r=(i,v,g,L)=>{let u=v+a.startDistance;if(g==="end"){const y=W(i);let _=y.width*e;u<_?u=0:u=y.width,a.transitionEndTrigger=()=>{a.moving=!1,p&&i.classList.remove(p),setTimeout(()=>{T&&Y(T),u==0?Y(i):z($.FoxLeaveEnd,{},i),a.moving=!1},w)},T&&P(T,0,"",0),u>0&&typeof n=="function"&&n(l),P(i,u,"end",L)}else u<0&&(u=0),P(i,u,"",0)},d=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},c=i=>{if(h.start(i),a.draging=E?E(t,h.state.startX,h.state.startY):!0,!a.draging){h.reset();return}a.scrollDistance=0,a.moving&&(a.scrollDistance=X(t)),p&&t.classList.add(p),a.transitionEndTrigger=null,a.moving=!0},x=i=>{a.draging&&(a.moving=!0,h.move(i),!h.isVertical()&&(X(t)===0&&h.state.deltaX<0||(gt(i),r(t,h.state.deltaX,"",0))))},s=()=>{if(!a.draging||(a.draging=!1,h.isVertical())||X(t)===0&&h.state.deltaX<0)return;const i=h.state.deltaX;if(i===0){p&&t.classList.remove(p),a.moving=!1;return}const v=h.state.duration;if(v<ft&&Math.abs(i)>dt){const g=mt(i,v,o);r(t,g,"end",m)}else r(t,i,"end",m)};t.addEventListener("transitionend",d),t.addEventListener("transitioncancel",d),t.addEventListener("touchstart",c),t.addEventListener("touchmove",x),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),S.set(t,{state:a,transitionend:d,transitioncancel:d,touchstart:c,touchmove:x,touchend:s,touchcancel:s})}function Tt(t){const e=S.get(t);e&&(S.delete(t),t.removeEventListener("transitionend",e.transitionend),t.removeEventListener("transitioncancel",e.transitioncancel),t.removeEventListener("touchstart",e.touchstart),t.removeEventListener("touchmove",e.touchmove),t.removeEventListener("touchend",e.touchend),t.removeEventListener("touchcancel",e.touchcancel))}var wt=(0,f.defineComponent)({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},resetDelay:{default:120},swipeDuration:{default:60},draggableArea:{},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},transitionDuration:{},viewClass:{type:[Function,String],default:"fox-stack-navigator__item"}},setup(t){const e=t;let o=null,n=null;function l(r){return(r&&r.params&&r.params.animationType)??"slide"}function p(r){return(r&&r.params&&r.params.dragRemove)??e.dragRemove}const m=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="show"&&(s==="pop"||n!=="leave"||(o?l(o):"")==="pop"))return;i==="enter"&&(o=c,n="enter");const v=`fox-stack-navigator--${s}-${i}-from`,g=`fox-stack-navigator--${s}-${i}-active`;r.classList.add(v),r.classList.add(g)}},w=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="show"&&(s==="pop"||n!=="leave"||(o?l(o):"")==="pop"))return;const v=`fox-stack-navigator--${s}-${i}-from`,g=`fox-stack-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.add(g)}},E=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"show":"enter";if(i==="enter"&&(o=null,n=null),s!=="pop"){const v=`fox-stack-navigator--${s}-${i}-active`,g=`fox-stack-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.remove(g)}}if(p(c)===!0&&!d&&c?.opsType===$.OperationType.Append){let s=null;e.draggableArea&&(s=function(i,v,g){const L=v-i.offsetLeft,u=g-i.offsetTop;return!(e.draggableArea?.left&&L<e.draggableArea?.left||e.draggableArea?.right&&L>e.draggableArea?.right||e.draggableArea?.top&&u<e.draggableArea?.top||e.draggableArea?.bottom&&u>e.draggableArea?.bottom)}),ht(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,c,"fox-stack-navigator__item--moving",e.swipeDuration,e.resetDelay,s)}},a=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="hide"&&(s==="pop"||n!=="enter"||(o?l(o):"")==="pop"))return;i==="leave"&&(o=c,n="leave");const v=`fox-stack-navigator--${s}-${i}-from`,g=`fox-stack-navigator--${s}-${i}-active`;r.classList.add(v),r.classList.add(g)}},T=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="hide"&&(s==="pop"||n!=="enter"||(o?l(o):"")==="pop"))return;const v=`fox-stack-navigator--${s}-${i}-from`,g=`fox-stack-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.add(g)}},h=(r,d,c,x)=>{if(c?.opsType===$.OperationType.Append||d){const s=l(c),i=d?"hide":"leave";if(i==="leave"&&(o=null,n=null),s!=="pop"){const v=`fox-stack-navigator--${s}-${i}-active`,g=`fox-stack-navigator--${s}-${i}-to`;r.classList.remove(v),r.classList.remove(g)}}p(c)&&!d&&Tt(r)};return(r,d)=>{const c=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(c,{class:"fox-stack-navigator","view-class":t.viewClass,"before-enter":m,enter:w,"after-enter":E,"before-leave":a,leave:T,"after-leave":h,multi:!0,name:t.routerViewName,"view-tag":t.viewTag,transition:t.transition,"transition-duration":t.transitionDuration},null,8,["view-class","name","view-tag","transition","transition-duration"])}}}),j=wt,_t={class:"fox-swiper-navigator"},xt=(0,f.defineComponent)({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,o=(0,f.computed)(()=>{const n={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(n["transition-duration"]=`${e.scrollDuration}ms`),n});return(n,l)=>((0,f.openBlock)(),(0,f.createElementBlock)("div",_t,[(0,f.createElementVNode)("div",{class:"fox-swiper-navigator__inner",style:(0,f.normalizeStyle)(o.value)},[(0,f.renderSlot)(n.$slots,"default")],4)]))}}),yt=xt,$t=0;function Et(){return++$t}var Lt=15,Dt=300,bt=200;function Mt(t){t.stopPropagation()}function At(t,e,o=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*o}function F(t,e=0,o,n=bt){o==="end"?t.style.transition=`transform ${n}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}var Ct=class{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;moveRatio=.5;momentumReduceRatio=1;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(t,e,o,n,l,p){this.getStartDistance=t,this.openPage=e,this.isPageOpened=o,this.pageOpened=n,this.moveRatio=l,this.momentumReduceRatio=p}open(){const t=this.el,e=I(),o=(n,l,p,m)=>{let w=l+this.startDistance;const E=this.columnWidth*this.moveRatio;if(p==="end"){if(l==0){this.moving=!1;return}Math.abs(l)>E?l>0?w=this.startDistance+this.columnWidth:w=this.startDistance-this.columnWidth:w=this.startDistance;let a=-w;a<0?a=0:a>this.width-this.columnWidth&&(a=this.width-this.columnWidth);const T=Math.floor(a/this.columnWidth);this.isPageOpened(T)||this.openPage(T),w=-T*this.columnWidth,m&&m>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(T)}),F(n,w,"end",m),this.scrollDistance=w}else{if(Math.abs(l)>E){let T=0;if(l>0?T=Math.abs(this.startDistance+this.columnWidth):T=Math.abs(this.startDistance-this.columnWidth),T>=0&&T<this.width){const h=Math.floor(T/this.columnWidth);this.isPageOpened(h)||this.openPage(h)}}let a=-w;a<this.min?a=this.min:a>this.max&&(a=this.max),F(n,-a,"",0)}};this.transitionend=()=>{t.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=n=>{this.moving||(e.start(n),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=n=>{e.move(n),!e.isVertical()&&(Mt(n),o(t,e.state.deltaX,"",0))},this.touchend=()=>{if(e.isVertical())return;const n=e.state.deltaX;if(n==0)return;const l=e.state.duration;if(l<Dt&&Math.abs(n)>Lt){const p=At(n,l,this.momentumReduceRatio);o(t,p,"end",this.swipeDuration)}else o(t,n,"end",this.swipeDuration)},t.addEventListener("transitionend",this.transitionend),t.addEventListener("touchstart",this.touchstart),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.touchend)}close(){const t=this.el;this.transitionend&&t.removeEventListener("transitionend",this.transitionend),this.touchstart&&t.removeEventListener("touchstart",this.touchstart),this.touchmove&&t.removeEventListener("touchmove",this.touchmove),this.touchend&&t.removeEventListener("touchend",this.touchend),this.touchcancel&&t.removeEventListener("touchcancel",this.touchcancel),this.el=null}};function Rt(t,e,o,n,l,p){return new Ct(t,e,o,n,l,p)}function Ot(t){const e=(0,f.unref)(t),o=window.getComputedStyle(e,null),n=parseFloat(o.getPropertyValue("padding-left")),l=parseFloat(o.getPropertyValue("padding-right")),p=parseFloat(o.getPropertyValue("padding-top")),m=parseFloat(o.getPropertyValue("padding-bottom"));return{width:e.clientWidth-n-l,height:e.clientHeight-p-m}}var Pt=(0,f.defineComponent)({__name:"index",props:{activePath:{},routes:{},height:{default:-1},width:{default:-1},draggable:{type:Boolean,default:!0},openViewPage:{},routerViewName:{},moveRatio:{default:.5},momentumReduceRatio:{default:1},direction:{default:"horizontal"},transition:{type:[Function,Boolean],default:!0},swipeDuration:{default:360},scrollDuration:{},customClass:{},customStyle:{}},emits:["update:activePath"],setup(t,{emit:e}){const o=t,n=(0,f.reactive)({scrollDistance:0,index:-1,openedIndexList:[],width:o.width,height:o.height}),l=e,p=()=>n.scrollDistance,m=u=>{if(n.openedIndexList.indexOf(u)===-1){n.openedIndexList.push(u);const y=o.routes[u];try{o.openViewPage(y,u)}catch(_){console.error(_)}}},w=u=>n.openedIndexList.indexOf(u)!==-1,E=u=>{n.index=u,n.width>0?n.scrollDistance=-n.index*n.width:n.scrollDistance=0;const y=o.routes[u];l("update:activePath",y.path)};let a=null;o.draggable&&(a=Rt(p,m,w,E,o.moveRatio,o.momentumReduceRatio));let T=null;(0,f.onMounted)(()=>{const u=s(),y=()=>{const _=Ot(u);h(o.activePath,o.routes,_.width,_.height,o.swipeDuration,o.direction)};if(window.ResizeObserver&&(T=new window.ResizeObserver(y),T.observe(u)),y(),a){const _=v();a.el=_,a.open()}}),(0,f.onBeforeUnmount)(()=>{T&&(T.disconnect(),T=null),a&&a.close()}),(0,f.watch)([()=>o.activePath,()=>o.routes,()=>o.width,()=>o.height,()=>o.swipeDuration,()=>o.direction],([u,y,_,b,M,A])=>{const C=_<=0?n.width:_,D=b<=0?n.height:b;h(u,y,C,D,M,A)});const h=(u,y,_,b,M,A="horizontal")=>{const C=u;if(n.index=y.findIndex(D=>D.path===C),A==="horizontal"){const D=_;if(D>0){n.width=_;const G=D*o.routes.length,J=-D/3,K=D*(y.length-1)+D/3;a&&(a.columnWidth=D,a.width=G,a.min=J,a.max=K),n.index!==-1&&(n.openedIndexList.push(n.index),n.scrollDistance=-D*n.index)}}a&&(a.swipeDuration=M)},r=`fox-swiper-navigator-${Et()}`,d=(0,f.computed)(()=>{const u=[r];return o.customClass&&u.push(o.customClass),u}),c=(0,f.computed)(()=>{const u={},y=n.width>0?n.width:o.width;y>0&&(u.width=`${y}px`);const _=n.height>0?n.height:o.height;return _>0&&(u.height=`${_}px`),o.customStyle&&Object.assign(u,o.customStyle),u});let x=null;function s(){return x||(x=document.querySelector(`.${r}`),x)}let i=null;function v(){return i||(i=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),i)}const g=(0,f.computed)(()=>n.width>0?`${n.width*o.routes.length}px`:"100%"),L=(u,y)=>{const _=o.routes.findIndex(b=>{const M=u.path??u.name??"";return b.path==M});return n.width<=0?{}:{style:{left:`${_*n.width}px`,width:`${n.width}px`}}};return(u,y)=>{const _=(0,f.resolveComponent)("fox-router-view");return(0,f.openBlock)(),(0,f.createBlock)(_,{class:(0,f.normalizeClass)(d.value),style:(0,f.normalizeStyle)(c.value),"view-class":"fox-swiper-navigator__item",tag:yt,"view-tag-props":L,multi:!0,name:t.routerViewName,transition:t.transition,"scroll-distance":n.scrollDistance,"scroll-duration":t.scrollDuration,direction:t.direction,width:g.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),H=Pt,Xt={install(t,e="fox"){t.component(`${e}-default-navigator`,N),t.component(`${e}-root-navigator`,U),t.component(`${e}-card-navigator`,q),t.component(`${e}-stack-navigator`,j),t.component(`${e}-swiper-navigator`,H)}};exports.FoxCardNavigator=q;exports.FoxDefaultNavigator=N;exports.FoxRootNavigator=U;exports.FoxStackNavigator=j;exports.FoxSwiperNavigator=H;exports.default=Xt;
|