PageSourceSearch

https://www.cyclesprog.co.uk/wp-content/themes/two-base/js/sticky-panel.js?ver=7.0.3

js cyclesprog.co.uk collected 2026-10-03 22:04:20 UTC 2,408 bytes, 54 lines download raw bytes

1window.addEventListener('scroll', function() {
2  let scrollTop = window.pageYOffset || (document.documentElement || document.body.parentNode || document.body).scrollTop
3  let bodyOffset = document.body.getBoundingClientRect().top;
4  let viewportHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
5  Array.from(document.querySelectorAll('.sticky-panel')).forEach(function(panel) {
6    panel.sticky = parseInt(panel.getAttribute('data-sticky')) || 0;
7    let panelRect = panel.getBoundingClientRect();
8    let parentElement = panel.parentElement;
9    let parentRect = parentElement.getBoundingClientRect();
10    let panelOffsetFromBody = panelRect.top - bodyOffset;
11    let allowSticky = parentRect.height > viewportHeight && panelRect.height < viewportHeight;
12    switch (panel.sticky) {
13      case 0:
14        if (allowSticky && panelOffsetFromBody <= scrollTop) {
15          panel.setAttribute('data-sticky', 1);
16          panel.setAttribute('data-offset', panelOffsetFromBody);
17          if (panel.style.length) {
18            panel.setAttribute('data-styles', panel.getAttribute('style'));
19          }
20          panel.style.top = (bodyOffset + scrollTop) + 'px';
21          panel.style.bottom = 'auto';
22          panel.style.width = panelRect.width + 'px';
23          panel.style.position = 'fixed';
24        }
25        break;
26
27      case 1:
28        if (!allowSticky || scrollTop < (parseInt(panel.getAttribute('data-offset')) || 0)) {
29          panel.setAttribute('data-sticky', 0);
30          panel.setAttribute('style', panel.getAttribute('data-styles'));
31        }
32        else if (allowSticky && parentRect.top + parentRect.height <= panelRect.top + panelRect.height) {
33          if (window.getComputedStyle(parentElement).position === 'static') {
34            parentElement.style.position = 'relative';
35          }
36          panel.setAttribute('data-sticky', 2);
37          panel.style.position = 'absolute';
38          panel.style.top = 'auto';
39          panel.style.bottom = 0;
40        }
41        break;
42
43      case 2:
44        if (allowSticky && panelRect.top - (bodyOffset + scrollTop) > 0) {
45          panel.setAttribute('data-sticky', 1);
46          panel.style.top = (bodyOffset + scrollTop) + 'px';
47          panel.style.bottom = 'auto';
48          panel.style.width = panelRect.width + 'px';
49          panel.style.position = 'fixed';
50        }
51        break;
52    }
53  });
54});

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.