Skip to content

Commit

Permalink
change adjustDialog if conditions to help readability
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoSot committed Oct 8, 2021
1 parent 6c54c1b commit 86b9f9c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,16 @@ class Modal extends BaseComponent {
const scrollbarWidth = this._scrollBar.getWidth()
const isBodyOverflowing = scrollbarWidth > 0

if ((!isBodyOverflowing && isModalOverflowing && !isRTL()) || (isBodyOverflowing && !isModalOverflowing && isRTL())) {
this._element.style.paddingLeft = `${scrollbarWidth}px`
const adjustPadding = property => {
this._element.style[property] = `${scrollbarWidth}px`
}

if ((isBodyOverflowing && !isModalOverflowing && !isRTL()) || (!isBodyOverflowing && isModalOverflowing && isRTL())) {
this._element.style.paddingRight = `${scrollbarWidth}px`
if (isBodyOverflowing && !isModalOverflowing) {
adjustPadding(isRTL() ? 'paddingLeft' : 'paddingRight')
}

if (!isBodyOverflowing && isModalOverflowing) {
adjustPadding(isRTL() ? 'paddingRight' : 'paddingLeft')
}
}

Expand Down

0 comments on commit 86b9f9c

Please sign in to comment.