@1337exp/taoui 1.10.3 → 1.10.4

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.cjs CHANGED
@@ -7259,6 +7259,7 @@
7259
7259
  let dragMoved = 0;
7260
7260
  let dragPointer = -1;
7261
7261
  let scrollFrame = 0;
7262
+ let focusFrame = 0;
7262
7263
  let autoplayTimer = 0;
7263
7264
  const step = vue.computed(() => Math.max(1, Math.round(props.perView)));
7264
7265
  const lastIndex = vue.computed(() => Math.max(count.value - step.value, 0));
@@ -7367,18 +7368,32 @@
7367
7368
  hoverPaused.value = false;
7368
7369
  syncAutoplay();
7369
7370
  }
7370
- function onFocusIn() {
7371
- focusPaused.value = true;
7372
- stopAutoplay();
7371
+ function hasKeyboardFocus(root) {
7372
+ const active = document.activeElement;
7373
+ if (!(active instanceof HTMLElement) || !root.contains(active)) {
7374
+ return false;
7375
+ }
7376
+ try {
7377
+ return active.matches(":focus-visible");
7378
+ } catch {
7379
+ return true;
7380
+ }
7373
7381
  }
7374
- function onFocusOut(event) {
7382
+ function scheduleFocusPause(event) {
7375
7383
  const root = event.currentTarget;
7376
- const next = event.relatedTarget;
7377
- if (next && root.contains(next)) {
7378
- return;
7379
- }
7380
- focusPaused.value = false;
7381
- syncAutoplay();
7384
+ cancelAnimationFrame(focusFrame);
7385
+ focusFrame = requestAnimationFrame(() => {
7386
+ if (!track.value) {
7387
+ return;
7388
+ }
7389
+ const next = hasKeyboardFocus(root);
7390
+ focusPaused.value = next;
7391
+ if (next) {
7392
+ stopAutoplay();
7393
+ return;
7394
+ }
7395
+ syncAutoplay();
7396
+ });
7382
7397
  }
7383
7398
  function onScroll() {
7384
7399
  if (dragging.value) {
@@ -7515,6 +7530,7 @@
7515
7530
  vue.onBeforeUnmount(() => {
7516
7531
  endDrag();
7517
7532
  cancelAnimationFrame(scrollFrame);
7533
+ cancelAnimationFrame(focusFrame);
7518
7534
  stopAutoplay();
7519
7535
  document.removeEventListener("visibilitychange", onVisibilityChange);
7520
7536
  window.removeEventListener("blur", onWindowBlur);
@@ -7526,8 +7542,8 @@
7526
7542
  style: vue.normalizeStyle(trackStyle.value),
7527
7543
  onMouseenter: onMouseEnter,
7528
7544
  onMouseleave: onMouseLeave,
7529
- onFocusin: onFocusIn,
7530
- onFocusout: onFocusOut
7545
+ onFocusin: scheduleFocusPause,
7546
+ onFocusout: scheduleFocusPause
7531
7547
  }, [
7532
7548
  vue.createElementVNode("div", _hoisted_1$4, [
7533
7549
  vue.renderSlot(_ctx.$slots, "prev", {
@@ -7650,7 +7666,7 @@
7650
7666
  };
7651
7667
  }
7652
7668
  });
7653
- const TaoCarousel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-bc396e5d"]]);
7669
+ const TaoCarousel = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-b4139b57"]]);
7654
7670
  const _hoisted_1$3 = ["aria-label"];
7655
7671
  const _hoisted_2$2 = ["aria-label"];
7656
7672
  const _hoisted_3$2 = {