PageSourceSearch

https://hctorpedo.ru/js/sticky-header.js?v=5

js hctorpedo.ru collected 2026-10-02 06:06:29 UTC 2,284 bytes, 55 lines download raw bytes

1/**
2 * Sticky header — no-op.
3 *
4 * Sticky behavior is handled by CSS rule `header.header { position: sticky; top: 0 }`
5 * in /css/styles.css. Previous JS approaches set `position: fixed` on
6 * `.header__wrapper`, which conflicts with `body { transform }` from the page
7 * fade-in animation — fixed elements get anchored to the (scrolling) body
8 * instead of the viewport.
9 *
10 * File kept (as no-op) so existing <script src="/js/sticky-header.js?v=..."> tags
11 * in 60+ HTML files don't 404.
12 */
13(function () {
14  'use strict';
15})();
16
17/* ── Header._compact: уменьшаем логотип-оленя при скролле вниз ─────────────
18   Мобилка (≤767px): из «выступает ниже бара» → «вписан в бар».
19   Десктоп  (>767px): мягко скейлим скрипт-логотип на 0.85 — даёт плавное
20   уменьшение при скролле (CSS transition: transform .2s уже есть в main.css).
21   Threshold = 20px scrollY.
22   ─────────────────────────────────────────────────────────────────────── */
23(function () {
24  'use strict';
25
26  var THRESHOLD = 20;
27
28  var header = document.querySelector('header.header');
29  if (!header) return;
30
31  function currentScroll() {
32    // Учитываем оба сценария: и стандартный (scroll на documentElement),
33    // и Astro-/Bitrix-сборки где html/body имеют свой overflow-y: auto
34    // и фактически скроллится body.
35    return Math.max(
36      window.scrollY || 0,
37      document.documentElement.scrollTop || 0,
38      document.body.scrollTop || 0,
39    );
40  }
41
42  function update() {
43    if (currentScroll() > THRESHOLD) {
44      header.classList.add('_compact');
45    } else {
46      header.classList.remove('_compact');
47    }
48  }
49
50  update();
51  window.addEventListener('scroll',   update, { passive: true });
52  window.addEventListener('resize',   update, { passive: true });
53  document.addEventListener('scroll', update, { passive: true });
54  document.body.addEventListener('scroll', update, { passive: true });
55}());

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.