PageSourceSearch

https://www.lengyelorszag.travel/wp-content/themes/polskatravel/assets/js/parallax.js?ver=1.23.4

js lengyelorszag.travel collected 2026-09-25 07:02:06 UTC 2,337 bytes, 92 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2  // ✅ Run only on Swedish + Danish pages
3  const htmlLang = (document.documentElement.getAttribute('lang') || '').toLowerCase();
4  const path = window.location.pathname.toLowerCase();
5
6  // const isSvOrDa =
7  //   htmlLang.startsWith('sv') ||
8  //   htmlLang.startsWith('dk') ||
9  //   path.startsWith('/sv') || path.includes('/sv/') ||
10  //   path.startsWith('/dk') || path.includes('/dk/');
11
12  // if (!isSvOrDa) return;
13
14  // ✅ Parallax init
15  const els = document.querySelectorAll('.page-header--bg');
16  if (!els.length) return;
17
18  function tier() {
19    const w = window.innerWidth;
20    if (w >= 2000) return "ultra";
21    if (w >= 1200) return "desktop";
22    return "off"; // tablet + mobile: no parallax
23  }
24
25  function getSpeed() {
26    const t = tier();
27    if (t === "ultra")   return 0.35;
28    if (t === "desktop") return 0.25;
29    return 0;
30  }
31
32  function getBase() {
33    return 0;
34  }
35
36  function getLimits() {
37    const t = tier();
38    if (t === "ultra")   return { min: -990, max: 260 };
39    if (t === "desktop") return { min: -680, max: 180 };
40    return { min: 0, max: 0 };
41  }
42
43  function clamp(v, min, max) {
44    return Math.max(min, Math.min(max, v));
45  }
46
47  let current = 0;
48  let target = 0;
49  let rafId = null;
50
51  function render() {
52    const t = tier();
53    if (t === "off") {
54      els.forEach(el => (el.style.backgroundPosition = 'center 30%'));
55      rafId = null;
56      return;
57    }
58
59    const easing = (t === "ultra") ? 0.22 : 0.18;
60    current += (target - current) * easing;
61
62    const { min, max } = getLimits();
63    const y = clamp(getBase() + current, min, max);
64
65    els.forEach(el => {
66      el.style.backgroundPosition = `center calc(50% + ${Math.round(y)}px)`;
67    });
68
69    if (Math.abs(target - current) > 0.5) {
70      rafId = requestAnimationFrame(render);
71    } else {
72      rafId = null;
73    }
74  }
75
76  function updateTarget() {
77    const t = tier();
78    if (t === "off") {
79      target = 0;
80      current = 0;
81      if (!rafId) rafId = requestAnimationFrame(render);
82      return;
83    }
84
85    target = window.scrollY * getSpeed();
86    if (!rafId) rafId = requestAnimationFrame(render);
87  }
88
89  window.addEventListener('scroll', updateTarget, { passive: true });
90  window.addEventListener('resize', updateTarget);
91  updateTarget();
92});

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.