From 4c2ffe6cc002637dbf01703a59e9c9f4eee79b6c Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 24 Feb 2022 18:57:38 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/wrapper/layout.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/core/wrapper/layout.js b/src/core/wrapper/layout.js index 6f4469258..6690a51c0 100644 --- a/src/core/wrapper/layout.js +++ b/src/core/wrapper/layout.js @@ -323,27 +323,37 @@ BI.Layout = BI.inherit(BI.Widget, { // 横向换纵向 _handleReverseGap: function (w, item, index) { var o = this.options; - if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { - var top = (index === 0 ? o.vgap : 0) + (index === 0 ? o.tgap : 0) + (item.tgap || 0) + (item.vgap || 0); + var innerLgap, innerRgap, innerTgap, innerBgap; + if (BI.isNull(vIndex)) { + innerTgap = innerBgap = o.paddingVgap; + innerLgap = hIndex === 0 ? o.paddingHgap : 0; + innerRgap = hIndex === o.items.length - 1 ? o.paddingHgap : 0; + } else { + innerLgap = innerRgap = o.paddingHgap; + innerTgap = vIndex === 0 ? o.paddingVgap : 0; + innerBgap = vIndex === o.items.length - 1 ? o.paddingVgap : 0; + } + if (o.vgap + o.tgap + innerTgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { + var top = (index === 0 ? o.vgap : 0) + (index === 0 ? o.tgap : 0) + innerTgap + (item.tgap || 0) + (item.vgap || 0); w.element.css({ "margin-top": this._optimiseGap(top) }); } - if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { - var left = o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0); + if (o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { + var left = o.hgap + o.lgap + innerLgap + (item.lgap || 0) + (item.hgap || 0); w.element.css({ "margin-left": this._optimiseGap(left) }); } - if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { - var right = o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0); + if (o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0) !== 0) { + var right = o.hgap + o.rgap + innerRgap + (item.rgap || 0) + (item.hgap || 0); w.element.css({ "margin-right": this._optimiseGap(right) }); } // 这里的代码是关键 - if (o.vgap + o.hgap + o.bgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { - var bottom = (index === o.items.length - 1 ? o.vgap : o.hgap) + (index === o.items.length - 1 ? o.bgap : 0) + (item.bgap || 0) + (item.vgap || 0); + if (o.vgap + o.hgap + o.bgap + innerBgap + (item.bgap || 0) + (item.vgap || 0) !== 0) { + var bottom = (index === o.items.length - 1 ? o.vgap : o.hgap) + (index === o.items.length - 1 ? o.bgap : 0) + innerBgap + (item.bgap || 0) + (item.vgap || 0); w.element.css({ "margin-bottom": this._optimiseGap(bottom) });