PageSourceSearch

https://emprendedores.es/wp-content/themes/mkt228/assets/js/modules/mkt-header-scroll.js?ver=1790237230

js emprendedores.es collected 2026-09-24 08:33:29 UTC 2,408 bytes, 71 lines download raw bytes

1(function () {
2  "use strict";
3
4  var root = document.documentElement;
5  var header = document.querySelector("[data-scroll-header]");
6  var headerMain = document.querySelector("[data-header-main]");
7  var collapseRows = Array.prototype.slice.call(
8    document.querySelectorAll("[data-header-collapse-row]")
9  );
10  var lastScrollY = window.scrollY || 0;
11  var ticking = false;
12
13  if (!header || !headerMain || collapseRows.length === 0) {
14    return;
15  }
16
17  function getCollapseHeight() {
18    return collapseRows.reduce(function (total, row) {
19      return total + row.offsetHeight;
20    }, 0);
21  }
22
23  function updateScrollState() {
24    var currentScrollY = window.scrollY || 0;
25    var direction = currentScrollY > lastScrollY ? "down" : "up";
26    var collapseHeight = getCollapseHeight();
27    var collapseOffset = Math.min(currentScrollY, collapseHeight);
28    var headerMainHeight = headerMain.offsetHeight;
29    var isScrolled = currentScrollY > 0;
30    var isHeaderFixed = currentScrollY >= collapseHeight;
31
32    root.style.setProperty("--mkt-header-collapse-offset", String(collapseOffset) + "px");
33    root.style.setProperty("--mkt-header-collapse-height", String(collapseHeight) + "px");
34    root.style.setProperty("--mkt-header-main-height", String(headerMainHeight) + "px");
35
36    document.body.classList.toggle("is-scrolled", isScrolled);
37    document.body.classList.toggle("header-fixed", isHeaderFixed);
38    document.body.classList.toggle("scrolling-down", isScrolled && direction === "down");
39    document.body.classList.toggle("scrolling-up", isScrolled && direction === "up");
40
41    window.dispatchEvent(
42      new CustomEvent("mkt:header-scroll", {
43        detail: {
44          scrollY: currentScrollY,
45          direction: direction,
46          isScrolled: isScrolled,
47          isHeaderFixed: isHeaderFixed,
48          collapseHeight: collapseHeight,
49          collapseOffset: collapseOffset,
50        },
51      })
52    );
53
54    lastScrollY = currentScrollY;
55    ticking = false;
56  }
57
58  function requestScrollUpdate() {
59    if (ticking) {
60      return;
61    }
62
63    ticking = true;
64    window.requestAnimationFrame(updateScrollState);
65  }
66
67  document.addEventListener("DOMContentLoaded", updateScrollState);
68  window.addEventListener("load", requestScrollUpdate);
69  window.addEventListener("scroll", requestScrollUpdate, { passive: true });
70  window.addEventListener("resize", requestScrollUpdate);
71})();

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.