@fox-js/navigation 4.0.1-1 → 4.0.1-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +41 -2
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.esm.js +497 -283
- package/dist/index.umd.js +3 -3
- package/dist/style.css +1 -1
- package/package.json +12 -15
package/dist/index.esm.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as P, resolveComponent as S, openBlock as L, createBlock as R, withCtx as C, createVNode as H, Transition as G, resolveDynamicComponent as J, unref as N, computed as O, createElementBlock as K, createElementVNode as Q, normalizeStyle as B, renderSlot as Z, reactive as tt, onMounted as et, onBeforeUnmount as nt, watch as ot, normalizeClass as it } from "vue";
|
|
2
|
+
import { OperationType as b } from "@fox-js/fox";
|
|
2
3
|
/*!
|
|
3
|
-
* @fox-js/navigation v4.0.1-
|
|
4
|
+
* @fox-js/navigation v4.0.1-10 Tue Mar 12 2024 21:40:43 GMT+0800 (中国标准时间)
|
|
4
5
|
*/
|
|
5
|
-
const
|
|
6
|
+
const st = /* @__PURE__ */ P({
|
|
6
7
|
__name: "index",
|
|
7
8
|
props: {
|
|
8
|
-
routerViewName:
|
|
9
|
-
transition: { type: [
|
|
9
|
+
routerViewName: {},
|
|
10
|
+
transition: { type: [Function, Boolean], default: !1 }
|
|
10
11
|
},
|
|
11
12
|
setup(t) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return y(), M(a, {
|
|
13
|
+
return (e, n) => {
|
|
14
|
+
const o = S("fox-router-view");
|
|
15
|
+
return L(), R(o, {
|
|
16
16
|
class: "fox-card-navigator",
|
|
17
17
|
"view-class": "fox-card-navigator__item",
|
|
18
18
|
"view-active-class": "fox-card-navigator__item-active",
|
|
@@ -24,56 +24,95 @@ const Y = /* @__PURE__ */ T({
|
|
|
24
24
|
}, null, 8, ["transition", "name"]);
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
})
|
|
28
|
-
|
|
27
|
+
}), at = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
28
|
+
__proto__: null,
|
|
29
|
+
default: st
|
|
30
|
+
}, Symbol.toStringTag, { value: "Module" })), rt = /* @__PURE__ */ P({
|
|
31
|
+
__name: "index",
|
|
32
|
+
props: {
|
|
33
|
+
routerViewName: {},
|
|
34
|
+
transition: { type: [Function, Boolean], default: !0 }
|
|
35
|
+
},
|
|
36
|
+
setup(t) {
|
|
37
|
+
return (e, n) => {
|
|
38
|
+
const o = S("fox-router-view");
|
|
39
|
+
return L(), R(o, {
|
|
40
|
+
transition: !1,
|
|
41
|
+
multi: !1,
|
|
42
|
+
name: e.routerViewName
|
|
43
|
+
}, {
|
|
44
|
+
default: C(({ Component: a }) => [
|
|
45
|
+
H(G, { name: "fox-default-navigator__trans" }, {
|
|
46
|
+
default: C(() => [
|
|
47
|
+
(L(), R(J(a)))
|
|
48
|
+
]),
|
|
49
|
+
_: 2
|
|
50
|
+
}, 1024)
|
|
51
|
+
]),
|
|
52
|
+
_: 1
|
|
53
|
+
}, 8, ["name"]);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}), ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
29
57
|
__proto__: null,
|
|
30
|
-
default:
|
|
31
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
32
|
-
function
|
|
33
|
-
return t > e && t >
|
|
58
|
+
default: rt
|
|
59
|
+
}, Symbol.toStringTag, { value: "Module" })), Y = 10;
|
|
60
|
+
function lt(t, e) {
|
|
61
|
+
return t > e && t > Y ? "horizontal" : e > t && e > Y ? "vertical" : "";
|
|
34
62
|
}
|
|
35
|
-
function
|
|
36
|
-
const t =
|
|
37
|
-
|
|
63
|
+
function F() {
|
|
64
|
+
const t = {
|
|
65
|
+
startX: 0,
|
|
66
|
+
startY: 0,
|
|
67
|
+
startTime: 0,
|
|
68
|
+
duration: 0,
|
|
69
|
+
moveX: 0,
|
|
70
|
+
moveY: 0,
|
|
71
|
+
deltaX: 0,
|
|
72
|
+
deltaY: 0,
|
|
73
|
+
offsetX: 0,
|
|
74
|
+
offsetY: 0,
|
|
75
|
+
direction: ""
|
|
76
|
+
}, e = () => t.direction === "vertical", n = () => t.direction === "horizontal", o = () => {
|
|
77
|
+
t.deltaX = 0, t.deltaY = 0, t.offsetX = 0, t.offsetY = 0, t.direction = "", t.startTime = 0;
|
|
38
78
|
};
|
|
39
79
|
return {
|
|
40
|
-
move: (
|
|
41
|
-
|
|
42
|
-
|
|
80
|
+
move: (h) => {
|
|
81
|
+
if (h.touches) {
|
|
82
|
+
const c = h.touches[0];
|
|
83
|
+
t.deltaX = c.clientX - t.startX, t.deltaY = c.clientY - t.startY, t.moveX = c.clientX, t.moveY = c.clientY;
|
|
84
|
+
} else
|
|
85
|
+
t.deltaX = h.clientX - t.startX, t.deltaY = h.clientY - t.startY, t.moveX = h.clientX, t.moveY = h.clientY;
|
|
86
|
+
t.offsetX = Math.abs(t.deltaX), t.offsetY = Math.abs(t.deltaY), t.duration = Date.now() - t.startTime, t.direction || (t.direction = lt(t.offsetX, t.offsetY));
|
|
43
87
|
},
|
|
44
|
-
start: (
|
|
45
|
-
|
|
88
|
+
start: (h) => {
|
|
89
|
+
if (o(), h.touches) {
|
|
90
|
+
const c = h.touches[0];
|
|
91
|
+
t.startX = c.clientX, t.startY = c.clientY;
|
|
92
|
+
} else
|
|
93
|
+
t.startX = h.clientX, t.startY = h.clientY;
|
|
94
|
+
t.startTime = Date.now();
|
|
46
95
|
},
|
|
47
|
-
reset:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
duration: s,
|
|
52
|
-
moveX: a,
|
|
53
|
-
moveY: v,
|
|
54
|
-
deltaX: p,
|
|
55
|
-
deltaY: m,
|
|
56
|
-
offsetX: d,
|
|
57
|
-
offsetY: c,
|
|
58
|
-
direction: o,
|
|
59
|
-
isVertical: i,
|
|
60
|
-
isHorizontal: h
|
|
96
|
+
reset: o,
|
|
97
|
+
isVertical: e,
|
|
98
|
+
isHorizontal: n,
|
|
99
|
+
state: t
|
|
61
100
|
};
|
|
62
101
|
}
|
|
63
|
-
function
|
|
102
|
+
function ut(t) {
|
|
64
103
|
return t === window;
|
|
65
104
|
}
|
|
66
|
-
const
|
|
67
|
-
const e =
|
|
68
|
-
if (
|
|
69
|
-
const n = e.innerWidth,
|
|
105
|
+
const dt = (t) => {
|
|
106
|
+
const e = N(t);
|
|
107
|
+
if (ut(e)) {
|
|
108
|
+
const n = e.innerWidth, o = e.innerHeight;
|
|
70
109
|
return {
|
|
71
110
|
top: 0,
|
|
72
111
|
left: 0,
|
|
73
112
|
right: n,
|
|
74
|
-
bottom:
|
|
113
|
+
bottom: o,
|
|
75
114
|
width: n,
|
|
76
|
-
height:
|
|
115
|
+
height: o
|
|
77
116
|
};
|
|
78
117
|
}
|
|
79
118
|
return e && e.getBoundingClientRect ? e.getBoundingClientRect() : {
|
|
@@ -84,253 +123,359 @@ const H = (t) => {
|
|
|
84
123
|
width: 0,
|
|
85
124
|
height: 0
|
|
86
125
|
};
|
|
87
|
-
},
|
|
88
|
-
function
|
|
126
|
+
}, ft = 15, ht = 300, mt = 200;
|
|
127
|
+
function pt(t) {
|
|
89
128
|
t.stopPropagation();
|
|
90
129
|
}
|
|
91
|
-
function
|
|
92
|
-
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e &&
|
|
130
|
+
function gt(t, e) {
|
|
131
|
+
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && pt(t);
|
|
93
132
|
}
|
|
94
|
-
function
|
|
95
|
-
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t;
|
|
133
|
+
function vt(t, e, n = 1) {
|
|
134
|
+
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t * n;
|
|
96
135
|
}
|
|
97
|
-
function
|
|
98
|
-
n === "end" ? t.style.transition = `transform ${
|
|
136
|
+
function I(t, e = 0, n, o = mt) {
|
|
137
|
+
n === "end" ? t.style.transition = `transform ${o}ms cubic-bezier(0.17, 0.89, 0.45, 1)` : t.style.transition = "transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)", t.style.transform = `translate3d(${e}px, 0, 0)`;
|
|
99
138
|
}
|
|
100
|
-
const
|
|
101
|
-
function
|
|
102
|
-
const
|
|
139
|
+
const V = /* @__PURE__ */ new WeakMap();
|
|
140
|
+
function _t(t, e, n, o, a = 500, d, h = 1e3) {
|
|
141
|
+
const c = {
|
|
103
142
|
active: !0,
|
|
104
143
|
startDistance: 0,
|
|
105
144
|
scrollDistance: 0,
|
|
106
145
|
scrollTime: 0,
|
|
107
146
|
moving: !1,
|
|
108
147
|
transitionEndTrigger: null
|
|
109
|
-
}, v = t.previousSibling,
|
|
110
|
-
let
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
113
|
-
let
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
148
|
+
}, v = t.previousSibling, m = F(), p = (s, g, w, x) => {
|
|
149
|
+
let T = g + c.startDistance;
|
|
150
|
+
if (w === "end") {
|
|
151
|
+
const r = dt(s);
|
|
152
|
+
let y = r.width * e;
|
|
153
|
+
T < y ? T = 0 : T = r.width;
|
|
154
|
+
let _ = !1;
|
|
155
|
+
x && x > 0 && (_ = !0, c.transitionEndTrigger = () => {
|
|
156
|
+
c.moving = !1, d && s.classList.remove(d), T > 0 && typeof o == "function" && o();
|
|
157
|
+
}), I(s, T, "end", x), v && I(v, 0, "", 0), !_ && T > 0 && typeof o == "function" && (c.moving = !1, o());
|
|
117
158
|
} else
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
t.style.transform = "", t.style.transition = "",
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
159
|
+
T < 0 && (T = 0), I(s, T, "", 0);
|
|
160
|
+
}, i = () => {
|
|
161
|
+
t.style.transform = "", t.style.transition = "", c.transitionEndTrigger ? (c.transitionEndTrigger(), c.transitionEndTrigger = null, v && setTimeout(() => {
|
|
162
|
+
v && (v.style.transform = "", v.style.transition = "");
|
|
163
|
+
}, a)) : v && (v.style.transform = "", v.style.transition = "");
|
|
164
|
+
}, u = /^matrix\((.+)\)$/, f = (s) => {
|
|
165
|
+
if (m.start(s), c.scrollDistance = 0, c.moving) {
|
|
166
|
+
const g = t, { transform: w } = window.getComputedStyle(g);
|
|
167
|
+
if (w) {
|
|
168
|
+
const x = u.exec(w);
|
|
169
|
+
if (x) {
|
|
170
|
+
const r = x[1].split(/,\s*/);
|
|
171
|
+
c.scrollDistance = +r[4];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
125
174
|
}
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
|
|
175
|
+
d && t.classList.add(d), c.startDistance = c.scrollDistance, c.transitionEndTrigger = null, c.moving = !0;
|
|
176
|
+
}, E = (s) => {
|
|
177
|
+
c.moving = !0, m.move(s), !m.isVertical() && (gt(s, !0), p(t, m.state.deltaX, "", 0));
|
|
178
|
+
}, l = () => {
|
|
179
|
+
if (m.isVertical()) {
|
|
180
|
+
p(t, 0, "end", h);
|
|
130
181
|
return;
|
|
131
182
|
}
|
|
132
|
-
m
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (h == 0) {
|
|
136
|
-
n && t.classList.remove(n);
|
|
183
|
+
const s = m.state.deltaX;
|
|
184
|
+
if (s === 0) {
|
|
185
|
+
d && t.classList.remove(d), c.moving = !1;
|
|
137
186
|
return;
|
|
138
187
|
}
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
const
|
|
142
|
-
|
|
188
|
+
const g = m.state.duration;
|
|
189
|
+
if (g < ht && Math.abs(s) > ft) {
|
|
190
|
+
const x = vt(s, g, n);
|
|
191
|
+
p(t, x, "end", h);
|
|
143
192
|
} else
|
|
144
|
-
|
|
193
|
+
p(t, s, "end", h);
|
|
145
194
|
};
|
|
146
|
-
t.addEventListener("transitionend",
|
|
147
|
-
state:
|
|
148
|
-
transitionend:
|
|
149
|
-
touchstart:
|
|
150
|
-
touchmove:
|
|
151
|
-
touchend:
|
|
152
|
-
touchcancel:
|
|
195
|
+
t.addEventListener("transitionend", i), t.addEventListener("touchstart", f), t.addEventListener("touchmove", E), t.addEventListener("touchend", l), t.addEventListener("touchcancel", l), V.set(t, {
|
|
196
|
+
state: c,
|
|
197
|
+
transitionend: i,
|
|
198
|
+
touchstart: f,
|
|
199
|
+
touchmove: E,
|
|
200
|
+
touchend: l,
|
|
201
|
+
touchcancel: l
|
|
153
202
|
});
|
|
154
203
|
}
|
|
155
|
-
function
|
|
156
|
-
const e =
|
|
157
|
-
e && (
|
|
204
|
+
function wt(t) {
|
|
205
|
+
const e = V.get(t);
|
|
206
|
+
e && (V.delete(t), t.addEventListener("transitionend", e.transitionend), t.addEventListener("touchstart", e.touchstart), t.addEventListener("touchmove", e.touchmove), t.addEventListener("touchend", e.touchend), t.addEventListener("touchcancel", e.touchcancel));
|
|
158
207
|
}
|
|
159
|
-
const
|
|
208
|
+
const yt = /* @__PURE__ */ P({
|
|
160
209
|
__name: "index",
|
|
161
210
|
props: {
|
|
162
211
|
dragRemove: { type: Boolean, default: !0 },
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
212
|
+
removeViewPage: {},
|
|
213
|
+
removeMoveRatio: { default: 0.5 },
|
|
214
|
+
momentumReduceRatio: { default: 1 },
|
|
215
|
+
removeViewPageDuration: { default: 500 },
|
|
216
|
+
routerViewName: {},
|
|
217
|
+
viewTag: { type: [Function, String], default: "div" },
|
|
218
|
+
transition: { type: [Function, Boolean], default: !0 },
|
|
219
|
+
viewClass: { type: [Function, String], default: "fox-root-navigator__item" }
|
|
167
220
|
},
|
|
168
221
|
setup(t) {
|
|
169
222
|
const e = t;
|
|
170
|
-
|
|
171
|
-
|
|
223
|
+
let n = null, o = null;
|
|
224
|
+
function a(i) {
|
|
225
|
+
return (i.params && i.params.animationType) ?? "slide";
|
|
172
226
|
}
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
227
|
+
const d = (i, u, f, E) => {
|
|
228
|
+
if (f.opsType === b.Append || u) {
|
|
229
|
+
const l = a(f), s = u ? "show" : "enter";
|
|
230
|
+
if (s === "show" && (l === "pop" || o !== "leave" || (n ? a(n) : "") === "pop"))
|
|
177
231
|
return;
|
|
178
|
-
|
|
179
|
-
|
|
232
|
+
s === "enter" && (n = f, o = "enter");
|
|
233
|
+
const g = `fox-root-navigator__${l}-${s}-from`, w = `fox-root-navigator__${l}-${s}-active`;
|
|
234
|
+
i.classList.add(g), i.classList.add(w);
|
|
180
235
|
}
|
|
181
|
-
},
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
236
|
+
}, h = (i, u, f, E) => {
|
|
237
|
+
if (f.opsType === b.Append || u) {
|
|
238
|
+
const l = a(f), s = u ? "show" : "enter";
|
|
239
|
+
if (s === "show" && (l === "pop" || o !== "leave" || (n ? a(n) : "") === "pop"))
|
|
185
240
|
return;
|
|
186
|
-
const
|
|
187
|
-
|
|
241
|
+
const g = `fox-root-navigator__${l}-${s}-from`, w = `fox-root-navigator__${l}-${s}-to`;
|
|
242
|
+
i.classList.remove(g), i.classList.add(w);
|
|
188
243
|
}
|
|
189
|
-
},
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
193
|
-
const
|
|
194
|
-
|
|
244
|
+
}, c = (i, u, f, E) => {
|
|
245
|
+
if (f.opsType === b.Append || u) {
|
|
246
|
+
const l = a(f), s = u ? "show" : "enter";
|
|
247
|
+
if (s === "enter" && (n = null, o = null), l !== "pop") {
|
|
248
|
+
const g = `fox-root-navigator__${l}-${s}-active`, w = `fox-root-navigator__${l}-${s}-to`;
|
|
249
|
+
i.classList.remove(g), i.classList.remove(w);
|
|
195
250
|
}
|
|
196
251
|
}
|
|
197
|
-
e.dragRemove && !
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
252
|
+
e.dragRemove && !u && f.opsType === b.Append && _t(
|
|
253
|
+
i,
|
|
254
|
+
e.removeMoveRatio,
|
|
255
|
+
e.momentumReduceRatio,
|
|
256
|
+
e.removeViewPage,
|
|
257
|
+
e.removeViewPageDuration,
|
|
258
|
+
"fox-root-navigator__item-moving",
|
|
259
|
+
1e3
|
|
260
|
+
);
|
|
261
|
+
}, v = (i, u, f, E) => {
|
|
262
|
+
if (f.opsType === b.Append || u) {
|
|
263
|
+
const l = a(f), s = u ? "hide" : "leave";
|
|
264
|
+
if (s === "hide" && (l === "pop" || o !== "enter" || (n ? a(n) : "") === "pop"))
|
|
202
265
|
return;
|
|
203
|
-
|
|
204
|
-
|
|
266
|
+
s === "leave" && (n = f, o = "leave");
|
|
267
|
+
const g = `fox-root-navigator__${l}-${s}-from`, w = `fox-root-navigator__${l}-${s}-active`;
|
|
268
|
+
i.classList.add(g), i.classList.add(w);
|
|
205
269
|
}
|
|
206
|
-
}, m = (
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
270
|
+
}, m = (i, u, f, E) => {
|
|
271
|
+
if (f.opsType === b.Append || u) {
|
|
272
|
+
const l = a(f), s = u ? "hide" : "leave";
|
|
273
|
+
if (s === "hide" && (l === "pop" || o !== "enter" || (n ? a(n) : "") === "pop"))
|
|
210
274
|
return;
|
|
211
|
-
const
|
|
212
|
-
|
|
275
|
+
const g = `fox-root-navigator__${l}-${s}-from`, w = `fox-root-navigator__${l}-${s}-to`;
|
|
276
|
+
i.classList.remove(g), i.classList.add(w);
|
|
213
277
|
}
|
|
214
|
-
},
|
|
215
|
-
if (
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
const
|
|
219
|
-
|
|
278
|
+
}, p = (i, u, f, E) => {
|
|
279
|
+
if (f.opsType === b.Append || u) {
|
|
280
|
+
const l = a(f), s = u ? "hide" : "leave";
|
|
281
|
+
if (s === "leave" && (n = null, o = null), l !== "pop") {
|
|
282
|
+
const g = `fox-root-navigator__${l}-${s}-active`, w = `fox-root-navigator__${l}-${s}-to`;
|
|
283
|
+
i.classList.remove(g), i.classList.remove(w);
|
|
220
284
|
}
|
|
221
285
|
}
|
|
222
|
-
e.dragRemove && !
|
|
286
|
+
e.dragRemove && !u && wt(i);
|
|
223
287
|
};
|
|
224
|
-
return (
|
|
225
|
-
const
|
|
226
|
-
return
|
|
288
|
+
return (i, u) => {
|
|
289
|
+
const f = S("fox-router-view");
|
|
290
|
+
return L(), R(f, {
|
|
227
291
|
class: "fox-root-navigator",
|
|
228
|
-
"view-class":
|
|
229
|
-
"before-enter":
|
|
230
|
-
enter:
|
|
231
|
-
"after-enter":
|
|
232
|
-
"before-leave":
|
|
292
|
+
"view-class": i.viewClass,
|
|
293
|
+
"before-enter": d,
|
|
294
|
+
enter: h,
|
|
295
|
+
"after-enter": c,
|
|
296
|
+
"before-leave": v,
|
|
233
297
|
leave: m,
|
|
234
|
-
"after-leave":
|
|
298
|
+
"after-leave": p,
|
|
235
299
|
multi: !0,
|
|
236
|
-
name:
|
|
237
|
-
"view-tag":
|
|
238
|
-
transition:
|
|
239
|
-
}, null, 8, ["name", "view-tag", "transition"]);
|
|
300
|
+
name: i.routerViewName,
|
|
301
|
+
"view-tag": i.viewTag,
|
|
302
|
+
transition: i.transition
|
|
303
|
+
}, null, 8, ["view-class", "name", "view-tag", "transition"]);
|
|
240
304
|
};
|
|
241
305
|
}
|
|
242
|
-
})
|
|
243
|
-
const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
306
|
+
}), xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
244
307
|
__proto__: null,
|
|
245
|
-
default:
|
|
246
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
308
|
+
default: yt
|
|
309
|
+
}, Symbol.toStringTag, { value: "Module" })), Tt = { class: "fox-swiper-navigator" }, Dt = /* @__PURE__ */ P({
|
|
247
310
|
__name: "swiper",
|
|
248
311
|
props: {
|
|
249
|
-
width:
|
|
250
|
-
scrollDistance:
|
|
251
|
-
|
|
312
|
+
width: {},
|
|
313
|
+
scrollDistance: {},
|
|
314
|
+
scrollDuration: {},
|
|
315
|
+
direction: {}
|
|
252
316
|
},
|
|
253
317
|
setup(t) {
|
|
254
|
-
const e = t, n =
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
318
|
+
const e = t, n = O(() => {
|
|
319
|
+
const o = {
|
|
320
|
+
transform: `translate3d(${e.scrollDistance}px, 0, 0)`,
|
|
321
|
+
width: `${e.width}`
|
|
322
|
+
};
|
|
323
|
+
return e.scrollDuration > 0 && (o["transition-duration"] = `${e.scrollDuration}ms`), o;
|
|
324
|
+
});
|
|
325
|
+
return (o, a) => (L(), K("div", Tt, [
|
|
326
|
+
Q("div", {
|
|
260
327
|
class: "fox-swiper-navigator__inner",
|
|
261
|
-
style:
|
|
328
|
+
style: B(n.value)
|
|
262
329
|
}, [
|
|
263
|
-
|
|
330
|
+
Z(o.$slots, "default")
|
|
264
331
|
], 4)
|
|
265
332
|
]));
|
|
266
333
|
}
|
|
267
334
|
});
|
|
268
|
-
let
|
|
269
|
-
function
|
|
270
|
-
return ++
|
|
335
|
+
let Et = 0;
|
|
336
|
+
function bt() {
|
|
337
|
+
return ++Et;
|
|
271
338
|
}
|
|
272
|
-
const
|
|
273
|
-
function
|
|
339
|
+
const Lt = 15, $t = 300, Mt = 200;
|
|
340
|
+
function Rt(t) {
|
|
274
341
|
t.stopPropagation();
|
|
275
342
|
}
|
|
276
|
-
function
|
|
277
|
-
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e &&
|
|
343
|
+
function Pt(t, e) {
|
|
344
|
+
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && Rt(t);
|
|
278
345
|
}
|
|
279
|
-
function
|
|
280
|
-
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t;
|
|
346
|
+
function Ot(t, e, n = 1) {
|
|
347
|
+
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t * n;
|
|
281
348
|
}
|
|
282
|
-
function
|
|
283
|
-
n === "end" ? t.style.transition = `transform ${
|
|
349
|
+
function z(t, e = 0, n, o = Mt) {
|
|
350
|
+
n === "end" ? t.style.transition = `transform ${o}ms cubic-bezier(0.17, 0.89, 0.45, 1)` : t.style.transition = "transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)", t.style.transform = `translate3d(${e}px, 0, 0)`;
|
|
284
351
|
}
|
|
285
|
-
class
|
|
352
|
+
class St {
|
|
353
|
+
/**
|
|
354
|
+
* width
|
|
355
|
+
*/
|
|
286
356
|
width = 0;
|
|
357
|
+
/**
|
|
358
|
+
* column width
|
|
359
|
+
*/
|
|
287
360
|
columnWidth = 0;
|
|
361
|
+
/**
|
|
362
|
+
* max
|
|
363
|
+
*/
|
|
288
364
|
max = 0;
|
|
365
|
+
/**
|
|
366
|
+
* min
|
|
367
|
+
*/
|
|
289
368
|
min = 0;
|
|
369
|
+
/**
|
|
370
|
+
* element
|
|
371
|
+
*/
|
|
290
372
|
el = null;
|
|
373
|
+
/**
|
|
374
|
+
* swipe duration
|
|
375
|
+
*/
|
|
291
376
|
swipeDuration = 360;
|
|
377
|
+
/**
|
|
378
|
+
* transitionEndTrigger
|
|
379
|
+
*/
|
|
292
380
|
transitionEndTrigger = null;
|
|
381
|
+
/**
|
|
382
|
+
* moving
|
|
383
|
+
*/
|
|
293
384
|
moving = !1;
|
|
385
|
+
/**
|
|
386
|
+
* start distance
|
|
387
|
+
*/
|
|
294
388
|
startDistance = 0;
|
|
389
|
+
/**
|
|
390
|
+
* scroll distance
|
|
391
|
+
*/
|
|
295
392
|
scrollDistance = 0;
|
|
393
|
+
/**
|
|
394
|
+
* 获取start distance
|
|
395
|
+
*/
|
|
296
396
|
getStartDistance;
|
|
397
|
+
/**
|
|
398
|
+
* open page
|
|
399
|
+
*/
|
|
297
400
|
openPage;
|
|
401
|
+
/**
|
|
402
|
+
* is page opened
|
|
403
|
+
*/
|
|
298
404
|
isPageOpened;
|
|
405
|
+
/**
|
|
406
|
+
* page opened
|
|
407
|
+
*/
|
|
299
408
|
pageOpened;
|
|
409
|
+
/**
|
|
410
|
+
*触发移动页面的移动比例(相对页面)
|
|
411
|
+
*/
|
|
412
|
+
moveRatio = 0.5;
|
|
413
|
+
/**
|
|
414
|
+
* 惯性削减比例
|
|
415
|
+
*/
|
|
416
|
+
momentumReduceRatio = 1;
|
|
417
|
+
/**
|
|
418
|
+
* transitionend
|
|
419
|
+
*/
|
|
300
420
|
transitionend = null;
|
|
421
|
+
/**
|
|
422
|
+
* touchstart
|
|
423
|
+
*/
|
|
301
424
|
touchstart = null;
|
|
425
|
+
/**
|
|
426
|
+
* touchmove
|
|
427
|
+
*/
|
|
302
428
|
touchmove = null;
|
|
429
|
+
/**
|
|
430
|
+
* touchend
|
|
431
|
+
*/
|
|
303
432
|
touchend = null;
|
|
433
|
+
/**
|
|
434
|
+
* touchcancel
|
|
435
|
+
*/
|
|
304
436
|
touchcancel = null;
|
|
305
|
-
|
|
306
|
-
|
|
437
|
+
/**
|
|
438
|
+
* 构造函数
|
|
439
|
+
* @param getStartDistance
|
|
440
|
+
* @param openPage
|
|
441
|
+
* @param isPageOpened
|
|
442
|
+
* @param pageOpened
|
|
443
|
+
* @param moveRatio
|
|
444
|
+
* @param momentumReduceRatio
|
|
445
|
+
*
|
|
446
|
+
*/
|
|
447
|
+
constructor(e, n, o, a, d, h) {
|
|
448
|
+
this.getStartDistance = e, this.openPage = n, this.isPageOpened = o, this.pageOpened = a, this.moveRatio = d, this.momentumReduceRatio = h;
|
|
307
449
|
}
|
|
450
|
+
/**
|
|
451
|
+
* 打开drag支持
|
|
452
|
+
*/
|
|
308
453
|
open() {
|
|
309
|
-
const e = this.el, n =
|
|
310
|
-
let
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
454
|
+
const e = this.el, n = F(), o = (a, d, h, c) => {
|
|
455
|
+
let v = d + this.startDistance;
|
|
456
|
+
const m = this.columnWidth * this.moveRatio;
|
|
457
|
+
if (h === "end") {
|
|
313
458
|
if (d == 0) {
|
|
314
459
|
this.moving = !1;
|
|
315
460
|
return;
|
|
316
461
|
}
|
|
317
|
-
Math.abs(
|
|
318
|
-
let
|
|
319
|
-
|
|
320
|
-
const i = Math.floor(
|
|
321
|
-
this.isPageOpened(i) || this.openPage(i),
|
|
462
|
+
Math.abs(d) > m ? d > 0 ? v = this.startDistance + this.columnWidth : v = this.startDistance - this.columnWidth : v = this.startDistance;
|
|
463
|
+
let p = -v;
|
|
464
|
+
p < 0 ? p = 0 : p > this.width - this.columnWidth && (p = this.width - this.columnWidth);
|
|
465
|
+
const i = Math.floor(p / this.columnWidth);
|
|
466
|
+
this.isPageOpened(i) || this.openPage(i), v = -i * this.columnWidth, c && c > 0 && (this.transitionEndTrigger = () => {
|
|
322
467
|
this.moving = !1, this.pageOpened(i);
|
|
323
|
-
}),
|
|
468
|
+
}), z(a, v, "end", c), this.scrollDistance = v;
|
|
324
469
|
} else {
|
|
325
|
-
if (Math.abs(
|
|
470
|
+
if (Math.abs(d) > m) {
|
|
326
471
|
let i = 0;
|
|
327
|
-
if (
|
|
328
|
-
const
|
|
329
|
-
this.isPageOpened(
|
|
472
|
+
if (d > 0 ? i = Math.abs(this.startDistance + this.columnWidth) : i = Math.abs(this.startDistance - this.columnWidth), i >= 0 && i < this.width) {
|
|
473
|
+
const u = Math.floor(i / this.columnWidth);
|
|
474
|
+
this.isPageOpened(u) || this.openPage(u);
|
|
330
475
|
}
|
|
331
476
|
}
|
|
332
|
-
let
|
|
333
|
-
|
|
477
|
+
let p = -v;
|
|
478
|
+
p < this.min ? p = this.min : p > this.max && (p = this.max), z(a, -p, "", 0);
|
|
334
479
|
}
|
|
335
480
|
};
|
|
336
481
|
this.transitionend = () => {
|
|
@@ -338,131 +483,200 @@ class pt {
|
|
|
338
483
|
}, this.touchstart = (a) => {
|
|
339
484
|
this.moving || (n.start(a), this.startDistance = this.getStartDistance(), this.transitionEndTrigger = null, this.moving = !0);
|
|
340
485
|
}, this.touchmove = (a) => {
|
|
341
|
-
|
|
342
|
-
|
|
486
|
+
n.move(a), !n.isVertical() && (Pt(a, !0), o(e, n.state.deltaX, "", 0));
|
|
487
|
+
}, this.touchend = () => {
|
|
488
|
+
if (n.isVertical()) {
|
|
489
|
+
o(e, 0, "end", this.swipeDuration);
|
|
343
490
|
return;
|
|
344
491
|
}
|
|
345
|
-
|
|
346
|
-
}, this.touchend = () => {
|
|
347
|
-
const a = n.deltaX.value;
|
|
492
|
+
const a = n.state.deltaX;
|
|
348
493
|
if (a == 0)
|
|
349
494
|
return;
|
|
350
|
-
const
|
|
351
|
-
if (
|
|
352
|
-
const
|
|
353
|
-
|
|
495
|
+
const d = n.state.duration;
|
|
496
|
+
if (d < $t && Math.abs(a) > Lt) {
|
|
497
|
+
const c = Ot(a, d, this.momentumReduceRatio);
|
|
498
|
+
o(e, c, "end", this.swipeDuration);
|
|
354
499
|
} else
|
|
355
|
-
|
|
500
|
+
o(e, a, "end", this.swipeDuration);
|
|
356
501
|
}, e.addEventListener("transitionend", this.transitionend), e.addEventListener("touchstart", this.touchstart), e.addEventListener("touchmove", this.touchmove), e.addEventListener("touchend", this.touchend), e.addEventListener("touchcancel", this.touchend);
|
|
357
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
* 关闭drag支持
|
|
505
|
+
*/
|
|
358
506
|
close() {
|
|
359
507
|
const e = this.el;
|
|
360
508
|
this.transitionend && e.addEventListener("transitionend", this.transitionend), this.touchstart && e.addEventListener("touchstart", this.touchstart), this.touchmove && e.addEventListener("touchmove", this.touchmove), this.touchend && e.addEventListener("touchend", this.touchend), this.touchcancel && e.addEventListener("touchcancel", this.touchcancel), this.el = null;
|
|
361
509
|
}
|
|
362
510
|
}
|
|
363
|
-
function
|
|
364
|
-
return new
|
|
511
|
+
function Xt(t, e, n, o, a, d) {
|
|
512
|
+
return new St(t, e, n, o, a, d);
|
|
513
|
+
}
|
|
514
|
+
function At(t) {
|
|
515
|
+
const e = N(t), n = window.getComputedStyle(e, null), o = parseFloat(n.getPropertyValue("padding-left")), a = parseFloat(n.getPropertyValue("padding-right")), d = parseFloat(n.getPropertyValue("padding-top")), h = parseFloat(n.getPropertyValue("padding-bottom"));
|
|
516
|
+
return {
|
|
517
|
+
width: e.clientWidth - o - a,
|
|
518
|
+
height: e.clientHeight - d - h
|
|
519
|
+
};
|
|
365
520
|
}
|
|
366
|
-
const
|
|
521
|
+
const It = /* @__PURE__ */ P({
|
|
367
522
|
__name: "index",
|
|
368
523
|
props: {
|
|
369
|
-
activePath:
|
|
370
|
-
routes:
|
|
371
|
-
height:
|
|
372
|
-
width:
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
routerViewName:
|
|
376
|
-
|
|
524
|
+
activePath: {},
|
|
525
|
+
routes: {},
|
|
526
|
+
height: { default: -1 },
|
|
527
|
+
width: { default: -1 },
|
|
528
|
+
draggable: { type: Boolean, default: !0 },
|
|
529
|
+
openViewPage: {},
|
|
530
|
+
routerViewName: {},
|
|
531
|
+
moveRatio: { default: 0.5 },
|
|
532
|
+
momentumReduceRatio: { default: 1 },
|
|
533
|
+
direction: { default: "horizontal" },
|
|
534
|
+
transition: { type: [Function, Boolean], default: !0 },
|
|
377
535
|
swipeDuration: { default: 360 },
|
|
378
|
-
|
|
536
|
+
scrollDuration: {},
|
|
537
|
+
customClass: {},
|
|
538
|
+
customStyle: {}
|
|
379
539
|
},
|
|
380
540
|
emits: ["update:activePath"],
|
|
381
541
|
setup(t, { emit: e }) {
|
|
382
|
-
const n = t,
|
|
542
|
+
const n = t, o = tt({
|
|
383
543
|
scrollDistance: 0,
|
|
384
544
|
index: -1,
|
|
385
|
-
openedIndexList: []
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
545
|
+
openedIndexList: [],
|
|
546
|
+
width: n.width,
|
|
547
|
+
height: n.height
|
|
548
|
+
}), a = e, d = () => o.scrollDistance, h = (r) => {
|
|
549
|
+
if (o.openedIndexList.indexOf(r) === -1) {
|
|
550
|
+
o.openedIndexList.push(r);
|
|
551
|
+
const y = n.routes[r];
|
|
390
552
|
try {
|
|
391
|
-
n.
|
|
392
|
-
} catch (
|
|
393
|
-
console.error(
|
|
553
|
+
n.openViewPage(y, r);
|
|
554
|
+
} catch (_) {
|
|
555
|
+
console.error(_);
|
|
394
556
|
}
|
|
395
557
|
}
|
|
396
|
-
}, (
|
|
397
|
-
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
d
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const u = $(() => `${n.width * n.routes.length}px`), f = (l, r) => ({
|
|
420
|
-
style: {
|
|
421
|
-
left: `${n.routes.findIndex((x) => {
|
|
422
|
-
const D = l.path ?? l.name ?? "";
|
|
423
|
-
return x.path == D;
|
|
424
|
-
}) * n.width}px`,
|
|
425
|
-
width: `${n.width}px`
|
|
558
|
+
}, c = (r) => o.openedIndexList.indexOf(r) !== -1, v = (r) => {
|
|
559
|
+
o.index = r, o.width > 0 ? o.scrollDistance = -o.index * o.width : o.scrollDistance = 0;
|
|
560
|
+
const y = n.routes[r];
|
|
561
|
+
a("update:activePath", y.path);
|
|
562
|
+
};
|
|
563
|
+
let m = null;
|
|
564
|
+
n.draggable && (m = Xt(
|
|
565
|
+
d,
|
|
566
|
+
h,
|
|
567
|
+
c,
|
|
568
|
+
v,
|
|
569
|
+
n.moveRatio,
|
|
570
|
+
n.momentumReduceRatio
|
|
571
|
+
));
|
|
572
|
+
let p = null;
|
|
573
|
+
et(() => {
|
|
574
|
+
const r = s(), y = () => {
|
|
575
|
+
const _ = At(r);
|
|
576
|
+
i(n.activePath, n.routes, _.width, _.height, n.swipeDuration, n.direction);
|
|
577
|
+
};
|
|
578
|
+
if (window.ResizeObserver && (p = new window.ResizeObserver(y), p.observe(r)), y(), m) {
|
|
579
|
+
const _ = w();
|
|
580
|
+
m.el = _, m.open();
|
|
426
581
|
}
|
|
582
|
+
}), nt(() => {
|
|
583
|
+
p && (p.disconnect(), p = null), m && m.close();
|
|
584
|
+
}), ot(
|
|
585
|
+
[
|
|
586
|
+
() => n.activePath,
|
|
587
|
+
() => n.routes,
|
|
588
|
+
() => n.width,
|
|
589
|
+
() => n.height,
|
|
590
|
+
() => n.swipeDuration,
|
|
591
|
+
() => n.direction
|
|
592
|
+
],
|
|
593
|
+
([r, y, _, $, M, X]) => {
|
|
594
|
+
const A = _ <= 0 ? o.width : _, D = $ <= 0 ? o.height : $;
|
|
595
|
+
i(r, y, A, D, M, X);
|
|
596
|
+
}
|
|
597
|
+
);
|
|
598
|
+
const i = (r, y, _, $, M, X = "horizontal") => {
|
|
599
|
+
const A = r;
|
|
600
|
+
if (o.index = y.findIndex((D) => D.path === A), X === "horizontal") {
|
|
601
|
+
const D = _;
|
|
602
|
+
if (D > 0) {
|
|
603
|
+
o.width = _;
|
|
604
|
+
const j = D * n.routes.length, k = -D / 3, q = D * (y.length - 1) + D / 3;
|
|
605
|
+
m && (m.columnWidth = D, m.width = j, m.min = k, m.max = q), o.index !== -1 && (o.openedIndexList.push(o.index), o.scrollDistance = -D * o.index);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
m && (m.swipeDuration = M);
|
|
609
|
+
}, u = `fox-swiper-navigator-${bt()}`, f = O(() => {
|
|
610
|
+
const r = [u];
|
|
611
|
+
return n.customClass && r.push(n.customClass), r;
|
|
612
|
+
}), E = O(() => {
|
|
613
|
+
const r = {}, y = o.width > 0 ? o.width : n.width;
|
|
614
|
+
y > 0 && (r.width = `${y}px`);
|
|
615
|
+
const _ = o.height > 0 ? o.height : n.height;
|
|
616
|
+
return _ > 0 && (r.height = `${_}px`), n.customStyle && Object.assign(r, n.customStyle), r;
|
|
427
617
|
});
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
return
|
|
431
|
-
|
|
432
|
-
|
|
618
|
+
let l = null;
|
|
619
|
+
function s() {
|
|
620
|
+
return l || (l = document.querySelector(`.${u}`), l);
|
|
621
|
+
}
|
|
622
|
+
let g = null;
|
|
623
|
+
function w() {
|
|
624
|
+
return g || (g = document.querySelector(`.${u}>.fox-swiper-navigator__inner`), g);
|
|
625
|
+
}
|
|
626
|
+
const x = O(() => o.width > 0 ? `${o.width * n.routes.length}px` : "100%"), T = (r, y) => {
|
|
627
|
+
const _ = n.routes.findIndex(($) => {
|
|
628
|
+
const M = r.path ?? r.name ?? "";
|
|
629
|
+
return $.path == M;
|
|
630
|
+
});
|
|
631
|
+
return o.width <= 0 ? {} : {
|
|
632
|
+
style: {
|
|
633
|
+
left: `${_ * o.width}px`,
|
|
634
|
+
width: `${o.width}px`
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
};
|
|
638
|
+
return (r, y) => {
|
|
639
|
+
const _ = S("fox-router-view");
|
|
640
|
+
return L(), R(_, {
|
|
641
|
+
class: it(f.value),
|
|
642
|
+
style: B(E.value),
|
|
433
643
|
"view-class": "fox-swiper-navigator__item",
|
|
434
|
-
tag:
|
|
435
|
-
"view-tag-props":
|
|
644
|
+
tag: Dt,
|
|
645
|
+
"view-tag-props": T,
|
|
436
646
|
multi: !0,
|
|
437
|
-
name:
|
|
438
|
-
transition:
|
|
439
|
-
"scroll-distance":
|
|
440
|
-
"scroll-
|
|
441
|
-
|
|
442
|
-
|
|
647
|
+
name: r.routerViewName,
|
|
648
|
+
transition: r.transition,
|
|
649
|
+
"scroll-distance": o.scrollDistance,
|
|
650
|
+
"scroll-duration": r.scrollDuration,
|
|
651
|
+
direction: r.direction,
|
|
652
|
+
width: x.value
|
|
653
|
+
}, null, 8, ["class", "style", "name", "transition", "scroll-distance", "scroll-duration", "direction", "width"]);
|
|
443
654
|
};
|
|
444
655
|
}
|
|
445
|
-
})
|
|
446
|
-
const _t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
656
|
+
}), Vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
447
657
|
__proto__: null,
|
|
448
|
-
default:
|
|
658
|
+
default: It
|
|
449
659
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
450
|
-
let
|
|
451
|
-
const
|
|
452
|
-
for (const t in
|
|
660
|
+
let Ct = "fox-";
|
|
661
|
+
const Yt = [], W = /* @__PURE__ */ Object.assign({ "/src/components/card-navigator/index.vue": at, "/src/components/default-navigator/index.vue": ct, "/src/components/root-navigator/index.vue": xt, "/src/components/swiper-navigator/index.vue": Vt }), U = [];
|
|
662
|
+
for (const t in W) {
|
|
453
663
|
let e = /src\/components\/(.*)\/index.vue/.exec(t)[1];
|
|
454
|
-
|
|
664
|
+
Yt.indexOf(e) === -1 && U.push({
|
|
455
665
|
name: e,
|
|
456
|
-
component:
|
|
666
|
+
component: W[t].default
|
|
457
667
|
});
|
|
458
668
|
}
|
|
459
|
-
const
|
|
669
|
+
const Nt = {
|
|
670
|
+
/**
|
|
671
|
+
* 安装
|
|
672
|
+
* @param app
|
|
673
|
+
*/
|
|
460
674
|
install(t) {
|
|
461
|
-
|
|
462
|
-
t.component(`${
|
|
675
|
+
U.forEach((e) => {
|
|
676
|
+
t.component(`${Ct}${e.name}`, e.component);
|
|
463
677
|
});
|
|
464
678
|
}
|
|
465
679
|
};
|
|
466
680
|
export {
|
|
467
|
-
|
|
681
|
+
Nt as default
|
|
468
682
|
};
|