@slidejs/runner-swiper 0.1.5 → 0.1.6

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.mjs CHANGED
@@ -203,12 +203,12 @@ function Q(n) {
203
203
  } = e;
204
204
  let m = S;
205
205
  m.originalEvent && (m = m.originalEvent);
206
- const k = m.keyCode || m.charCode, c = e.params.keyboard.pageUpDown, l = c && k === 33, g = c && k === 34, u = k === 37, i = k === 39, r = k === 38, o = k === 40;
206
+ const k = m.keyCode || m.charCode, d = e.params.keyboard.pageUpDown, l = d && k === 33, g = d && k === 34, u = k === 37, i = k === 39, r = k === 38, o = k === 40;
207
207
  if (!e.allowSlideNext && (e.isHorizontal() && i || e.isVertical() && o || g) || !e.allowSlidePrev && (e.isHorizontal() && u || e.isVertical() && r || l))
208
208
  return !1;
209
209
  if (!(m.shiftKey || m.altKey || m.ctrlKey || m.metaKey) && !(a.activeElement && (a.activeElement.isContentEditable || a.activeElement.nodeName && (a.activeElement.nodeName.toLowerCase() === "input" || a.activeElement.nodeName.toLowerCase() === "textarea")))) {
210
210
  if (e.params.keyboard.onlyInViewport && (l || g || u || i || r || o)) {
211
- let d = !1;
211
+ let c = !1;
212
212
  if (N(e.el, `.${e.params.slideClass}, swiper-slide`).length > 0 && N(e.el, `.${e.params.slideActiveClass}`).length === 0)
213
213
  return;
214
214
  const C = e.el, M = C.clientWidth, Y = C.clientHeight, A = f.innerWidth, L = f.innerHeight, b = ie(C);
@@ -218,10 +218,10 @@ function Q(n) {
218
218
  const y = D[x];
219
219
  if (y[0] >= 0 && y[0] <= A && y[1] >= 0 && y[1] <= L) {
220
220
  if (y[0] === 0 && y[1] === 0) continue;
221
- d = !0;
221
+ c = !0;
222
222
  }
223
223
  }
224
- if (!d) return;
224
+ if (!c) return;
225
225
  }
226
226
  e.isHorizontal() ? ((l || g || u || i) && (m.preventDefault ? m.preventDefault() : m.returnValue = !1), ((g || i) && !v || (l || u) && v) && e.slideNext(), ((l || u) && !v || (g || i) && v) && e.slidePrev()) : ((l || g || r || o) && (m.preventDefault ? m.preventDefault() : m.returnValue = !1), (g || o) && e.slideNext(), (l || r) && e.slidePrev()), p("keyPress", k);
227
227
  }
@@ -270,59 +270,59 @@ function R(n) {
270
270
  nextEl: null,
271
271
  prevEl: null
272
272
  };
273
- function a(c) {
273
+ function a(d) {
274
274
  let l;
275
- return c && typeof c == "string" && e.isElement && (l = e.el.querySelector(c) || e.hostEl.querySelector(c), l) ? l : (c && (typeof c == "string" && (l = [...document.querySelectorAll(c)]), e.params.uniqueNavElements && typeof c == "string" && l && l.length > 1 && e.el.querySelectorAll(c).length === 1 ? l = e.el.querySelector(c) : l && l.length === 1 && (l = l[0])), c && !l ? c : l);
275
+ return d && typeof d == "string" && e.isElement && (l = e.el.querySelector(d) || e.hostEl.querySelector(d), l) ? l : (d && (typeof d == "string" && (l = [...document.querySelectorAll(d)]), e.params.uniqueNavElements && typeof d == "string" && l && l.length > 1 && e.el.querySelectorAll(d).length === 1 ? l = e.el.querySelector(d) : l && l.length === 1 && (l = l[0])), d && !l ? d : l);
276
276
  }
277
- function f(c, l) {
277
+ function f(d, l) {
278
278
  const g = e.params.navigation;
279
- c = E(c), c.forEach((u) => {
279
+ d = E(d), d.forEach((u) => {
280
280
  u && (u.classList[l ? "add" : "remove"](...g.disabledClass.split(" ")), u.tagName === "BUTTON" && (u.disabled = l), e.params.watchOverflow && e.enabled && u.classList[e.isLocked ? "add" : "remove"](g.lockClass));
281
281
  });
282
282
  }
283
283
  function h() {
284
284
  const {
285
- nextEl: c,
285
+ nextEl: d,
286
286
  prevEl: l
287
287
  } = e.navigation;
288
288
  if (e.params.loop) {
289
- f(l, !1), f(c, !1);
289
+ f(l, !1), f(d, !1);
290
290
  return;
291
291
  }
292
- f(l, e.isBeginning && !e.params.rewind), f(c, e.isEnd && !e.params.rewind);
292
+ f(l, e.isBeginning && !e.params.rewind), f(d, e.isEnd && !e.params.rewind);
293
293
  }
294
- function w(c) {
295
- c.preventDefault(), !(e.isBeginning && !e.params.loop && !e.params.rewind) && (e.slidePrev(), p("navigationPrev"));
294
+ function w(d) {
295
+ d.preventDefault(), !(e.isBeginning && !e.params.loop && !e.params.rewind) && (e.slidePrev(), p("navigationPrev"));
296
296
  }
297
- function B(c) {
298
- c.preventDefault(), !(e.isEnd && !e.params.loop && !e.params.rewind) && (e.slideNext(), p("navigationNext"));
297
+ function B(d) {
298
+ d.preventDefault(), !(e.isEnd && !e.params.loop && !e.params.rewind) && (e.slideNext(), p("navigationNext"));
299
299
  }
300
300
  function S() {
301
- const c = e.params.navigation;
301
+ const d = e.params.navigation;
302
302
  if (e.params.navigation = q(e, e.originalParams.navigation, e.params.navigation, {
303
303
  nextEl: "swiper-button-next",
304
304
  prevEl: "swiper-button-prev"
305
- }), !(c.nextEl || c.prevEl)) return;
306
- let l = a(c.nextEl), g = a(c.prevEl);
305
+ }), !(d.nextEl || d.prevEl)) return;
306
+ let l = a(d.nextEl), g = a(d.prevEl);
307
307
  Object.assign(e.navigation, {
308
308
  nextEl: l,
309
309
  prevEl: g
310
310
  }), l = E(l), g = E(g);
311
311
  const u = (i, r) => {
312
- i && i.addEventListener("click", r === "next" ? B : w), !e.enabled && i && i.classList.add(...c.lockClass.split(" "));
312
+ i && i.addEventListener("click", r === "next" ? B : w), !e.enabled && i && i.classList.add(...d.lockClass.split(" "));
313
313
  };
314
314
  l.forEach((i) => u(i, "next")), g.forEach((i) => u(i, "prev"));
315
315
  }
316
316
  function v() {
317
317
  let {
318
- nextEl: c,
318
+ nextEl: d,
319
319
  prevEl: l
320
320
  } = e.navigation;
321
- c = E(c), l = E(l);
321
+ d = E(d), l = E(l);
322
322
  const g = (u, i) => {
323
323
  u.removeEventListener("click", i === "next" ? B : w), u.classList.remove(...e.params.navigation.disabledClass.split(" "));
324
324
  };
325
- c.forEach((u) => g(u, "next")), l.forEach((u) => g(u, "prev"));
325
+ d.forEach((u) => g(u, "next")), l.forEach((u) => g(u, "prev"));
326
326
  }
327
327
  t("init", () => {
328
328
  e.params.navigation.enabled === !1 ? k() : (S(), h());
@@ -332,15 +332,15 @@ function R(n) {
332
332
  v();
333
333
  }), t("enable disable", () => {
334
334
  let {
335
- nextEl: c,
335
+ nextEl: d,
336
336
  prevEl: l
337
337
  } = e.navigation;
338
- if (c = E(c), l = E(l), e.enabled) {
338
+ if (d = E(d), l = E(l), e.enabled) {
339
339
  h();
340
340
  return;
341
341
  }
342
- [...c, ...l].filter((g) => !!g).forEach((g) => g.classList.add(e.params.navigation.lockClass));
343
- }), t("click", (c, l) => {
342
+ [...d, ...l].filter((g) => !!g).forEach((g) => g.classList.add(e.params.navigation.lockClass));
343
+ }), t("click", (d, l) => {
344
344
  let {
345
345
  nextEl: g,
346
346
  prevEl: u
@@ -350,12 +350,12 @@ function R(n) {
350
350
  let r = u.includes(i) || g.includes(i);
351
351
  if (e.isElement && !r) {
352
352
  const o = l.path || l.composedPath && l.composedPath();
353
- o && (r = o.find((d) => g.includes(d) || u.includes(d)));
353
+ o && (r = o.find((c) => g.includes(c) || u.includes(c)));
354
354
  }
355
355
  if (e.params.navigation.hideOnClick && !r) {
356
356
  if (e.pagination && e.params.pagination && e.params.pagination.clickable && (e.pagination.el === i || e.pagination.el.contains(i))) return;
357
357
  let o;
358
- g.length ? o = g[0].classList.contains(e.params.navigation.hiddenClass) : u.length && (o = u[0].classList.contains(e.params.navigation.hiddenClass)), p(o === !0 ? "navigationShow" : "navigationHide"), [...g, ...u].filter((d) => !!d).forEach((d) => d.classList.toggle(e.params.navigation.hiddenClass));
358
+ g.length ? o = g[0].classList.contains(e.params.navigation.hiddenClass) : u.length && (o = u[0].classList.contains(e.params.navigation.hiddenClass)), p(o === !0 ? "navigationShow" : "navigationHide"), [...g, ...u].filter((c) => !!c).forEach((c) => c.classList.toggle(e.params.navigation.hiddenClass));
359
359
  }
360
360
  });
361
361
  const m = () => {
@@ -441,8 +441,8 @@ function Z(n) {
441
441
  const o = I(r) * e.params.slidesPerGroup;
442
442
  if (e.params.loop) {
443
443
  if (e.realIndex === o) return;
444
- const d = S(e.realIndex, o, e.slides.length);
445
- d === "next" ? e.slideNext() : d === "previous" ? e.slidePrev() : e.slideToLoop(o);
444
+ const c = S(e.realIndex, o, e.slides.length);
445
+ c === "next" ? e.slideNext() : c === "previous" ? e.slidePrev() : e.slideToLoop(o);
446
446
  } else
447
447
  e.slideTo(o);
448
448
  }
@@ -451,25 +451,25 @@ function Z(n) {
451
451
  if (w()) return;
452
452
  let o = e.pagination.el;
453
453
  o = E(o);
454
- let d, C;
454
+ let c, C;
455
455
  const M = e.virtual && e.params.virtual.enabled ? e.virtual.slides.length : e.slides.length, Y = e.params.loop ? Math.ceil(M / e.params.slidesPerGroup) : e.snapGrid.length;
456
- if (e.params.loop ? (C = e.previousRealIndex || 0, d = e.params.slidesPerGroup > 1 ? Math.floor(e.realIndex / e.params.slidesPerGroup) : e.realIndex) : typeof e.snapIndex < "u" ? (d = e.snapIndex, C = e.previousSnapIndex) : (C = e.previousIndex || 0, d = e.activeIndex || 0), r.type === "bullets" && e.pagination.bullets && e.pagination.bullets.length > 0) {
456
+ if (e.params.loop ? (C = e.previousRealIndex || 0, c = e.params.slidesPerGroup > 1 ? Math.floor(e.realIndex / e.params.slidesPerGroup) : e.realIndex) : typeof e.snapIndex < "u" ? (c = e.snapIndex, C = e.previousSnapIndex) : (C = e.previousIndex || 0, c = e.activeIndex || 0), r.type === "bullets" && e.pagination.bullets && e.pagination.bullets.length > 0) {
457
457
  const A = e.pagination.bullets;
458
458
  let L, b, D;
459
459
  if (r.dynamicBullets && (f = te(A[0], e.isHorizontal() ? "width" : "height"), o.forEach((x) => {
460
460
  x.style[e.isHorizontal() ? "width" : "height"] = `${f * (r.dynamicMainBullets + 4)}px`;
461
- }), r.dynamicMainBullets > 1 && C !== void 0 && (h += d - (C || 0), h > r.dynamicMainBullets - 1 ? h = r.dynamicMainBullets - 1 : h < 0 && (h = 0)), L = Math.max(d - h, 0), b = L + (Math.min(A.length, r.dynamicMainBullets) - 1), D = (b + L) / 2), A.forEach((x) => {
461
+ }), r.dynamicMainBullets > 1 && C !== void 0 && (h += c - (C || 0), h > r.dynamicMainBullets - 1 ? h = r.dynamicMainBullets - 1 : h < 0 && (h = 0)), L = Math.max(c - h, 0), b = L + (Math.min(A.length, r.dynamicMainBullets) - 1), D = (b + L) / 2), A.forEach((x) => {
462
462
  const y = [...["", "-next", "-next-next", "-prev", "-prev-prev", "-main"].map((z) => `${r.bulletActiveClass}${z}`)].map((z) => typeof z == "string" && z.includes(" ") ? z.split(" ") : z).flat();
463
463
  x.classList.remove(...y);
464
464
  }), o.length > 1)
465
465
  A.forEach((x) => {
466
466
  const y = I(x);
467
- y === d ? x.classList.add(...r.bulletActiveClass.split(" ")) : e.isElement && x.setAttribute("part", "bullet"), r.dynamicBullets && (y >= L && y <= b && x.classList.add(...`${r.bulletActiveClass}-main`.split(" ")), y === L && B(x, "prev"), y === b && B(x, "next"));
467
+ y === c ? x.classList.add(...r.bulletActiveClass.split(" ")) : e.isElement && x.setAttribute("part", "bullet"), r.dynamicBullets && (y >= L && y <= b && x.classList.add(...`${r.bulletActiveClass}-main`.split(" ")), y === L && B(x, "prev"), y === b && B(x, "next"));
468
468
  });
469
469
  else {
470
- const x = A[d];
470
+ const x = A[c];
471
471
  if (x && x.classList.add(...r.bulletActiveClass.split(" ")), e.isElement && A.forEach((y, z) => {
472
- y.setAttribute("part", z === d ? "bullet-active" : "bullet");
472
+ y.setAttribute("part", z === c ? "bullet-active" : "bullet");
473
473
  }), r.dynamicBullets) {
474
474
  const y = A[L], z = A[b];
475
475
  for (let j = L; j <= b; j += 1)
@@ -486,19 +486,19 @@ function Z(n) {
486
486
  }
487
487
  o.forEach((A, L) => {
488
488
  if (r.type === "fraction" && (A.querySelectorAll(P(r.currentClass)).forEach((b) => {
489
- b.textContent = r.formatFractionCurrent(d + 1);
489
+ b.textContent = r.formatFractionCurrent(c + 1);
490
490
  }), A.querySelectorAll(P(r.totalClass)).forEach((b) => {
491
491
  b.textContent = r.formatFractionTotal(Y);
492
492
  })), r.type === "progressbar") {
493
493
  let b;
494
494
  r.progressbarOpposite ? b = e.isHorizontal() ? "vertical" : "horizontal" : b = e.isHorizontal() ? "horizontal" : "vertical";
495
- const D = (d + 1) / Y;
495
+ const D = (c + 1) / Y;
496
496
  let x = 1, y = 1;
497
497
  b === "horizontal" ? x = D : y = D, A.querySelectorAll(P(r.progressbarFillClass)).forEach((z) => {
498
498
  z.style.transform = `translate3d(0,0,0) scaleX(${x}) scaleY(${y})`, z.style.transitionDuration = `${e.params.speed}ms`;
499
499
  });
500
500
  }
501
- r.type === "custom" && r.renderCustom ? (O(A, r.renderCustom(e, d + 1, Y)), L === 0 && p("paginationRender", A)) : (L === 0 && p("paginationRender", A), p("paginationUpdate", A)), e.params.watchOverflow && e.enabled && A.classList[e.isLocked ? "add" : "remove"](r.lockClass);
501
+ r.type === "custom" && r.renderCustom ? (O(A, r.renderCustom(e, c + 1, Y)), L === 0 && p("paginationRender", A)) : (L === 0 && p("paginationRender", A), p("paginationUpdate", A)), e.params.watchOverflow && e.enabled && A.classList[e.isLocked ? "add" : "remove"](r.lockClass);
502
502
  });
503
503
  }
504
504
  function k() {
@@ -507,18 +507,18 @@ function Z(n) {
507
507
  const r = e.virtual && e.params.virtual.enabled ? e.virtual.slides.length : e.grid && e.params.grid.rows > 1 ? e.slides.length / Math.ceil(e.params.grid.rows) : e.slides.length;
508
508
  let o = e.pagination.el;
509
509
  o = E(o);
510
- let d = "";
510
+ let c = "";
511
511
  if (i.type === "bullets") {
512
512
  let C = e.params.loop ? Math.ceil(r / e.params.slidesPerGroup) : e.snapGrid.length;
513
513
  e.params.freeMode && e.params.freeMode.enabled && C > r && (C = r);
514
514
  for (let M = 0; M < C; M += 1)
515
- i.renderBullet ? d += i.renderBullet.call(e, M, i.bulletClass) : d += `<${i.bulletElement} ${e.isElement ? 'part="bullet"' : ""} class="${i.bulletClass}"></${i.bulletElement}>`;
515
+ i.renderBullet ? c += i.renderBullet.call(e, M, i.bulletClass) : c += `<${i.bulletElement} ${e.isElement ? 'part="bullet"' : ""} class="${i.bulletClass}"></${i.bulletElement}>`;
516
516
  }
517
- i.type === "fraction" && (i.renderFraction ? d = i.renderFraction.call(e, i.currentClass, i.totalClass) : d = `<span class="${i.currentClass}"></span> / <span class="${i.totalClass}"></span>`), i.type === "progressbar" && (i.renderProgressbar ? d = i.renderProgressbar.call(e, i.progressbarFillClass) : d = `<span class="${i.progressbarFillClass}"></span>`), e.pagination.bullets = [], o.forEach((C) => {
518
- i.type !== "custom" && O(C, d || ""), i.type === "bullets" && e.pagination.bullets.push(...C.querySelectorAll(P(i.bulletClass)));
517
+ i.type === "fraction" && (i.renderFraction ? c = i.renderFraction.call(e, i.currentClass, i.totalClass) : c = `<span class="${i.currentClass}"></span> / <span class="${i.totalClass}"></span>`), i.type === "progressbar" && (i.renderProgressbar ? c = i.renderProgressbar.call(e, i.progressbarFillClass) : c = `<span class="${i.progressbarFillClass}"></span>`), e.pagination.bullets = [], o.forEach((C) => {
518
+ i.type !== "custom" && O(C, c || ""), i.type === "bullets" && e.pagination.bullets.push(...C.querySelectorAll(P(i.bulletClass)));
519
519
  }), i.type !== "custom" && p("paginationRender", o[0]);
520
520
  }
521
- function c() {
521
+ function d() {
522
522
  e.params.pagination = q(e, e.originalParams.pagination, e.params.pagination, {
523
523
  el: "swiper-pagination"
524
524
  });
@@ -549,7 +549,7 @@ function Z(n) {
549
549
  o.classList.remove(i.horizontalClass, i.verticalClass), o.classList.add(e.isHorizontal() ? i.horizontalClass : i.verticalClass);
550
550
  });
551
551
  }), t("init", () => {
552
- e.params.pagination.enabled === !1 ? u() : (c(), k(), m());
552
+ e.params.pagination.enabled === !1 ? u() : (d(), k(), m());
553
553
  }), t("activeIndexChange", () => {
554
554
  typeof e.snapIndex > "u" && m();
555
555
  }), t("snapIndexChange", () => {
@@ -566,11 +566,11 @@ function Z(n) {
566
566
  }), t("lock unlock", () => {
567
567
  m();
568
568
  }), t("click", (i, r) => {
569
- const o = r.target, d = E(e.pagination.el);
570
- if (e.params.pagination.el && e.params.pagination.hideOnClick && d && d.length > 0 && !o.classList.contains(e.params.pagination.bulletClass)) {
569
+ const o = r.target, c = E(e.pagination.el);
570
+ if (e.params.pagination.el && e.params.pagination.hideOnClick && c && c.length > 0 && !o.classList.contains(e.params.pagination.bulletClass)) {
571
571
  if (e.navigation && (e.navigation.nextEl && o === e.navigation.nextEl || e.navigation.prevEl && o === e.navigation.prevEl)) return;
572
- const C = d[0].classList.contains(e.params.pagination.hiddenClass);
573
- p(C === !0 ? "paginationShow" : "paginationHide"), d.forEach((M) => M.classList.toggle(e.params.pagination.hiddenClass));
572
+ const C = c[0].classList.contains(e.params.pagination.hiddenClass);
573
+ p(C === !0 ? "paginationShow" : "paginationHide"), c.forEach((M) => M.classList.toggle(e.params.pagination.hiddenClass));
574
574
  }
575
575
  });
576
576
  const g = () => {
@@ -578,7 +578,7 @@ function Z(n) {
578
578
  let {
579
579
  el: i
580
580
  } = e.pagination;
581
- i && (i = E(i), i.forEach((r) => r.classList.remove(e.params.pagination.paginationDisabledClass))), c(), k(), m();
581
+ i && (i = E(i), i.forEach((r) => r.classList.remove(e.params.pagination.paginationDisabledClass))), d(), k(), m();
582
582
  }, u = () => {
583
583
  e.el.classList.add(e.params.pagination.paginationDisabledClass);
584
584
  let {
@@ -591,7 +591,7 @@ function Z(n) {
591
591
  disable: u,
592
592
  render: k,
593
593
  update: m,
594
- init: c,
594
+ init: d,
595
595
  destroy: l
596
596
  });
597
597
  }
@@ -617,6 +617,8 @@ class re {
617
617
  speed: 300,
618
618
  spaceBetween: 30,
619
619
  slidesPerView: 1,
620
+ slidesPerGroup: 1,
621
+ // 确保每次导航只移动一个 slide
620
622
  // 注册模块
621
623
  modules: [R, Z, Q],
622
624
  // 导航配置 - 使用元素引用而不是选择器,确保在 Vue 组件中也能正常工作
@@ -634,6 +636,7 @@ class re {
634
636
  enabled: !0,
635
637
  onlyInViewport: !0
636
638
  },
639
+ // 用户自定义配置(会覆盖上面的默认配置)
637
640
  ...s?.swiperConfig
638
641
  };
639
642
  this.swiper = new F(this.swiperContainer, t), await new Promise((p) => {