@fox-js/navigation 4.0.1-14 → 4.0.1-16
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 +294 -294
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +253 -239
- package/dist/index.umd.js +2 -2
- package/package.json +34 -34
package/README.md
CHANGED
|
@@ -1,294 +1,294 @@
|
|
|
1
|
-
# fox-navigation
|
|
2
|
-
|
|
3
|
-
导航组件,支持动画过渡
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
### NPM
|
|
8
|
-
|
|
9
|
-
```shell
|
|
10
|
-
npm i @fox-js/navigation -S
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### YARN
|
|
14
|
-
|
|
15
|
-
```shell
|
|
16
|
-
yarn add @fox-js/navigation
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### PNPM
|
|
20
|
-
|
|
21
|
-
```shell
|
|
22
|
-
pnpm add @fox-js/navigation
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## 使用说明
|
|
26
|
-
|
|
27
|
-
### fox-root-navigator
|
|
28
|
-
|
|
29
|
-
root导航组件,在入口vue文件(App.vue)上使用,支持新增页面的动画效果和拖曳关闭页面。
|
|
30
|
-
|
|
31
|
-
#### 基础用法
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
<script setup lang="ts">
|
|
35
|
-
import { usePageHelper } from '@/utils/custom'
|
|
36
|
-
// 获取page helper
|
|
37
|
-
const pageHelper = usePageHelper()
|
|
38
|
-
// 定义remove page函数
|
|
39
|
-
const removePage = () => {
|
|
40
|
-
pageHelper.remove()
|
|
41
|
-
}
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<template>
|
|
45
|
-
<fox-root-navigator :remove-page="removePage"></fox-root-navigator>
|
|
46
|
-
</template>
|
|
47
|
-
|
|
48
|
-
<style lang="scss">
|
|
49
|
-
</style>
|
|
50
|
-
|
|
51
|
-
```
|
|
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
|
-
|
|
88
|
-
#### Props
|
|
89
|
-
|
|
90
|
-
| 字段 | 说明 | 类型 | 默认值 |
|
|
91
|
-
|------------------|----------------------------------------|---------|-----------|
|
|
92
|
-
| drag-remove | 是否支持拖曳关闭 | Boolean | true |
|
|
93
|
-
| remove-page | 关闭顶层页面方法 | Function | |
|
|
94
|
-
| router-view-name | router view名称 | String | `default` |
|
|
95
|
-
| view-tag | view tag标签 | Function/String | `div` |
|
|
96
|
-
| remove-move-ratio | 触发移除页面的移动比例(相对页面宽度) | Number | 0.5 |
|
|
97
|
-
| momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
## 插槽
|
|
102
|
-
|
|
103
|
-
| 名称 | 说明 |
|
|
104
|
-
|---------|------------------|
|
|
105
|
-
| default | 内容 |
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
### fox-card-navigator
|
|
110
|
-
|
|
111
|
-
卡片导航组件,配合多标签页容器使用,具备缓存页面的能力。
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
#### 基础用法
|
|
116
|
-
|
|
117
|
-
```
|
|
118
|
-
<script setup lang="ts">
|
|
119
|
-
const rootName = $ref('_tab_view')
|
|
120
|
-
</script>
|
|
121
|
-
|
|
122
|
-
<template>
|
|
123
|
-
<fox-card-navigator
|
|
124
|
-
:router-view-name="rootName"
|
|
125
|
-
:transition="true"
|
|
126
|
-
></fox-card-navigator>
|
|
127
|
-
</template>
|
|
128
|
-
|
|
129
|
-
<style lang="scss">
|
|
130
|
-
</style>
|
|
131
|
-
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
#### Props
|
|
135
|
-
|
|
136
|
-
| 字段 | 说明 | 类型 | 默认值 |
|
|
137
|
-
|------------------|----------------------------------------|---------|-----------|
|
|
138
|
-
| router-view-name | router view名称 | String | `default` |
|
|
139
|
-
| transition | 是否支持过渡动画 | Boolean | false |
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
## 插槽
|
|
144
|
-
|
|
145
|
-
| 名称 | 说明 |
|
|
146
|
-
|---------|------------------|
|
|
147
|
-
| default | 内容 |
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### fox-swiper-navigator
|
|
151
|
-
|
|
152
|
-
swiper导航组件,配合tab标签使用(例如手机端的主界面),支持拖曳新打开新页面/切换页面
|
|
153
|
-
|
|
154
|
-
#### 基础用法
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
<script lang="ts" setup>
|
|
158
|
-
import { onMounted, ref, computed } from 'vue'
|
|
159
|
-
import { usePageHelper } from '@/utils/custom'
|
|
160
|
-
import store from '@/store'
|
|
161
|
-
import tabs from './data'
|
|
162
|
-
const contentPadding = {
|
|
163
|
-
left: 0,
|
|
164
|
-
top: 0,
|
|
165
|
-
right: 0,
|
|
166
|
-
bottom: 0
|
|
167
|
-
}
|
|
168
|
-
// -------------- 导航设置 ---------------
|
|
169
|
-
// content width/height
|
|
170
|
-
const contentWidth = ref(0)
|
|
171
|
-
const contentHeight = ref(0)
|
|
172
|
-
// page ref
|
|
173
|
-
const pageRef = ref(null)
|
|
174
|
-
// root name
|
|
175
|
-
const rootName = ref('_tab_view')
|
|
176
|
-
// routes
|
|
177
|
-
const routes = computed(() => {
|
|
178
|
-
return tabs.map(tab => {
|
|
179
|
-
return {
|
|
180
|
-
path: tab.route
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
})
|
|
184
|
-
// active route path
|
|
185
|
-
const activeRoutePath = computed({
|
|
186
|
-
set: (newVal: string) => {
|
|
187
|
-
// 更新tab bar的index
|
|
188
|
-
index.value = routes.value.findIndex(r => {
|
|
189
|
-
return r.path === newVal
|
|
190
|
-
})
|
|
191
|
-
store.setCurrentRoutePath(newVal, rootName.value)
|
|
192
|
-
},
|
|
193
|
-
get: (): string => {
|
|
194
|
-
return store.getCurrentRoutePath(rootName.value) as string
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
|
-
// open page
|
|
198
|
-
const openPage = (route: any, index: number) => {
|
|
199
|
-
onTabChange(index)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// -------------tab bar 设置 ------------------
|
|
203
|
-
//当前tab索引
|
|
204
|
-
const index = ref(0)
|
|
205
|
-
// 获取page helper
|
|
206
|
-
const pageHelper = usePageHelper()
|
|
207
|
-
// tab change事件
|
|
208
|
-
const onTabChange = (index: any) => {
|
|
209
|
-
const tab = tabs[index]
|
|
210
|
-
// open页面
|
|
211
|
-
pageHelper.open(tab.route)
|
|
212
|
-
// 当前的route path到公共store中
|
|
213
|
-
store.setCurrentRoutePath(tab.route, rootName.value)
|
|
214
|
-
}
|
|
215
|
-
// content应用
|
|
216
|
-
const contentRef = ref(null)
|
|
217
|
-
// 加载后处理
|
|
218
|
-
onMounted(() => {
|
|
219
|
-
if (pageRef.value) {
|
|
220
|
-
const anyPage: any = pageRef.value
|
|
221
|
-
contentWidth.value = anyPage.getPageContentWidth()
|
|
222
|
-
if (contentWidth.value === 0) {
|
|
223
|
-
const anyContent: any = contentRef.value
|
|
224
|
-
contentWidth.value = anyContent.$el.offsetWidth
|
|
225
|
-
}
|
|
226
|
-
contentHeight.value = anyPage.getPageContentHeight()
|
|
227
|
-
}
|
|
228
|
-
// 当前选中tab index
|
|
229
|
-
let curIndex = index.value
|
|
230
|
-
// 获取之前保存的route path
|
|
231
|
-
let path = store.getCurrentRoutePath(rootName.value)
|
|
232
|
-
if (path) {
|
|
233
|
-
let i = tabs.findIndex(tab => {
|
|
234
|
-
return tab.route === path
|
|
235
|
-
})
|
|
236
|
-
curIndex = i !== -1 ? i : curIndex
|
|
237
|
-
// 更新tab的model
|
|
238
|
-
index.value = curIndex
|
|
239
|
-
}
|
|
240
|
-
// 触发页面跳转
|
|
241
|
-
onTabChange(curIndex)
|
|
242
|
-
})
|
|
243
|
-
</script>
|
|
244
|
-
|
|
245
|
-
<template>
|
|
246
|
-
<fox-page :content-padding="contentPadding" ref="pageRef">
|
|
247
|
-
<fox-footer-bar>
|
|
248
|
-
<fox-tabbar v-model="index" @change="onTabChange">
|
|
249
|
-
<template v-for="tab in tabs" :key="tab.title">
|
|
250
|
-
<fox-tabbar-item :title="tab.title" :icon="tab.icon"></fox-tabbar-item>
|
|
251
|
-
</template>
|
|
252
|
-
</fox-tabbar>
|
|
253
|
-
</fox-footer-bar>
|
|
254
|
-
<fox-content ref="contentRef">
|
|
255
|
-
<fox-swiper-navigator
|
|
256
|
-
v-model:activePath="activeRoutePath"
|
|
257
|
-
:router-view-name="rootName"
|
|
258
|
-
:routes="routes"
|
|
259
|
-
:open-page="openPage"
|
|
260
|
-
:transition="true"
|
|
261
|
-
:width="contentWidth"
|
|
262
|
-
:height="contentHeight"
|
|
263
|
-
></fox-swiper-navigator>
|
|
264
|
-
</fox-content>
|
|
265
|
-
</fox-page>
|
|
266
|
-
</template>
|
|
267
|
-
|
|
268
|
-
<style lang="scss" scoped></style>
|
|
269
|
-
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
#### Props
|
|
273
|
-
|
|
274
|
-
| 字段 | 说明 | 类型 | 默认值 |
|
|
275
|
-
|------------------|----------------------------------------|---------|-----------|
|
|
276
|
-
| open-page | 打开页面方法 | Function | |
|
|
277
|
-
| router-view-name | router view名称 | String | `default` |
|
|
278
|
-
| routes | 路由列表 | Route[] | |
|
|
279
|
-
| active-path | 激活路径 | String | |
|
|
280
|
-
| height | 导航容器高度 | Number | |
|
|
281
|
-
| width | 导航容器宽度 | Number | |
|
|
282
|
-
| drag | 是否支持拖曳 | Boolean | |
|
|
283
|
-
| swipe-duration | 滑动页面动画时间 | Number ||
|
|
284
|
-
| scroll-time | 切换页面动画时间 | Number | |
|
|
285
|
-
| move-ratio | 触发页面移动的比例(相对页面宽度) | Number | 0.5 |
|
|
286
|
-
| momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
## 插槽
|
|
291
|
-
|
|
292
|
-
| 名称 | 说明 |
|
|
293
|
-
|---------|------------------|
|
|
294
|
-
| default | 内容 |
|
|
1
|
+
# fox-navigation
|
|
2
|
+
|
|
3
|
+
导航组件,支持动画过渡
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
### NPM
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm i @fox-js/navigation -S
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### YARN
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
yarn add @fox-js/navigation
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### PNPM
|
|
20
|
+
|
|
21
|
+
```shell
|
|
22
|
+
pnpm add @fox-js/navigation
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 使用说明
|
|
26
|
+
|
|
27
|
+
### fox-root-navigator
|
|
28
|
+
|
|
29
|
+
root导航组件,在入口vue文件(App.vue)上使用,支持新增页面的动画效果和拖曳关闭页面。
|
|
30
|
+
|
|
31
|
+
#### 基础用法
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
<script setup lang="ts">
|
|
35
|
+
import { usePageHelper } from '@/utils/custom'
|
|
36
|
+
// 获取page helper
|
|
37
|
+
const pageHelper = usePageHelper()
|
|
38
|
+
// 定义remove page函数
|
|
39
|
+
const removePage = () => {
|
|
40
|
+
pageHelper.remove()
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<fox-root-navigator :remove-page="removePage"></fox-root-navigator>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<style lang="scss">
|
|
49
|
+
</style>
|
|
50
|
+
|
|
51
|
+
```
|
|
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
|
+
|
|
88
|
+
#### Props
|
|
89
|
+
|
|
90
|
+
| 字段 | 说明 | 类型 | 默认值 |
|
|
91
|
+
|------------------|----------------------------------------|---------|-----------|
|
|
92
|
+
| drag-remove | 是否支持拖曳关闭 | Boolean | true |
|
|
93
|
+
| remove-page | 关闭顶层页面方法 | Function | |
|
|
94
|
+
| router-view-name | router view名称 | String | `default` |
|
|
95
|
+
| view-tag | view tag标签 | Function/String | `div` |
|
|
96
|
+
| remove-move-ratio | 触发移除页面的移动比例(相对页面宽度) | Number | 0.5 |
|
|
97
|
+
| momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## 插槽
|
|
102
|
+
|
|
103
|
+
| 名称 | 说明 |
|
|
104
|
+
|---------|------------------|
|
|
105
|
+
| default | 内容 |
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
### fox-card-navigator
|
|
110
|
+
|
|
111
|
+
卡片导航组件,配合多标签页容器使用,具备缓存页面的能力。
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
#### 基础用法
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
<script setup lang="ts">
|
|
119
|
+
const rootName = $ref('_tab_view')
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<template>
|
|
123
|
+
<fox-card-navigator
|
|
124
|
+
:router-view-name="rootName"
|
|
125
|
+
:transition="true"
|
|
126
|
+
></fox-card-navigator>
|
|
127
|
+
</template>
|
|
128
|
+
|
|
129
|
+
<style lang="scss">
|
|
130
|
+
</style>
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Props
|
|
135
|
+
|
|
136
|
+
| 字段 | 说明 | 类型 | 默认值 |
|
|
137
|
+
|------------------|----------------------------------------|---------|-----------|
|
|
138
|
+
| router-view-name | router view名称 | String | `default` |
|
|
139
|
+
| transition | 是否支持过渡动画 | Boolean | false |
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
## 插槽
|
|
144
|
+
|
|
145
|
+
| 名称 | 说明 |
|
|
146
|
+
|---------|------------------|
|
|
147
|
+
| default | 内容 |
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
### fox-swiper-navigator
|
|
151
|
+
|
|
152
|
+
swiper导航组件,配合tab标签使用(例如手机端的主界面),支持拖曳新打开新页面/切换页面
|
|
153
|
+
|
|
154
|
+
#### 基础用法
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
<script lang="ts" setup>
|
|
158
|
+
import { onMounted, ref, computed } from 'vue'
|
|
159
|
+
import { usePageHelper } from '@/utils/custom'
|
|
160
|
+
import store from '@/store'
|
|
161
|
+
import tabs from './data'
|
|
162
|
+
const contentPadding = {
|
|
163
|
+
left: 0,
|
|
164
|
+
top: 0,
|
|
165
|
+
right: 0,
|
|
166
|
+
bottom: 0
|
|
167
|
+
}
|
|
168
|
+
// -------------- 导航设置 ---------------
|
|
169
|
+
// content width/height
|
|
170
|
+
const contentWidth = ref(0)
|
|
171
|
+
const contentHeight = ref(0)
|
|
172
|
+
// page ref
|
|
173
|
+
const pageRef = ref(null)
|
|
174
|
+
// root name
|
|
175
|
+
const rootName = ref('_tab_view')
|
|
176
|
+
// routes
|
|
177
|
+
const routes = computed(() => {
|
|
178
|
+
return tabs.map(tab => {
|
|
179
|
+
return {
|
|
180
|
+
path: tab.route
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
})
|
|
184
|
+
// active route path
|
|
185
|
+
const activeRoutePath = computed({
|
|
186
|
+
set: (newVal: string) => {
|
|
187
|
+
// 更新tab bar的index
|
|
188
|
+
index.value = routes.value.findIndex(r => {
|
|
189
|
+
return r.path === newVal
|
|
190
|
+
})
|
|
191
|
+
store.setCurrentRoutePath(newVal, rootName.value)
|
|
192
|
+
},
|
|
193
|
+
get: (): string => {
|
|
194
|
+
return store.getCurrentRoutePath(rootName.value) as string
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
// open page
|
|
198
|
+
const openPage = (route: any, index: number) => {
|
|
199
|
+
onTabChange(index)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// -------------tab bar 设置 ------------------
|
|
203
|
+
//当前tab索引
|
|
204
|
+
const index = ref(0)
|
|
205
|
+
// 获取page helper
|
|
206
|
+
const pageHelper = usePageHelper()
|
|
207
|
+
// tab change事件
|
|
208
|
+
const onTabChange = (index: any) => {
|
|
209
|
+
const tab = tabs[index]
|
|
210
|
+
// open页面
|
|
211
|
+
pageHelper.open(tab.route)
|
|
212
|
+
// 当前的route path到公共store中
|
|
213
|
+
store.setCurrentRoutePath(tab.route, rootName.value)
|
|
214
|
+
}
|
|
215
|
+
// content应用
|
|
216
|
+
const contentRef = ref(null)
|
|
217
|
+
// 加载后处理
|
|
218
|
+
onMounted(() => {
|
|
219
|
+
if (pageRef.value) {
|
|
220
|
+
const anyPage: any = pageRef.value
|
|
221
|
+
contentWidth.value = anyPage.getPageContentWidth()
|
|
222
|
+
if (contentWidth.value === 0) {
|
|
223
|
+
const anyContent: any = contentRef.value
|
|
224
|
+
contentWidth.value = anyContent.$el.offsetWidth
|
|
225
|
+
}
|
|
226
|
+
contentHeight.value = anyPage.getPageContentHeight()
|
|
227
|
+
}
|
|
228
|
+
// 当前选中tab index
|
|
229
|
+
let curIndex = index.value
|
|
230
|
+
// 获取之前保存的route path
|
|
231
|
+
let path = store.getCurrentRoutePath(rootName.value)
|
|
232
|
+
if (path) {
|
|
233
|
+
let i = tabs.findIndex(tab => {
|
|
234
|
+
return tab.route === path
|
|
235
|
+
})
|
|
236
|
+
curIndex = i !== -1 ? i : curIndex
|
|
237
|
+
// 更新tab的model
|
|
238
|
+
index.value = curIndex
|
|
239
|
+
}
|
|
240
|
+
// 触发页面跳转
|
|
241
|
+
onTabChange(curIndex)
|
|
242
|
+
})
|
|
243
|
+
</script>
|
|
244
|
+
|
|
245
|
+
<template>
|
|
246
|
+
<fox-page :content-padding="contentPadding" ref="pageRef">
|
|
247
|
+
<fox-footer-bar>
|
|
248
|
+
<fox-tabbar v-model="index" @change="onTabChange">
|
|
249
|
+
<template v-for="tab in tabs" :key="tab.title">
|
|
250
|
+
<fox-tabbar-item :title="tab.title" :icon="tab.icon"></fox-tabbar-item>
|
|
251
|
+
</template>
|
|
252
|
+
</fox-tabbar>
|
|
253
|
+
</fox-footer-bar>
|
|
254
|
+
<fox-content ref="contentRef">
|
|
255
|
+
<fox-swiper-navigator
|
|
256
|
+
v-model:activePath="activeRoutePath"
|
|
257
|
+
:router-view-name="rootName"
|
|
258
|
+
:routes="routes"
|
|
259
|
+
:open-page="openPage"
|
|
260
|
+
:transition="true"
|
|
261
|
+
:width="contentWidth"
|
|
262
|
+
:height="contentHeight"
|
|
263
|
+
></fox-swiper-navigator>
|
|
264
|
+
</fox-content>
|
|
265
|
+
</fox-page>
|
|
266
|
+
</template>
|
|
267
|
+
|
|
268
|
+
<style lang="scss" scoped></style>
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
#### Props
|
|
273
|
+
|
|
274
|
+
| 字段 | 说明 | 类型 | 默认值 |
|
|
275
|
+
|------------------|----------------------------------------|---------|-----------|
|
|
276
|
+
| open-page | 打开页面方法 | Function | |
|
|
277
|
+
| router-view-name | router view名称 | String | `default` |
|
|
278
|
+
| routes | 路由列表 | Route[] | |
|
|
279
|
+
| active-path | 激活路径 | String | |
|
|
280
|
+
| height | 导航容器高度 | Number | |
|
|
281
|
+
| width | 导航容器宽度 | Number | |
|
|
282
|
+
| drag | 是否支持拖曳 | Boolean | |
|
|
283
|
+
| swipe-duration | 滑动页面动画时间 | Number ||
|
|
284
|
+
| scroll-time | 切换页面动画时间 | Number | |
|
|
285
|
+
| move-ratio | 触发页面移动的比例(相对页面宽度) | Number | 0.5 |
|
|
286
|
+
| momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
## 插槽
|
|
291
|
+
|
|
292
|
+
| 名称 | 说明 |
|
|
293
|
+
|---------|------------------|
|
|
294
|
+
| default | 内容 |
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";/*!
|
|
2
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
-
*/const s=require("vue"),b=require("@fox-js/fox"),k=s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{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"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),U=s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{transition:!1,multi:!1,name:e.routerViewName},{default:s.withCtx(({Component:i})=>[s.createVNode(s.Transition,{name:"fox-default-navigator__trans"},{default:s.withCtx(()=>[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i)))]),_:2},1024)]),_:1},8,["name"])}}}),j=Object.freeze(Object.defineProperty({__proto__:null,default:U},Symbol.toStringTag,{value:"Module"})),S=10;function q(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",n=()=>t.direction==="horizontal",o=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:m=>{if(m.touches){const a=m.touches[0];t.deltaX=a.clientX-t.startX,t.deltaY=a.clientY-t.startY,t.moveX=a.clientX,t.moveY=a.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=q(t.offsetX,t.offsetY))},start:m=>{if(o(),m.touches){const a=m.touches[0];t.startX=a.clientX,t.startY=a.clientY}else t.startX=m.clientX,t.startY=m.clientY;t.startTime=Date.now()},reset:o,isVertical:e,isHorizontal:n,state:t}}function H(t){return t===window}const G=t=>{const e=s.unref(t);if(H(e)){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},J=(t,e,n)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const o=document.createEvent("Events");let i=!0,d=!0;for(let a in e)a==="bubbles"?i=!!e[a]:a==="cancelable"?d=!!e[a]:o[a]=e[a];o.initEvent(t,i,d),(n??document).dispatchEvent(o)},K=15,Q=300,Z=200;function tt(t){t.stopPropagation()}function et(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function P(t,e=0,n,o=Z){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function A(t){t.style.transition="",t.style.transform=""}const nt=/^matrix\((.+)\)$/;function C(t){let e=0;const n=t,{transform:o}=window.getComputedStyle(n);if(o){const i=nt.exec(o);i&&(e=+i[1].split(/,\s*/)[4])}return e}const X=new WeakMap;function ot(t,e,n,o,i,d=600,m=60){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},x=t.previousSibling,f=V(),g=(_,h,c,w)=>{let v=h+a.startDistance;if(c==="end"){const D=G(_);let l=D.width*e;v<l?v=0:v=D.width,a.transitionEndTrigger=()=>{a.moving=!1,i&&_.classList.remove(i),setTimeout(()=>{x&&A(x),v==0?A(_):J(b.FoxLeaveEnd,{},_),a.moving=!1},m)},x&&P(x,0,"",0),v>0&&typeof o=="function"&&o(),P(_,v,"end",w)}else v<0&&(v=0),P(_,v,"",0)},y=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},r=_=>{f.start(_),a.scrollDistance=0,a.moving&&(a.scrollDistance=C(t)),i&&t.classList.add(i),a.transitionEndTrigger=null,a.moving=!0},p=_=>{a.moving=!0,f.move(_),!(f.isVertical()||C(t)===0&&f.state.deltaX<0)&&(tt(_),g(t,f.state.deltaX,"",0))},u=()=>{if(f.isVertical()||C(t)===0&&f.state.deltaX<0)return;const h=f.state.deltaX;if(h===0){i&&t.classList.remove(i),a.moving=!1;return}const c=f.state.duration;if(c<Q&&Math.abs(h)>K){const v=et(h,c,n);g(t,v,"end",d)}else g(t,h,"end",d)};t.addEventListener("transitionend",y),t.addEventListener("touchstart",r),t.addEventListener("touchmove",p),t.addEventListener("touchend",u),t.addEventListener("touchcancel",u),X.set(t,{state:a,transitionend:y,touchstart:r,touchmove:p,touchend:u,touchcancel:u})}function it(t){const e=X.get(t);e&&(X.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 st=s.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},resetDelay:{default:120},swipeDuration:{default:60},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let n=null,o=null;function i(r){return(r.params&&r.params.animationType)??"slide"}function d(r){return(r.params&&r.params.dragRemove)??e.dragRemove}const m=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"show":"enter";if(c==="show"&&(h==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;c==="enter"&&(n=u,o="enter");const w=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-active`;r.classList.add(w),r.classList.add(v)}},a=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"show":"enter";if(c==="show"&&(h==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;const w=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-to`;r.classList.remove(w),r.classList.add(v)}},x=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const c=i(u),w=p?"show":"enter";if(w==="enter"&&(n=null,o=null),c!=="pop"){const v=`fox-root-navigator__${c}-${w}-active`,D=`fox-root-navigator__${c}-${w}-to`;r.classList.remove(v),r.classList.remove(D)}}d(u)===!0&&!p&&u.opsType===b.OperationType.Append&&ot(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,"fox-root-navigator__item-moving",e.swipeDuration,e.resetDelay)},f=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"hide":"leave";if(c==="hide"&&(h==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;c==="leave"&&(n=u,o="leave");const w=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-active`;r.classList.add(w),r.classList.add(v)}},g=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"hide":"leave";if(c==="hide"&&(h==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;const w=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-to`;r.classList.remove(w),r.classList.add(v)}},y=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const c=i(u),w=p?"hide":"leave";if(w==="leave"&&(n=null,o=null),c!=="pop"){const v=`fox-root-navigator__${c}-${w}-active`,D=`fox-root-navigator__${c}-${w}-to`;r.classList.remove(v),r.classList.remove(D)}}d(u)&&!p&&it(r)};return(r,p)=>{const u=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(u,{class:"fox-root-navigator","view-class":r.viewClass,"before-enter":m,enter:a,"after-enter":x,"before-leave":f,leave:g,"after-leave":y,multi:!0,name:r.routerViewName,"view-tag":r.viewTag,transition:r.transition},null,8,["view-class","name","view-tag","transition"])}}}),at=Object.freeze(Object.defineProperty({__proto__:null,default:st},Symbol.toStringTag,{value:"Module"})),rt={class:"fox-swiper-navigator"},ct=s.defineComponent({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,n=s.computed(()=>{const o={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(o["transition-duration"]=`${e.scrollDuration}ms`),o});return(o,i)=>(s.openBlock(),s.createElementBlock("div",rt,[s.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:s.normalizeStyle(n.value)},[s.renderSlot(o.$slots,"default")],4)]))}});let lt=0;function ut(){return++lt}const dt=15,ft=300,ht=200;function mt(t){t.stopPropagation()}function pt(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function I(t,e=0,n,o=ht){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}class vt{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,o,i,d,m){this.getStartDistance=e,this.openPage=n,this.isPageOpened=o,this.pageOpened=i,this.moveRatio=d,this.momentumReduceRatio=m}open(){const e=this.el,n=V(),o=(i,d,m,a)=>{let x=d+this.startDistance;const f=this.columnWidth*this.moveRatio;if(m==="end"){if(d==0){this.moving=!1;return}Math.abs(d)>f?d>0?x=this.startDistance+this.columnWidth:x=this.startDistance-this.columnWidth:x=this.startDistance;let g=-x;g<0?g=0:g>this.width-this.columnWidth&&(g=this.width-this.columnWidth);const y=Math.floor(g/this.columnWidth);this.isPageOpened(y)||this.openPage(y),x=-y*this.columnWidth,a&&a>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(y)}),I(i,x,"end",a),this.scrollDistance=x}else{if(Math.abs(d)>f){let y=0;if(d>0?y=Math.abs(this.startDistance+this.columnWidth):y=Math.abs(this.startDistance-this.columnWidth),y>=0&&y<this.width){const r=Math.floor(y/this.columnWidth);this.isPageOpened(r)||this.openPage(r)}}let g=-x;g<this.min?g=this.min:g>this.max&&(g=this.max),I(i,-g,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=i=>{this.moving||(n.start(i),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=i=>{n.move(i),!n.isVertical()&&(mt(i),o(e,n.state.deltaX,"",0))},this.touchend=()=>{if(n.isVertical())return;const i=n.state.deltaX;if(i==0)return;const d=n.state.duration;if(d<ft&&Math.abs(i)>dt){const a=pt(i,d,this.momentumReduceRatio);o(e,a,"end",this.swipeDuration)}else o(e,i,"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 gt(t,e,n,o,i,d){return new vt(t,e,n,o,i,d)}function _t(t){const e=s.unref(t),n=window.getComputedStyle(e,null),o=parseFloat(n.getPropertyValue("padding-left")),i=parseFloat(n.getPropertyValue("padding-right")),d=parseFloat(n.getPropertyValue("padding-top")),m=parseFloat(n.getPropertyValue("padding-bottom"));return{width:e.clientWidth-o-i,height:e.clientHeight-d-m}}const wt=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 n=t,o=s.reactive({scrollDistance:0,index:-1,openedIndexList:[],width:n.width,height:n.height}),i=e,d=()=>o.scrollDistance,m=l=>{if(o.openedIndexList.indexOf(l)===-1){o.openedIndexList.push(l);const E=n.routes[l];try{n.openViewPage(E,l)}catch(T){console.error(T)}}},a=l=>o.openedIndexList.indexOf(l)!==-1,x=l=>{o.index=l,o.width>0?o.scrollDistance=-o.index*o.width:o.scrollDistance=0;const E=n.routes[l];i("update:activePath",E.path)};let f=null;n.draggable&&(f=gt(d,m,a,x,n.moveRatio,n.momentumReduceRatio));let g=null;s.onMounted(()=>{const l=h(),E=()=>{const T=_t(l);y(n.activePath,n.routes,T.width,T.height,n.swipeDuration,n.direction)};if(window.ResizeObserver&&(g=new window.ResizeObserver(E),g.observe(l)),E(),f){const T=w();f.el=T,f.open()}}),s.onBeforeUnmount(()=>{g&&(g.disconnect(),g=null),f&&f.close()}),s.watch([()=>n.activePath,()=>n.routes,()=>n.width,()=>n.height,()=>n.swipeDuration,()=>n.direction],([l,E,T,$,M,R])=>{const O=T<=0?o.width:T,L=$<=0?o.height:$;y(l,E,O,L,M,R)});const y=(l,E,T,$,M,R="horizontal")=>{const O=l;if(o.index=E.findIndex(L=>L.path===O),R==="horizontal"){const L=T;if(L>0){o.width=T;const z=L*n.routes.length,W=-L/3,N=L*(E.length-1)+L/3;f&&(f.columnWidth=L,f.width=z,f.min=W,f.max=N),o.index!==-1&&(o.openedIndexList.push(o.index),o.scrollDistance=-L*o.index)}}f&&(f.swipeDuration=M)},r=`fox-swiper-navigator-${ut()}`,p=s.computed(()=>{const l=[r];return n.customClass&&l.push(n.customClass),l}),u=s.computed(()=>{const l={},E=o.width>0?o.width:n.width;E>0&&(l.width=`${E}px`);const T=o.height>0?o.height:n.height;return T>0&&(l.height=`${T}px`),n.customStyle&&Object.assign(l,n.customStyle),l});let _=null;function h(){return _||(_=document.querySelector(`.${r}`),_)}let c=null;function w(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const v=s.computed(()=>o.width>0?`${o.width*n.routes.length}px`:"100%"),D=(l,E)=>{const T=n.routes.findIndex($=>{const M=l.path??l.name??"";return $.path==M});return o.width<=0?{}:{style:{left:`${T*o.width}px`,width:`${o.width}px`}}};return(l,E)=>{const T=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(T,{class:s.normalizeClass(p.value),style:s.normalizeStyle(u.value),"view-class":"fox-swiper-navigator__item",tag:ct,"view-tag-props":D,multi:!0,name:l.routerViewName,transition:l.transition,"scroll-distance":o.scrollDistance,"scroll-duration":l.scrollDuration,direction:l.direction,width:v.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),Tt=Object.freeze(Object.defineProperty({__proto__:null,default:wt},Symbol.toStringTag,{value:"Module"}));let yt="fox-";const xt=[],B=Object.assign({"/src/components/card-navigator/index.vue":F,"/src/components/default-navigator/index.vue":j,"/src/components/root-navigator/index.vue":at,"/src/components/swiper-navigator/index.vue":Tt}),Y=[];for(const t in B){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];xt.indexOf(e)===-1&&Y.push({name:e,component:B[t].default})}const Et={install(t){Y.forEach(e=>{t.component(`${yt}${e.name}`,e.component)})}};module.exports=Et;
|
|
2
|
+
* @fox-js/navigation v4.0.1-15 Sat Jun 15 2024 16:18:22 GMT+0800 (中国标准时间)
|
|
3
|
+
*/const r=require("vue"),L=require("@fox-js/fox"),k=r.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,n)=>{const o=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(o,{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"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),U=r.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,n)=>{const o=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(o,{transition:!1,multi:!1,name:e.routerViewName},{default:r.withCtx(({Component:i})=>[r.createVNode(r.Transition,{name:"fox-default-navigator__trans"},{default:r.withCtx(()=>[(r.openBlock(),r.createBlock(r.resolveDynamicComponent(i)))]),_:2},1024)]),_:1},8,["name"])}}}),j=Object.freeze(Object.defineProperty({__proto__:null,default:U},Symbol.toStringTag,{value:"Module"})),C=10;function q(t,e){return t>e&&t>C?"horizontal":e>t&&e>C?"vertical":""}function B(){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",n=()=>t.direction==="horizontal",o=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:p=>{if(p.touches){const m=p.touches[0];t.deltaX=m.clientX-t.startX,t.deltaY=m.clientY-t.startY,t.moveX=m.clientX,t.moveY=m.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=q(t.offsetX,t.offsetY))},start:p=>{if(o(),p.touches){const m=p.touches[0];t.startX=m.clientX,t.startY=m.clientY}else t.startX=p.clientX,t.startY=p.clientY;t.startTime=Date.now()},reset:o,isVertical:e,isHorizontal:n,state:t}}function H(t){return t===window}const G=t=>{const e=r.unref(t);if(H(e)){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},J=(t,e,n)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const o=document.createEvent("Events");let i=!0,h=!0;for(let m in e)m==="bubbles"?i=!!e[m]:m==="cancelable"?h=!!e[m]:o[m]=e[m];o.initEvent(t,i,h),(n??document).dispatchEvent(o)},K=15,Q=300,Z=200;function tt(t){t.stopPropagation()}function et(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function A(t,e=0,n,o=Z){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function S(t){t.style.transition="",t.style.transform=""}const nt=/^matrix\((.+)\)$/;function P(t){let e=0;const n=t,{transform:o}=window.getComputedStyle(n);if(o){const i=nt.exec(o);i&&(e=+i[1].split(/,\s*/)[4])}return e}const X=new WeakMap;function ot(t,e,n,o,i,h=600,p=60,m=null){const l={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},_=t.previousSibling,u=B(),y=(d,a,v,E)=>{let w=a+l.startDistance;if(v==="end"){const c=G(d);let T=c.width*e;w<T?w=0:w=c.width,l.transitionEndTrigger=()=>{l.moving=!1,i&&d.classList.remove(i),setTimeout(()=>{_&&S(_),w==0?S(d):J(L.FoxLeaveEnd,{},d),l.moving=!1},p)},_&&A(_,0,"",0),w>0&&typeof o=="function"&&o(),A(d,w,"end",E)}else w<0&&(w=0),A(d,w,"",0)},s=()=>{l.transitionEndTrigger&&(l.transitionEndTrigger(),l.transitionEndTrigger=null)},g=d=>{if(u.start(d),l.draging=m?m(t,u.state.startX,u.state.startY):!0,!l.draging){u.reset();return}l.scrollDistance=0,l.moving&&(l.scrollDistance=P(t)),i&&t.classList.add(i),l.transitionEndTrigger=null,l.moving=!0},f=d=>{!l.draging||(l.moving=!0,u.move(d),u.isVertical())||P(t)===0&&u.state.deltaX<0||(tt(d),y(t,u.state.deltaX,"",0))},b=()=>{if(!l.draging||(l.draging=!1,u.isVertical())||P(t)===0&&u.state.deltaX<0)return;const a=u.state.deltaX;if(a===0){i&&t.classList.remove(i),l.moving=!1;return}const v=u.state.duration;if(v<Q&&Math.abs(a)>K){const w=et(a,v,n);y(t,w,"end",h)}else y(t,a,"end",h)};t.addEventListener("transitionend",s),t.addEventListener("transitioncancel",s),t.addEventListener("touchstart",g),t.addEventListener("touchmove",f),t.addEventListener("touchend",b),t.addEventListener("touchcancel",b),X.set(t,{state:l,transitionend:s,transitioncancel:s,touchstart:g,touchmove:f,touchend:b,touchcancel:b})}function it(t){const e=X.get(t);e&&(X.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("transitioncancel",e.transitioncancel),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const st=r.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},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let n=null,o=null;function i(s){return(s.params&&s.params.animationType)??"slide"}function h(s){return(s.params&&s.params.dragRemove)??e.dragRemove}const p=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"show":"enter";if(a==="show"&&(d==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;a==="enter"&&(n=f,o="enter");const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-active`;s.classList.add(v),s.classList.add(E)}},m=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"show":"enter";if(a==="show"&&(d==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-to`;s.classList.remove(v),s.classList.add(E)}},l=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const a=i(f),v=g?"show":"enter";if(v==="enter"&&(n=null,o=null),a!=="pop"){const E=`fox-root-navigator__${a}-${v}-active`,w=`fox-root-navigator__${a}-${v}-to`;s.classList.remove(E),s.classList.remove(w)}}if(h(f)===!0&&!g&&f.opsType===L.OperationType.Append){let a=null;e.draggableArea&&(a=function(v,E,w){const c=E-v.offsetLeft,T=w-v.offsetTop;return!(e.draggableArea?.left&&c<e.draggableArea?.left||e.draggableArea?.right&&c>e.draggableArea?.right||e.draggableArea?.top&&T<e.draggableArea?.top||e.draggableArea?.bottom&&T>e.draggableArea?.bottom)}),ot(s,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,"fox-root-navigator__item-moving",e.swipeDuration,e.resetDelay,a)}},_=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"hide":"leave";if(a==="hide"&&(d==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;a==="leave"&&(n=f,o="leave");const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-active`;s.classList.add(v),s.classList.add(E)}},u=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"hide":"leave";if(a==="hide"&&(d==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-to`;s.classList.remove(v),s.classList.add(E)}},y=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const a=i(f),v=g?"hide":"leave";if(v==="leave"&&(n=null,o=null),a!=="pop"){const E=`fox-root-navigator__${a}-${v}-active`,w=`fox-root-navigator__${a}-${v}-to`;s.classList.remove(E),s.classList.remove(w)}}h(f)&&!g&&it(s)};return(s,g)=>{const f=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(f,{class:"fox-root-navigator","view-class":s.viewClass,"before-enter":p,enter:m,"after-enter":l,"before-leave":_,leave:u,"after-leave":y,multi:!0,name:s.routerViewName,"view-tag":s.viewTag,transition:s.transition},null,8,["view-class","name","view-tag","transition"])}}}),at=Object.freeze(Object.defineProperty({__proto__:null,default:st},Symbol.toStringTag,{value:"Module"})),rt={class:"fox-swiper-navigator"},ct=r.defineComponent({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,n=r.computed(()=>{const o={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(o["transition-duration"]=`${e.scrollDuration}ms`),o});return(o,i)=>(r.openBlock(),r.createElementBlock("div",rt,[r.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:r.normalizeStyle(n.value)},[r.renderSlot(o.$slots,"default")],4)]))}});let lt=0;function ut(){return++lt}const dt=15,ft=300,ht=200;function mt(t){t.stopPropagation()}function pt(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function I(t,e=0,n,o=ht){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}class gt{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,o,i,h,p){this.getStartDistance=e,this.openPage=n,this.isPageOpened=o,this.pageOpened=i,this.moveRatio=h,this.momentumReduceRatio=p}open(){const e=this.el,n=B(),o=(i,h,p,m)=>{let l=h+this.startDistance;const _=this.columnWidth*this.moveRatio;if(p==="end"){if(h==0){this.moving=!1;return}Math.abs(h)>_?h>0?l=this.startDistance+this.columnWidth:l=this.startDistance-this.columnWidth:l=this.startDistance;let u=-l;u<0?u=0:u>this.width-this.columnWidth&&(u=this.width-this.columnWidth);const y=Math.floor(u/this.columnWidth);this.isPageOpened(y)||this.openPage(y),l=-y*this.columnWidth,m&&m>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(y)}),I(i,l,"end",m),this.scrollDistance=l}else{if(Math.abs(h)>_){let y=0;if(h>0?y=Math.abs(this.startDistance+this.columnWidth):y=Math.abs(this.startDistance-this.columnWidth),y>=0&&y<this.width){const s=Math.floor(y/this.columnWidth);this.isPageOpened(s)||this.openPage(s)}}let u=-l;u<this.min?u=this.min:u>this.max&&(u=this.max),I(i,-u,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=i=>{this.moving||(n.start(i),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=i=>{n.move(i),!n.isVertical()&&(mt(i),o(e,n.state.deltaX,"",0))},this.touchend=()=>{if(n.isVertical())return;const i=n.state.deltaX;if(i==0)return;const h=n.state.duration;if(h<ft&&Math.abs(i)>dt){const m=pt(i,h,this.momentumReduceRatio);o(e,m,"end",this.swipeDuration)}else o(e,i,"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 vt(t,e,n,o,i,h){return new gt(t,e,n,o,i,h)}function _t(t){const e=r.unref(t),n=window.getComputedStyle(e,null),o=parseFloat(n.getPropertyValue("padding-left")),i=parseFloat(n.getPropertyValue("padding-right")),h=parseFloat(n.getPropertyValue("padding-top")),p=parseFloat(n.getPropertyValue("padding-bottom"));return{width:e.clientWidth-o-i,height:e.clientHeight-h-p}}const wt=r.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 n=t,o=r.reactive({scrollDistance:0,index:-1,openedIndexList:[],width:n.width,height:n.height}),i=e,h=()=>o.scrollDistance,p=c=>{if(o.openedIndexList.indexOf(c)===-1){o.openedIndexList.push(c);const T=n.routes[c];try{n.openViewPage(T,c)}catch(x){console.error(x)}}},m=c=>o.openedIndexList.indexOf(c)!==-1,l=c=>{o.index=c,o.width>0?o.scrollDistance=-o.index*o.width:o.scrollDistance=0;const T=n.routes[c];i("update:activePath",T.path)};let _=null;n.draggable&&(_=vt(h,p,m,l,n.moveRatio,n.momentumReduceRatio));let u=null;r.onMounted(()=>{const c=d(),T=()=>{const x=_t(c);y(n.activePath,n.routes,x.width,x.height,n.swipeDuration,n.direction)};if(window.ResizeObserver&&(u=new window.ResizeObserver(T),u.observe(c)),T(),_){const x=v();_.el=x,_.open()}}),r.onBeforeUnmount(()=>{u&&(u.disconnect(),u=null),_&&_.close()}),r.watch([()=>n.activePath,()=>n.routes,()=>n.width,()=>n.height,()=>n.swipeDuration,()=>n.direction],([c,T,x,$,M,R])=>{const O=x<=0?o.width:x,D=$<=0?o.height:$;y(c,T,O,D,M,R)});const y=(c,T,x,$,M,R="horizontal")=>{const O=c;if(o.index=T.findIndex(D=>D.path===O),R==="horizontal"){const D=x;if(D>0){o.width=x;const z=D*n.routes.length,W=-D/3,N=D*(T.length-1)+D/3;_&&(_.columnWidth=D,_.width=z,_.min=W,_.max=N),o.index!==-1&&(o.openedIndexList.push(o.index),o.scrollDistance=-D*o.index)}}_&&(_.swipeDuration=M)},s=`fox-swiper-navigator-${ut()}`,g=r.computed(()=>{const c=[s];return n.customClass&&c.push(n.customClass),c}),f=r.computed(()=>{const c={},T=o.width>0?o.width:n.width;T>0&&(c.width=`${T}px`);const x=o.height>0?o.height:n.height;return x>0&&(c.height=`${x}px`),n.customStyle&&Object.assign(c,n.customStyle),c});let b=null;function d(){return b||(b=document.querySelector(`.${s}`),b)}let a=null;function v(){return a||(a=document.querySelector(`.${s}>.fox-swiper-navigator__inner`),a)}const E=r.computed(()=>o.width>0?`${o.width*n.routes.length}px`:"100%"),w=(c,T)=>{const x=n.routes.findIndex($=>{const M=c.path??c.name??"";return $.path==M});return o.width<=0?{}:{style:{left:`${x*o.width}px`,width:`${o.width}px`}}};return(c,T)=>{const x=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(x,{class:r.normalizeClass(g.value),style:r.normalizeStyle(f.value),"view-class":"fox-swiper-navigator__item",tag:ct,"view-tag-props":w,multi:!0,name:c.routerViewName,transition:c.transition,"scroll-distance":o.scrollDistance,"scroll-duration":c.scrollDuration,direction:c.direction,width:E.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),Tt=Object.freeze(Object.defineProperty({__proto__:null,default:wt},Symbol.toStringTag,{value:"Module"}));let yt="fox-";const xt=[],Y=Object.assign({"/src/components/card-navigator/index.vue":F,"/src/components/default-navigator/index.vue":j,"/src/components/root-navigator/index.vue":at,"/src/components/swiper-navigator/index.vue":Tt}),V=[];for(const t in Y){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];xt.indexOf(e)===-1&&V.push({name:e,component:Y[t].default})}const Et={install(t){V.forEach(e=>{t.component(`${yt}${e.name}`,e.component)})}};module.exports=Et;
|