diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-11-16 19:30:20 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-11-16 19:30:20 +0100 |
| commit | 6faad524cf5e4db02855cb213277c40aee14c42a (patch) | |
| tree | 383c984dc1461a03481baa9fbdce8c156ca97e2e /addons/web/static/src/js/core | |
| parent | 3657dc77c2ddb4275f07d1271b93e7f25e09913a (diff) | |
| parent | bc744a1da46efda6f1eb5c341f2fa5df30c9c7ad (diff) | |
[MERGE] forward port branch 12.0 up to bc744a1da46
Diffstat (limited to 'addons/web/static/src/js/core')
| -rw-r--r-- | addons/web/static/src/js/core/dom.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/addons/web/static/src/js/core/dom.js b/addons/web/static/src/js/core/dom.js index 725658a351b..2a961596862 100644 --- a/addons/web/static/src/js/core/dom.js +++ b/addons/web/static/src/js/core/dom.js @@ -397,9 +397,10 @@ return { if (options.maxWidth) { maxWidth = options.maxWidth(); } else { - var rect = $el[0].getBoundingClientRect(); + var mLeft = $el.is('.ml-auto, .mx-auto, .m-auto'); + var mRight = $el.is('.mr-auto, .mx-auto, .m-auto'); + maxWidth = computeFloatOuterWidthWithMargins($el[0], mLeft, mRight); var style = window.getComputedStyle($el[0]); - maxWidth = (rect.right - rect.left); maxWidth -= (parseFloat(style.paddingLeft) + parseFloat(style.paddingRight) + parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth)); maxWidth -= _.reduce($unfoldableItems, function (sum, el) { return sum + computeFloatOuterWidthWithMargins(el); @@ -434,10 +435,17 @@ return { $extraItemsToggle.find('.nav-link').toggleClass('active', $extraItems.children().hasClass('active')); } - function computeFloatOuterWidthWithMargins(el) { + function computeFloatOuterWidthWithMargins(el, mLeft, mRight) { var rect = el.getBoundingClientRect(); var style = window.getComputedStyle(el); - return rect.right - rect.left + parseFloat(style.marginLeft) + parseFloat(style.marginRight); + var outerWidth = rect.right - rect.left; + if (mLeft !== false) { + outerWidth += parseFloat(style.marginLeft); + } + if (mRight !== false) { + outerWidth += parseFloat(style.marginRight); + } + return outerWidth; } }, /** |
