@fox-js/navigation 4.0.0 → 4.0.1-10

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