PageSourceSearch

https://www.stanleytools.co.uk/sites/g/files/xnuzat1881/files/cohe…/scripts/windowscroll/coh-scroll.js?tm46jr

js stanleytools.co.uk collected 2026-10-05 04:05:59 UTC 1,982 bytes, 63 lines download raw bytes

1(function ($, Drupal, once) {
2
3  Drupal.behaviors.CohesionScroll = {
4
5    attach: function (context) {
6
7      if(drupalSettings.cohesion.add_animation_classes === 'ENABLED') {
8
9        function getWindowOffset() {
10          return window.pageYOffset || document.documentElement.scrollTop;
11        }
12
13        var previous = getWindowOffset();
14
15        $(once('cohWindowScroll', 'body', context)).each(function() {
16
17          var $body = $(this);
18          var timeout, flag = false;
19
20          // Add the class onload if there is an offset
21          if(getWindowOffset() > 0) {
22            $body.addClass('is-scrolled');
23          }
24
25          // Bind the listener
26          //window.onscroll = function() {
27          $(window).scroll(function() {
28            var current = getWindowOffset();
29
30            // Determine if the user is scrolling up or down
31            var state = current > previous;
32
33            // These classes should only be applied when the event is taking place
34            if(!flag) {
35              flag = true;
36              $body.addClass('is-scrolling');
37            }
38
39            // These class should persist even once scrolling has ceased
40            if(current !== previous)    {
41              $body.addClass('is-scrolled').toggleClass('is-scrolled-down', state).toggleClass('is-scrolled-up', !state);
42            }
43
44            // Store the previous position (handles mobile or negative scrolling)
45            previous = current <= 0 ? 0 : current;
46
47            // Remove is-scrolling on scroll stop (no event for scrollStop)
48            clearTimeout(timeout);
49            timeout = setTimeout(function() {
50              $body.removeClass('is-scrolling');
51              flag = false;
52            }, 200);
53
54            // Remove 'is-scrolled' class if there is no offset
55            if(previous === 0) {
56              $body.removeClass('is-scrolled');
57            }
58          });
59        });
60      }
61    }
62  };
63})(jQuery, Drupal, once, drupalSettings);

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.