From 484843856d50ae44846831b82d24f6847382b2fc Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 11 Nov 2020 14:48:39 +0200 Subject: [PATCH] modal: move common check to a function --- js/src/modal.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/js/src/modal.js b/js/src/modal.js index ec1991da0..d7bb1fac2 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -229,6 +229,10 @@ class Modal { return config } + _isElementOverflowing() { + return this._element.scrollHeight > document.documentElement.clientHeight + } + _triggerBackdropTransition() { const hideEventPrevented = $.Event(EVENT_HIDE_PREVENTED) @@ -237,9 +241,7 @@ class Modal { return } - const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight - - if (!isModalOverflowing) { + if (!this._isElementOverflowing()) { this._element.style.overflowY = 'hidden' } @@ -250,7 +252,7 @@ class Modal { $(this._element).one(Util.TRANSITION_END, () => { this._element.classList.remove(CLASS_NAME_STATIC) - if (!isModalOverflowing) { + if (!this._isElementOverflowing()) { $(this._element).one(Util.TRANSITION_END, () => { this._element.style.overflowY = '' }) @@ -453,13 +455,11 @@ class Modal { // ---------------------------------------------------------------------- _adjustDialog() { - const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight - - if (!this._isBodyOverflowing && isModalOverflowing) { + if (!this._isBodyOverflowing && this._isElementOverflowing()) { this._element.style.paddingLeft = `${this._scrollbarWidth}px` } - if (this._isBodyOverflowing && !isModalOverflowing) { + if (this._isBodyOverflowing && !this._isElementOverflowing()) { this._element.style.paddingRight = `${this._scrollbarWidth}px` } }