From 105eabe737c119962e9211b115f6824d38dbd4bd Mon Sep 17 00:00:00 2001 From: git Date: Fri, 30 Jul 2021 00:14:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=AA=E5=90=91=E5=A1=AB=E5=85=85=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E7=9A=84=E9=99=8D=E7=BA=A7=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/platform/web/config.js | 2 +- .../{vertical.fill.js => fill.vertical.js} | 0 .../layout/fill/float.fill.horizontal.js | 78 +++++++++++++++++++ src/core/wrapper/layout/layout.inline.js | 3 +- src/less/core/wrapper/fill.horizontal.less | 5 ++ 5 files changed, 86 insertions(+), 2 deletions(-) rename src/core/wrapper/layout/fill/{vertical.fill.js => fill.vertical.js} (100%) create mode 100644 src/core/wrapper/layout/fill/float.fill.horizontal.js create mode 100644 src/less/core/wrapper/fill.horizontal.less diff --git a/src/core/platform/web/config.js b/src/core/platform/web/config.js index 7a9471bc2..49f9ab7d4 100644 --- a/src/core/platform/web/config.js +++ b/src/core/platform/web/config.js @@ -98,7 +98,7 @@ BI.prepares.push(function () { scrollx: false }, ob, {type: "bi.flex_horizontal"}); } - return BI.extend({}, ob, {type: "bi.htape"}); + return BI.extend({}, ob, {type: "bi.horizontal_float_fill"}); }); BI.Plugin.configWidget("bi.vertical_fill", function (ob) { if (isSupportFlex()) { diff --git a/src/core/wrapper/layout/fill/vertical.fill.js b/src/core/wrapper/layout/fill/fill.vertical.js similarity index 100% rename from src/core/wrapper/layout/fill/vertical.fill.js rename to src/core/wrapper/layout/fill/fill.vertical.js diff --git a/src/core/wrapper/layout/fill/float.fill.horizontal.js b/src/core/wrapper/layout/fill/float.fill.horizontal.js new file mode 100644 index 000000000..6235e6505 --- /dev/null +++ b/src/core/wrapper/layout/fill/float.fill.horizontal.js @@ -0,0 +1,78 @@ +BI.FloatHorizontalFillLayout = BI.inherit(BI.Layout, { + props: function () { + return BI.extend(BI.FloatHorizontalFillLayout.superclass.props.apply(this, arguments), { + baseCls: "bi-h-float-fill", + verticalAlign: BI.VerticalAlign.Top, + hgap: 0, + vgap: 0, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + columnSize: [], + items: [] + }); + }, + render: function () { + BI.FloatHorizontalFillLayout.superclass.render.apply(this, arguments); + this.populate(this.options.items); + }, + + resize: function () { + // console.log("填充布局不需要resize"); + }, + addItem: function (item) { + // do nothing + throw new Error("不能添加子组件"); + }, + + stroke: function (items) { + var self = this, o = this.options; + items = BI.compact(items); + var rank = 0; + BI.any(items, function (i, item) { + if (BI.isEmptyObject(item)) { + return true; + } + var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width; + if (columnSize === "fill") { + return true; + } + var w = BI._lazyCreateWidget(item); + self.addWidget(self._getChildName(rank++), w); + w.element.addClass("h-float-fill-item"); + w.element.css({ + float: "left" + }); + }); + BI.backAny(items, function (i, item) { + if (BI.isEmptyObject(item)) { + return true; + } + var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width; + if (columnSize === "fill") { + return true; + } + var w = BI._lazyCreateWidget(item); + self.addWidget(self._getChildName(rank++), w); + w.element.addClass("h-float-fill-item"); + w.element.css({ + float: "right" + }); + }); + BI.each(items, function (i, item) { + var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width; + if (columnSize === "fill") { + var w = BI._lazyCreateWidget(item); + self.addWidget(self._getChildName(rank++), w); + w.element.addClass("h-float-fill-item"); + } + }); + }, + + populate: function (items) { + BI.FloatHorizontalFillLayout.superclass.populate.apply(this, arguments); + this._mount(); + } +}); +BI.shortcut("bi.horizontal_float_fill", BI.FloatHorizontalFillLayout); \ No newline at end of file diff --git a/src/core/wrapper/layout/layout.inline.js b/src/core/wrapper/layout/layout.inline.js index 8d03273d8..c68a55bbb 100644 --- a/src/core/wrapper/layout/layout.inline.js +++ b/src/core/wrapper/layout/layout.inline.js @@ -20,7 +20,8 @@ BI.InlineLayout = BI.inherit(BI.Layout, { lgap: 0, rgap: 0, tgap: 0, - bgap: 0 + bgap: 0, + items: [] }); }, diff --git a/src/less/core/wrapper/fill.horizontal.less b/src/less/core/wrapper/fill.horizontal.less new file mode 100644 index 000000000..40c7a9aaf --- /dev/null +++ b/src/less/core/wrapper/fill.horizontal.less @@ -0,0 +1,5 @@ +.bi-h-float-fill { + .h-float-fill-item { + height: 100%; + } +} \ No newline at end of file