aboutsummaryrefslogtreecommitdiff
path: root/js/src/util
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2021-04-11 09:37:59 +0300
committerGitHub <[email protected]>2021-04-11 09:37:59 +0300
commit7b7f4a5ced176ae3d7d9d16583795245cb9c7df3 (patch)
tree820815a7921dc0c4787f19187b4ca278c7bd7fbe /js/src/util
parent2d2f5b3dfd901bca22133ae25fdcce7afb4042c7 (diff)
downloadbootstrap-7b7f4a5ced176ae3d7d9d16583795245cb9c7df3.tar.xz
bootstrap-7b7f4a5ced176ae3d7d9d16583795245cb9c7df3.zip
Decouple Modal's scrollbar functionality (#33245)
Diffstat (limited to 'js/src/util')
-rw-r--r--js/src/util/scrollbar.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/js/src/util/scrollbar.js b/js/src/util/scrollbar.js
index e63a66bf2..31b614375 100644
--- a/js/src/util/scrollbar.js
+++ b/js/src/util/scrollbar.js
@@ -8,7 +8,7 @@
import SelectorEngine from '../dom/selector-engine'
import Manipulator from '../dom/manipulator'
-const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed'
+const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'
const SELECTOR_STICKY_CONTENT = '.sticky-top'
const getWidth = () => {
@@ -19,6 +19,7 @@ const getWidth = () => {
const hide = (width = getWidth()) => {
document.body.style.overflow = 'hidden'
+ // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements, to keep shown fullwidth
_setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width)
_setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width)
_setElementAttributes('body', 'paddingRight', calculatedValue => calculatedValue + width)
@@ -49,7 +50,7 @@ const reset = () => {
const _resetElementAttributes = (selector, styleProp) => {
SelectorEngine.find(selector).forEach(element => {
const value = Manipulator.getDataAttribute(element, styleProp)
- if (typeof value === 'undefined' && element === document.body) {
+ if (typeof value === 'undefined') {
element.style.removeProperty(styleProp)
} else {
Manipulator.removeDataAttribute(element, styleProp)