From ee959189a7b8a1b088c4c7b663cf896fcfb7571f Mon Sep 17 00:00:00 2001 From: Rohit Sharma Date: Mon, 7 Dec 2020 21:44:05 +0200 Subject: [PATCH] Create a private method to check if elem is shorter --- js/src/modal.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/src/modal.js b/js/src/modal.js index 1b8363c01..c06374d74 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -462,7 +462,7 @@ class Modal extends BaseComponent { // Adjust fixed content padding SelectorEngine.find(SELECTOR_FIXED_CONTENT) .forEach(element => { - if (window.innerWidth > element.clientWidth + this._scrollbarWidth) { + if (this._isShorterThanWindow(element)) { return } @@ -475,7 +475,7 @@ class Modal extends BaseComponent { // Adjust sticky content margin SelectorEngine.find(SELECTOR_STICKY_CONTENT) .forEach(element => { - if (window.innerWidth > element.clientWidth + this._scrollbarWidth) { + if (this._isShorterThanWindow(element)) { return } @@ -536,6 +536,10 @@ class Modal extends BaseComponent { return scrollbarWidth } + _isShorterThanWindow(element) { + return window.innerWidth > element.clientWidth + this._scrollbarWidth + } + // Static static jQueryInterface(config, relatedTarget) {