PageSourceSearch

https://wyspachorzow.pl/y27hk1cx/vadeg4r.js

js wyspachorzow.pl collected 2026-10-09 00:43:15 UTC 3,458 bytes, 89 lines download raw bytes

1document.addEventListener("DOMContentLoaded", () => {
2  const scroller = document.querySelector(".recent-big-wins-scroller__cards");
3  if (!scroller) return;
4
5  let timer = null;
6  let index = 0;
7  let step = 0;
8  let originalCount = 0;
9  let cloneCount = 0;
10  let prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
11
12  function getStep(cards) {
13    if (cards.length >= 2) {
14      // Разница левых позиций надёжнее любых margin/gap
15      const left0 = cards[0].offsetLeft;
16      const left1 = cards[1].offsetLeft;
17      const delta = left1 - left0;
18      if (delta > 0) return delta;
19    }
20    // Фоллбек: ширина + правый margin
21    const cs = getComputedStyle(cards[0]);
22    const mr = parseFloat(cs.marginRight || "0") || 0;
23    return cards[0].offsetWidth + mr;
24  }
25
26  function clearClones() {
27    scroller.querySelectorAll(".recent-big-wins-card.is-clone").forEach(n => n.remove());
28  }
29
30  function init() {
31    // Остановим прежний цикл и почистим клоны
32    if (timer) { clearInterval(timer); timer = null; }
33    clearClones();
34    scroller.scrollTo({ left: 0, behavior: "auto" });
35    index = 0;
36
37    const cards = Array.from(scroller.querySelectorAll(".recent-big-wins-card"));
38    originalCount = cards.length;
39    if (originalCount === 0) return;
40
41    // Посчитаем шаг и сколько карточек помещается во вьюпорте
42    step = getStep(cards);
43    const visible = Math.max(1, Math.floor(scroller.clientWidth / step));
44
45    // Если скроллить нечего — просто выходим
46    const totalWidth = cards[cards.length - 1].offsetLeft + cards[cards.length - 1].offsetWidth - cards[0].offsetLeft;
47    if (totalWidth <= scroller.clientWidth + 1) return;
48
49    // Клонируем первые N карточек (на 1 больше видимого, чтобы шов был невидим)
50    cloneCount = Math.min(originalCount, visible + 1);
51    for (let i = 0; i < cloneCount; i++) {
52      const clone = cards[i].cloneNode(true);
53      clone.classList.add("is-clone");
54      // Чтобы не мешали доступности
55      clone.setAttribute("aria-hidden", "true");
56      scroller.appendChild(clone);
57    }
58
59    // Запускаем цикл
60    const intervalMs = 1500;
61    timer = setInterval(tick, intervalMs);
62  }
63
64  function tick() {
65    const behavior = prefersReduced ? "auto" : "smooth";
66    index += 1;
67    scroller.scrollTo({ left: index * step, behavior });
68
69    // Когда перешли на первый клон (index === originalCount),
70    // дождёмся окончания «smooth» и мгновенно телепортируемся в начало.
71    if (index === originalCount) {
72      // Таймаут ~длительности scroll-behavior: smooth. 350–450 мс обычно достаточно.
73      const snapDelay = prefersReduced ? 0 : 420;
74      setTimeout(() => {
75        scroller.scrollTo({ left: 0, behavior: "auto" });
76        index = 0;
77      }, snapDelay);
78    }
79  }
80
81  // Дебаунс ресайза — пересчёт шага/клонов
82  let resizeT;
83  window.addEventListener("resize", () => {
84    clearTimeout(resizeT);
85    resizeT = setTimeout(init, 150);
86  }, { passive: true });
87
88  init();
89});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.