vendor: 4,698 bytes, lines 1-113
1/*! 2 * Bootstrap scrollbar.js v5.3.8 (https://getbootstrap.com/) 3 * Copyright 2011-2025 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) 4 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 5 */ 6(function (global, factory) { 7 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/manipulator.js'), require('../dom/selector-engine.js'), require('./index.js')) : 8 typeof define === 'function' && define.amd ? define(['../dom/manipulator', '../dom/selector-engine', './index'], factory) : 9 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Scrollbar = factory(global.Manipulator, global.SelectorEngine, global.Index)); 10})(this, (function (Manipulator, SelectorEngine, index_js) { 'use strict'; 11 12 /** 13 * -------------------------------------------------------------------------- 14 * Bootstrap util/scrollBar.js 15 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) 16 * -------------------------------------------------------------------------- 17 */ 18 19 20 /** 21 * Constants 22 */ 23 24 const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; 25 const SELECTOR_STICKY_CONTENT = '.sticky-top'; 26 const PROPERTY_PADDING = 'padding-right'; 27 const PROPERTY_MARGIN = 'margin-right'; 28 29 /** 30 * Class definition 31 */ 32 33 class ScrollBarHelper { 34 constructor() { 35 this._element = document.body; 36 } 37 38 // Public 39 getWidth() { 40 // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes 41 const documentWidth = document.documentElement.clientWidth; 42 return Math.abs(window.innerWidth - documentWidth); 43 } 44 hide() { 45 const width = this.getWidth(); 46 this._disableOverFlow(); 47 // give padding to element to balance the hidden scrollbar width 48 this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width); 49 // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth 50 this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width); 51 this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width); 52 } 53 reset() { 54 this._resetElementAttributes(this._element, 'overflow'); 55 this._resetElementAttributes(this._element, PROPERTY_PADDING); 56 this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING); 57 this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN); 58 } 59 isOverflowing() { 60 return this.getWidth() > 0; 61 } 62 63 // Private 64 _disableOverFlow() { 65 this._saveInitialAttribute(this._element, 'overflow'); 66 this._element.style.overflow = 'hidden'; 67 } 68 _setElementAttributes(selector, styleProperty, callback) { 69 const scrollbarWidth = this.getWidth(); 70 const manipulationCallBack = element => { 71 if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) { 72 return; 73 } 74 this._saveInitialAttribute(element, styleProperty); 75 const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty); 76 element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`); 77 }; 78 this._applyManipulationCallback(selector, manipulationCallBack); 79 } 80 _saveInitialAttribute(element, styleProperty) { 81 const actualValue = element.style.getPropertyValue(styleProperty); 82 if (actualValue) { 83 Manipulator.setDataAttribute(element, styleProperty, actualValue); 84 } 85 } 86 _resetElementAttributes(selector, styleProperty) { 87 const manipulationCallBack = element => { 88 const value = Manipulator.getDataAttribute(element, styleProperty); 89 // We only want to remove the property if the value is `null`; the value can also be zero 90 if (value === null) { 91 element.style.removeProperty(styleProperty); 92 return; 93 } 94 Manipulator.removeDataAttribute(element, styleProperty); 95 element.style.setProperty(styleProperty, value); 96 }; 97 this._applyManipulationCallback(selector, manipulationCallBack); 98 } 99 _applyManipulationCallback(selector, callBack) { 100 if (index_js.isElement(selector)) { 101 callBack(selector); 102 return; 103 } 104 for (const sel of SelectorEngine.find(selector, this._element)) { 105 callBack(sel); 106 } 107 } 108 } 109 110 return ScrollBarHelper; 111 112})); 113//# sourceMappingURL=scrollbar.js.map
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.