mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-26 06:44:35 +02:00
Refactor scrollbar.js to be used as a Class (#33947)
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
import EventHandler from './dom/event-handler'
|
||||
import Manipulator from './dom/manipulator'
|
||||
import SelectorEngine from './dom/selector-engine'
|
||||
import { getWidth as getScrollBarWidth, hide as scrollBarHide, reset as scrollBarReset } from './util/scrollbar'
|
||||
import ScrollBarHelper from './util/scrollbar'
|
||||
import BaseComponent from './base-component'
|
||||
import Backdrop from './util/backdrop'
|
||||
|
||||
@@ -83,6 +83,7 @@ class Modal extends BaseComponent {
|
||||
this._isShown = false
|
||||
this._ignoreBackdropClick = false
|
||||
this._isTransitioning = false
|
||||
this._scrollBar = new ScrollBarHelper()
|
||||
}
|
||||
|
||||
// Getters
|
||||
@@ -120,7 +121,7 @@ class Modal extends BaseComponent {
|
||||
this._isTransitioning = true
|
||||
}
|
||||
|
||||
scrollBarHide()
|
||||
this._scrollBar.hide()
|
||||
|
||||
document.body.classList.add(CLASS_NAME_OPEN)
|
||||
|
||||
@@ -301,7 +302,7 @@ class Modal extends BaseComponent {
|
||||
this._backdrop.hide(() => {
|
||||
document.body.classList.remove(CLASS_NAME_OPEN)
|
||||
this._resetAdjustments()
|
||||
scrollBarReset()
|
||||
this._scrollBar.reset()
|
||||
EventHandler.trigger(this._element, EVENT_HIDDEN)
|
||||
})
|
||||
}
|
||||
@@ -368,7 +369,7 @@ class Modal extends BaseComponent {
|
||||
|
||||
_adjustDialog() {
|
||||
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
|
||||
const scrollbarWidth = getScrollBarWidth()
|
||||
const scrollbarWidth = this._scrollBar.getWidth()
|
||||
const isBodyOverflowing = scrollbarWidth > 0
|
||||
|
||||
if ((!isBodyOverflowing && isModalOverflowing && !isRTL()) || (isBodyOverflowing && !isModalOverflowing && isRTL())) {
|
||||
|
Reference in New Issue
Block a user