PageSourceSearch

https://www.parc-naturel-chevreuse.fr/themes/custom/wireframe/js/hasScrollBar.js?tm7vqo

js parc-naturel-chevreuse.fr collected 2026-10-01 11:36:19 UTC 2,202 bytes, 59 lines download raw bytes

1/**
2 * hasScrollbar is a JavaScript function to determine if the current
3 * window is scrollable or not, on a given axe or both.
4 *
5 * @param {optional string} axe - The axe where the scroll is checked. Must be "x" or "y".
6 * @return {boolean}
7 */
8var hasScrollbar = function (axe) {
9  var rootElem = document.documentElement || document.body,
10    overflowStyle,
11    overflowYStyle;
12
13  if (typeof rootElem.currentStyle !== 'undefined') {
14    overflowStyle = rootElem.currentStyle.overflow;
15    overflowYStyle = rootElem.currentStyle.overflowY;
16  }
17  overflowStyle = overflowStyle || window.getComputedStyle(rootElem, '').overflow;
18  overflowYStyle = overflowYStyle || window.getComputedStyle(rootElem, '').overflowY;
19
20  if (axe === 'x') {
21    var contentOverflows = rootElem.scrollWidth > rootElem.clientWidth,
22      overflowShown = /^(visible|auto)$/.test(overflowStyle),
23      alwaysShowScroll = overflowStyle === 'scroll';
24    return (contentOverflows && overflowShown) || (alwaysShowScroll);
25  } else if (axe === 'y') {
26    var contentOverflows = rootElem.scrollHeight > rootElem.clientHeight,
27      overflowShown = /^(visible|auto)$/.test(overflowYStyle),
28      alwaysShowScroll = overflowYStyle === 'scroll';
29    return (contentOverflows && overflowShown) || (alwaysShowScroll);
30  } else {
31    var contentOverflows = rootElem.scrollWidth > rootElem.clientWidth || rootElem.scrollHeight > rootElem.clientHeight,
32      overflowShown = /^(visible|auto)$/.test(overflowStyle) || /^(visible|auto)$/.test(overflowYStyle),
33      alwaysShowScroll = overflowStyle === 'scroll' || overflowYStyle === 'scroll';
34
35    return (contentOverflows && overflowShown) || (alwaysShowScroll);
36  }
37}
38
39// (function ($) {
40  Drupal.behaviors.has_scroll_bar = {
41    attach: function (context, settings) {
42      this.update();
43      $(window).on('resize', this.update);
44    },
45    update: function () {
46      if (hasScrollbar('x')) {
47        $('body').addClass('has-overflow-x')
48      } else {
49        $('body').removeClass('has-overflow-x')
50      }
51
52      if (hasScrollbar('y')) {
53        $('body').addClass('has-overflow-y')
54      } else {
55        $('body').removeClass('has-overflow-y')
56      }
57    }
58  };
59// })(jQuery);

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.