@fox-js/navigation 4.0.1-8 → 4.0.1

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