@fox-js/navigation 4.0.1-9 → 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/README.md +150 -8
- package/dist/index.cjs.js +1 -3
- package/dist/index.d.ts +486 -1
- package/dist/index.esm.js +605 -479
- package/dist/index.umd.js +1 -3
- package/dist/style.css +2 -1
- package/package.json +3 -5
- package/tsconfig.tsbuildinfo +1 -0
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-8 Mon Feb 19 2024 13:58:27 GMT+0800 (中国标准时间)
|
|
3
|
-
*/const s=require("vue"),M=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:c})=>[s.createVNode(s.Transition,{name:"fox-default-navigator__trans"},{default:s.withCtx(()=>[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(c)))]),_: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 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 u=m.touches[0];t.deltaX=u.clientX-t.startX,t.deltaY=u.clientY-t.startY,t.moveX=u.clientX,t.moveY=u.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=U(t.offsetX,t.offsetY))},start:m=>{if(n(),m.touches){const u=m.touches[0];t.startX=u.clientX,t.startY=u.clientY}else t.startX=m.clientX,t.startY=m.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,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 Q(t,e,o,n,c=500,h,m=1e3){const u={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},g=t.previousSibling,_=I(),p=(a,v,w,x)=>{let D=v+u.startDistance;if(w==="end"){const r=q(a);let T=r.width*e;D<T?D=0:D=r.width;let y=!1;x&&x>0&&(y=!0,u.transitionEndTrigger=()=>{u.moving=!1,h&&a.classList.remove(h),D>0&&typeof n=="function"&&n()}),P(a,D,"end",x),g&&P(g,0,"",0),!y&&D>0&&typeof n=="function"&&(u.moving=!1,n())}else D<0&&(D=0),P(a,D,"",0)},i=()=>{t.style.transform="",t.style.transition="",u.transitionEndTrigger?(u.transitionEndTrigger(),u.transitionEndTrigger=null,g&&setTimeout(()=>{g&&(g.style.transform="",g.style.transition="")},c)):g&&(g.style.transform="",g.style.transition="")},l=/^matrix\((.+)\)$/,f=a=>{if(_.start(a),u.scrollDistance=0,u.moving){const v=t,{transform:w}=window.getComputedStyle(v);if(w){const x=l.exec(w);if(x){const r=x[1].split(/,\s*/);u.scrollDistance=+r[4]}}}h&&t.classList.add(h),u.startDistance=u.scrollDistance,u.transitionEndTrigger=null,u.moving=!0},L=a=>{u.moving=!0,_.move(a),!_.isVertical()&&p(t,_.state.deltaX,"",0)},d=()=>{if(_.isVertical()){p(t,0,"end",m);return}const a=_.state.deltaX;if(a===0){h&&t.classList.remove(h),u.moving=!1;return}const v=_.state.duration;if(v<G&&Math.abs(a)>H){const x=K(a,v,o);p(t,x,"end",m)}else p(t,a,"end",m)};t.addEventListener("transitionend",i),t.addEventListener("touchstart",f),t.addEventListener("touchmove",L),t.addEventListener("touchend",d),t.addEventListener("touchcancel",d),C.set(t,{state:u,transitionend:i,touchstart:f,touchmove:L,touchend:d,touchcancel:d})}function Z(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 tt=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 c(i){return(i.params&&i.params.animationType)??"slide"}const h=(i,l,f,L)=>{if(f.opsType===M.OperationType.Append||l){const d=c(f);if(d==="pop"&&l)return;const a=l?"show":"enter";if(a==="enter"&&(o=f),a==="show"&&n&&c(n)==="pop")return;const v=`fox-root-navigator__${d}-${a}-from`,w=`fox-root-navigator__${d}-${a}-active`;i.classList.add(v),i.classList.add(w)}},m=(i,l,f,L)=>{if(f.opsType===M.OperationType.Append||l){const d=c(f);if(d==="pop"&&l)return;const a=l?"show":"enter";if(a==="show"&&n&&c(n)==="pop")return;const v=`fox-root-navigator__${d}-${a}-from`,w=`fox-root-navigator__${d}-${a}-to`;i.classList.remove(v),i.classList.add(w)}},u=(i,l,f,L)=>{if(f.opsType===M.OperationType.Append||l){const d=c(f);if(d!=="pop"||!l){const a=l?"show":"enter",v=`fox-root-navigator__${d}-${a}-active`,w=`fox-root-navigator__${d}-${a}-to`;i.classList.remove(v),i.classList.remove(w)}}e.dragRemove&&!l&&f.opsType===M.OperationType.Append&&Q(i,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},g=(i,l,f,L)=>{if(f.opsType===M.OperationType.Append||l){const d=c(f);if(d==="pop"&&l)return;const a=l?"hide":"leave";if(a==="leave"&&(n=f),a==="hide"&&o&&c(o)==="pop")return;const v=`fox-root-navigator__${d}-${a}-from`,w=`fox-root-navigator__${d}-${a}-active`;i.classList.add(v),i.classList.add(w)}},_=(i,l,f,L)=>{if(f.opsType===M.OperationType.Append||l){const d=c(f);if(d==="pop"&&l)return;const a=l?"hide":"leave";if(a==="hide"&&o&&c(o)==="pop")return;const v=`fox-root-navigator__${d}-${a}-from`,w=`fox-root-navigator__${d}-${a}-to`;i.classList.remove(v),i.classList.add(w)}},p=(i,l,f,L)=>{if(f.opsType===M.OperationType.Append||l){const d=c(f);if(d!=="pop"||!l){const a=l?"hide":"leave",v=`fox-root-navigator__${d}-${a}-active`,w=`fox-root-navigator__${d}-${a}-to`;i.classList.remove(v),i.classList.remove(w)}}e.dragRemove&&!l&&Z(i)};return(i,l)=>{const f=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(f,{class:"fox-root-navigator","view-class":i.viewClass,"before-enter":h,enter:m,"after-enter":u,"before-leave":g,leave:_,"after-leave":p,multi:!0,name:i.routerViewName,"view-tag":i.viewTag,transition:i.transition},null,8,["view-class","name","view-tag","transition"])}}}),et=Object.freeze(Object.defineProperty({__proto__:null,default:tt},Symbol.toStringTag,{value:"Module"})),nt={class:"fox-swiper-navigator"},ot=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,c)=>(s.openBlock(),s.createElementBlock("div",nt,[s.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:s.normalizeStyle(o.value)},[s.renderSlot(n.$slots,"default")],4)]))}});let it=0;function st(){return++it}const at=15,rt=300,ct=200;function lt(t,e,o=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*o}function V(t,e=0,o,n=ct){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 ut{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,c,h,m){this.getStartDistance=e,this.openPage=o,this.isPageOpened=n,this.pageOpened=c,this.moveRatio=h,this.momentumReduceRatio=m}open(){const e=this.el,o=I(),n=(c,h,m,u)=>{let g=h+this.startDistance;const _=this.columnWidth*this.moveRatio;if(m==="end"){if(h==0){this.moving=!1;return}Math.abs(h)>_?h>0?g=this.startDistance+this.columnWidth:g=this.startDistance-this.columnWidth:g=this.startDistance;let p=-g;p<0?p=0:p>this.width-this.columnWidth&&(p=this.width-this.columnWidth);const i=Math.floor(p/this.columnWidth);this.isPageOpened(i)||this.openPage(i),g=-i*this.columnWidth,u&&u>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(i)}),V(c,g,"end",u),this.scrollDistance=g}else{if(Math.abs(h)>_){let i=0;if(h>0?i=Math.abs(this.startDistance+this.columnWidth):i=Math.abs(this.startDistance-this.columnWidth),i>=0&&i<this.width){const l=Math.floor(i/this.columnWidth);this.isPageOpened(l)||this.openPage(l)}}let p=-g;p<this.min?p=this.min:p>this.max&&(p=this.max),V(c,-p,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=c=>{this.moving||(o.start(c),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=c=>{o.move(c),!o.isVertical()&&n(e,o.state.deltaX,"",0)},this.touchend=()=>{if(o.isVertical()){n(e,0,"end",this.swipeDuration);return}const c=o.state.deltaX;if(c==0)return;const h=o.state.duration;if(h<rt&&Math.abs(c)>at){const u=lt(c,h,this.momentumReduceRatio);n(e,u,"end",this.swipeDuration)}else n(e,c,"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 dt(t,e,o,n,c,h){return new ut(t,e,o,n,c,h)}function ft(t){const e=s.unref(t),o=window.getComputedStyle(e,null),n=parseFloat(o.getPropertyValue("padding-left")),c=parseFloat(o.getPropertyValue("padding-right")),h=parseFloat(o.getPropertyValue("padding-top")),m=parseFloat(o.getPropertyValue("padding-bottom"));return{width:e.clientWidth-n-c,height:e.clientHeight-h-m}}const ht=s.defineComponent({__name:"index",props:{activePath:{},routes:{},height:{default:-1},width:{default:-1},drag:{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}),c=e,_=dt(()=>n.scrollDistance,r=>{if(n.openedIndexList.indexOf(r)===-1){n.openedIndexList.push(r);const T=o.routes[r];try{o.openViewPage(T,r)}catch(y){console.error(y)}}},r=>n.openedIndexList.indexOf(r)!==-1,r=>{n.index=r,n.width>0?n.scrollDistance=-n.index*n.width:n.scrollDistance=0;const T=o.routes[r];c("update:activePath",T.path)},o.moveRatio,o.momentumReduceRatio);let p=null;s.onMounted(()=>{const r=a(),T=()=>{const $=ft(r);i(o.activePath,o.routes,$.width,$.height,o.swipeDuration,o.direction)};window.ResizeObserver&&(p=new window.ResizeObserver(T),p.observe(r)),T();const y=w();_.el=y,_.open()}),s.onBeforeUnmount(()=>{p&&(p.disconnect(),p=null),_.close()}),s.watch([()=>o.activePath,()=>o.routes,()=>o.width,()=>o.height,()=>o.swipeDuration,()=>o.direction],([r,T,y,$,b,R])=>{const O=y<=0?n.width:y,E=$<=0?n.height:$;i(r,T,O,E,b,R)});const i=(r,T,y,$,b,R="horizontal")=>{const O=r;if(n.index=T.findIndex(E=>E.path===O),R==="horizontal"){const E=y;if(E>0){n.width=y;const B=E*o.routes.length,z=-E/3,Y=E*(T.length-1)+E/3;_.columnWidth=E,_.width=B,_.min=z,_.max=Y,n.index!==-1&&(n.openedIndexList.push(n.index),n.scrollDistance=-E*n.index)}}_.swipeDuration=b},l=`fox-swiper-navigator-${st()}`,f=s.computed(()=>{const r=[l];return o.customClass&&r.push(o.customClass),r}),L=s.computed(()=>{const r={},T=n.width>0?n.width:o.width;T>0&&(r.width=`${T}px`);const y=n.height>0?n.height:o.height;return y>0&&(r.height=`${y}px`),o.customStyle&&Object.assign(r,o.customStyle),r});let d=null;function a(){return d||(d=document.querySelector(`.${l}`),d)}let v=null;function w(){return v||(v=document.querySelector(`.${l}>.fox-swiper-navigator__inner`),v)}const x=s.computed(()=>n.width>0?`${n.width*o.routes.length}px`:"100%"),D=(r,T)=>{const y=o.routes.findIndex($=>{const b=r.path??r.name??"";return $.path==b});return n.width<=0?{}:{style:{left:`${y*n.width}px`,width:`${n.width}px`}}};return(r,T)=>{const y=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(y,{class:s.normalizeClass(f.value),style:s.normalizeStyle(L.value),"view-class":"fox-swiper-navigator__item",tag:ot,"view-tag-props":D,multi:!0,name:r.routerViewName,transition:r.transition,"scroll-distance":n.scrollDistance,"scroll-duration":r.scrollDuration,direction:r.direction,width:x.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),mt=Object.freeze(Object.defineProperty({__proto__:null,default:ht},Symbol.toStringTag,{value:"Module"}));let pt="fox-";const vt=[],X=Object.assign({"/src/components/card-navigator/index.vue":N,"/src/components/default-navigator/index.vue":F,"/src/components/root-navigator/index.vue":et,"/src/components/swiper-navigator/index.vue":mt}),A=[];for(const t in X){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];vt.indexOf(e)===-1&&A.push({name:e,component:X[t].default})}const gt={install(t){A.forEach(e=>{t.component(`${pt}${e.name}`,e.component)})}};module.exports=gt;
|
|
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;
|