From 52f1c6621bffbe61bd90a7c671863434c36496e6 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 19 Aug 2021 20:46:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/float/float.absolute.horizontal.js | 15 +++++++++------ .../layout/float/float.absolute.vertical.js | 9 ++++++--- src/less/core/wrapper/float.absolute.less | 12 +++++++++++- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/core/wrapper/layout/float/float.absolute.horizontal.js b/src/core/wrapper/layout/float/float.absolute.horizontal.js index 358535359..5ccc22daf 100644 --- a/src/core/wrapper/layout/float/float.absolute.horizontal.js +++ b/src/core/wrapper/layout/float/float.absolute.horizontal.js @@ -31,26 +31,29 @@ BI.FloatAbsoluteHorizontalLayout = BI.inherit(BI.Layout, { }, hgap: "50%", vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, tgap: o.tgap, - bgap: o.bgap + bgap: o.bgap, + // lgap和rgap不传的话内部不会设置left和right + lgap: o.lgap, + rgap: o.rgap }; }, _formatItems: function (items) { - if (this.options.horizontalAlign !== BI.HorizontalAlign.Center) { + var o = this.options; + if (o.horizontalAlign === BI.HorizontalAlign.Left) { return items; } + var cls = o.horizontalAlign === BI.HorizontalAlign.Right ? "bi-abs-r-x-item" : "bi-abs-c-x-item"; return BI.map(items, function (i, item) { if (!item || BI.isEmptyObject(item)) { return item; } var el = BI.stripEL(item); if (BI.isWidget(el)) { - el.element.addClass("bi-abs-c-x-item"); + el.element.addClass(cls); } else { - el.cls = (el.cls || "") + "bi-abs-c-x-item"; + el.cls = (el.cls || "") + cls; } return item; }); diff --git a/src/core/wrapper/layout/float/float.absolute.vertical.js b/src/core/wrapper/layout/float/float.absolute.vertical.js index 431fa810c..bea82bb3c 100644 --- a/src/core/wrapper/layout/float/float.absolute.vertical.js +++ b/src/core/wrapper/layout/float/float.absolute.vertical.js @@ -33,24 +33,27 @@ BI.FloatAbsoluteVerticalLayout = BI.inherit(BI.Layout, { hgap: o.hgap, lgap: o.lgap, rgap: o.rgap, + // tgap和bgap不传的话内部不会设置top和bottom tgap: o.tgap, bgap: o.bgap }; }, _formatItems: function (items) { - if (this.options.verticalAlign !== BI.VerticalAlign.Middle) { + var o = this.options; + if (o.verticalAlign === BI.VerticalAlign.Top) { return items; } + var cls = o.verticalAlign === BI.VerticalAlign.Bottom ? "bi-abs-b-y-item" : "bi-abs-c-y-item"; return BI.map(items, function (i, item) { if (!item || BI.isEmptyObject(item)) { return item; } var el = BI.stripEL(item); if (BI.isWidget(el)) { - el.element.addClass("bi-abs-c-y-item"); + el.element.addClass(cls); } else { - el.cls = (el.cls || "") + "bi-abs-c-y-item"; + el.cls = (el.cls || "") + cls; } return item; }); diff --git a/src/less/core/wrapper/float.absolute.less b/src/less/core/wrapper/float.absolute.less index 8461b68e1..12d9da013 100644 --- a/src/less/core/wrapper/float.absolute.less +++ b/src/less/core/wrapper/float.absolute.less @@ -24,4 +24,14 @@ -webkit-transform: translate(-50%, -50%); /* Safari 和 Chrome */ -o-transform: translate(-50%, -50%); /* Opera */ transform: translate(-50%, -50%); -} \ No newline at end of file +} + +.bi-abs-b-y-item { + bottom: 0; + margin-top: auto; +} + +.bi-abs-r-x-item { + right: 0; + margin-left: auto; +}