PageSourceSearch

https://gapfy.io/js/navbar-scroll.cy7drqqq5y.js

js gapfy.io collected 2026-09-24 15:04:10 UTC 1,686 bytes, 45 lines download raw bytes

1/*
2 * Gapfy navbar shadow-on-scroll — toggles .is-scrolled on the
3 * <header class="site-navbar"> when the user scrolls past a small
4 * threshold (8px). CSS reads that class to drop a subtle shadow
5 * beneath the sticky navbar.
6 *
7 * Stripe pattern: the navbar feels weightless at the top of the
8 * page (sits over the hero) and gains a subtle elevation when
9 * content starts to scroll beneath it. Zero shadow when the user
10 * is at the top, so the hero looks unbroken.
11 *
12 * Uses a scroll listener with rAF coalescing instead of an
13 * IntersectionObserver because the threshold is so small (8px)
14 * that an observer with a sentinel element is overkill.
15 */
16(function () {
17    if (typeof window === 'undefined' || typeof document === 'undefined') return;
18
19    var THRESHOLD = 8;
20    var SCROLLED_CLASS = 'is-scrolled';
21    var rafScheduled = false;
22
23    function update() {
24        rafScheduled = false;
25        var scrolled = (window.scrollY || window.pageYOffset || 0) > THRESHOLD;
26        var headers = document.querySelectorAll('.site-navbar');
27        for (var i = 0; i < headers.length; i++) {
28            headers[i].classList.toggle(SCROLLED_CLASS, scrolled);
29        }
30    }
31
32    function onScroll() {
33        if (rafScheduled) return;
34        rafScheduled = true;
35        requestAnimationFrame(update);
36    }
37
38    window.addEventListener('scroll', onScroll, { passive: true });
39    // Run once after first paint so a page that loads already
40    // scrolled (browser restore, anchor link, etc.) gets the
41    // correct state from the start.
42    document.addEventListener('DOMContentLoaded', update);
43    document.addEventListener('enhancedload', update);
44    update();
45})();

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.