PageSourceSearch

https://new.newcastle.gov.uk/themes/contrib/localgov_base/js/sticky-header.js?tm8xmv

js newcastle.gov.uk collected 2026-10-02 02:31:32 UTC 2,439 bytes, 80 lines download raw bytes

1(function stickyHeaderScript(Drupal) {
2  Drupal.behaviors.stickyHeader = {
3    attach(context) {
4      const headers = once('allStickyHeaders', '.lgd-header', context);
5
6      if (!headers) {
7        return;
8      }
9
10      headers.forEach((header) => {
11        function calculatePositions() {
12          let tabsHeight = 0;
13          const tabs = header
14            .closest('body')
15            .querySelector('.lgd-region--tabs');
16          if (tabs) {
17            tabsHeight = tabs.offsetHeight;
18          }
19
20          let displaceOffsetTop = 0;
21          const displaceOffsetTopValue = parseInt(
22            getComputedStyle(document.documentElement)
23              .getPropertyValue('--drupal-displace-offset-top')
24              .replace('px', ''),
25            10,
26          );
27          if (displaceOffsetTopValue) {
28            displaceOffsetTop = displaceOffsetTopValue;
29          }
30
31          const headerHeight = header.offsetHeight;
32          const headerPosition = displaceOffsetTop + tabsHeight;
33
34          if (header.closest('body').classList.contains('sticky-header')) {
35            document.documentElement.style.setProperty(
36              '--lgd-sticky-header-position',
37              `${headerPosition}px`,
38            );
39            document.documentElement.style.setProperty(
40              '--lgd-sticky-header-height',
41              `${headerHeight}px`,
42            );
43          }
44
45          if (
46            header.closest('body').classList.contains('sticky-header--sticky')
47          ) {
48            header.style.position = 'fixed';
49          }
50        }
51
52        // Initialize oldScroll, so we can use it in the scroll event.
53        let oldScroll = window.scrollY;
54
55        function handleScroll() {
56          if (oldScroll > window.scrollY) {
57            header.closest('body').classList.add('sticky-header--sticky');
58          } else {
59            header.closest('body').classList.remove('sticky-header--sticky');
60            header.style.position = 'relative';
61          }
62          // Update oldScroll to the new scroll position after the comparison
63          oldScroll = window.scrollY;
64
65          calculatePositions();
66        }
67
68        if (
69          header.closest('body').classList.contains('sticky-header--scroll')
70        ) {
71          window.addEventListener('scroll', handleScroll);
72        }
73
74        setTimeout(() => {
75          calculatePositions();
76        }, 50);
77      });
78    },
79  };
80})(Drupal);

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.