diff options
author | Mario <mario@mariovavti.com> | 2023-01-20 11:05:15 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-01-20 11:05:15 +0000 |
commit | 9dc949b62c6b5e3c8872211f71b11714d9d22b22 (patch) | |
tree | 38c06e7a128742e219eb74d6adb035f2f106918a /vendor/twbs/bootstrap/js/dist/util/scrollbar.js | |
parent | 40394b94d7c8a8bf1f61f5482195164fff434b90 (diff) | |
download | volse-hubzilla-9dc949b62c6b5e3c8872211f71b11714d9d22b22.tar.gz volse-hubzilla-9dc949b62c6b5e3c8872211f71b11714d9d22b22.tar.bz2 volse-hubzilla-9dc949b62c6b5e3c8872211f71b11714d9d22b22.zip |
native dark theme initial checkin
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/util/scrollbar.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/dist/util/scrollbar.js | 67 |
1 files changed, 20 insertions, 47 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/util/scrollbar.js b/vendor/twbs/bootstrap/js/dist/util/scrollbar.js index 35f9d0b28..72db28a08 100644 --- a/vendor/twbs/bootstrap/js/dist/util/scrollbar.js +++ b/vendor/twbs/bootstrap/js/dist/util/scrollbar.js @@ -1,25 +1,21 @@ /*! - * Bootstrap scrollbar.js v5.2.2 (https://getbootstrap.com/) + * Bootstrap scrollbar.js v5.3.0-alpha1 (https://getbootstrap.com/) * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/selector-engine'), require('../dom/manipulator'), require('./index')) : + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/selector-engine.js'), require('../dom/manipulator.js'), require('./index.js')) : typeof define === 'function' && define.amd ? define(['../dom/selector-engine', '../dom/manipulator', './index'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Scrollbar = factory(global.SelectorEngine, global.Manipulator, global.Index)); -})(this, (function (SelectorEngine, Manipulator, index) { 'use strict'; - - const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; - - const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); - const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); +})(this, (function (SelectorEngine, Manipulator, index_js) { 'use strict'; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.2): util/scrollBar.js + * Bootstrap (v5.3.0-alpha1): util/scrollBar.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ + /** * Constants */ @@ -28,6 +24,7 @@ const SELECTOR_STICKY_CONTENT = '.sticky-top'; const PROPERTY_PADDING = 'padding-right'; const PROPERTY_MARGIN = 'margin-right'; + /** * Class definition */ @@ -35,102 +32,78 @@ class ScrollBarHelper { constructor() { this._element = document.body; - } // Public - + } + // Public getWidth() { // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes const documentWidth = document.documentElement.clientWidth; return Math.abs(window.innerWidth - documentWidth); } - hide() { const width = this.getWidth(); - - this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width - - - this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth - - + this._disableOverFlow(); + // give padding to element to balance the hidden scrollbar width + this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width); + // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width); - this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width); } - reset() { this._resetElementAttributes(this._element, 'overflow'); - this._resetElementAttributes(this._element, PROPERTY_PADDING); - this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING); - this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN); } - isOverflowing() { return this.getWidth() > 0; - } // Private - + } + // Private _disableOverFlow() { this._saveInitialAttribute(this._element, 'overflow'); - this._element.style.overflow = 'hidden'; } - _setElementAttributes(selector, styleProperty, callback) { const scrollbarWidth = this.getWidth(); - const manipulationCallBack = element => { if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) { return; } - this._saveInitialAttribute(element, styleProperty); - const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty); element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`); }; - this._applyManipulationCallback(selector, manipulationCallBack); } - _saveInitialAttribute(element, styleProperty) { const actualValue = element.style.getPropertyValue(styleProperty); - if (actualValue) { - Manipulator__default.default.setDataAttribute(element, styleProperty, actualValue); + Manipulator.setDataAttribute(element, styleProperty, actualValue); } } - _resetElementAttributes(selector, styleProperty) { const manipulationCallBack = element => { - const value = Manipulator__default.default.getDataAttribute(element, styleProperty); // We only want to remove the property if the value is `null`; the value can also be zero - + const value = Manipulator.getDataAttribute(element, styleProperty); + // We only want to remove the property if the value is `null`; the value can also be zero if (value === null) { element.style.removeProperty(styleProperty); return; } - - Manipulator__default.default.removeDataAttribute(element, styleProperty); + Manipulator.removeDataAttribute(element, styleProperty); element.style.setProperty(styleProperty, value); }; - this._applyManipulationCallback(selector, manipulationCallBack); } - _applyManipulationCallback(selector, callBack) { - if (index.isElement(selector)) { + if (index_js.isElement(selector)) { callBack(selector); return; } - - for (const sel of SelectorEngine__default.default.find(selector, this._element)) { + for (const sel of SelectorEngine.find(selector, this._element)) { callBack(sel); } } - } return ScrollBarHelper; |