From f3d8016e71d431ef7a0f600edea113f9d4fc8227 Mon Sep 17 00:00:00 2001 From: Dailer Date: Thu, 13 Sep 2018 15:44:07 +0800 Subject: [PATCH] =?UTF-8?q?float=5Fcenter=5Fadapt=20=E7=94=A8inline=5Fcent?= =?UTF-8?q?er=5Fadapt=20=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/platform/web/config.js | 4 ++-- .../wrapper/layout/adapt/inline.center.js | 22 +++++-------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/core/platform/web/config.js b/src/core/platform/web/config.js index 4ffa98fe2..8fea7807d 100644 --- a/src/core/platform/web/config.js +++ b/src/core/platform/web/config.js @@ -3,7 +3,7 @@ BI.prepares.push(function () { // 注册布局 var _isSupprtFlex; var isSupportFlex = function () { - if(_isSupprtFlex == null) { + if (_isSupprtFlex == null) { _isSupprtFlex = !!(BI.isSupportCss3 && BI.isSupportCss3("flex")); } return _isSupprtFlex; @@ -45,6 +45,6 @@ BI.prepares.push(function () { } return BI.extend(ob, {type: "bi.flex_center"}); } - return ob; + return BI.extend(ob, {type: "bi.inline_center_adapt"}); }); }); \ No newline at end of file diff --git a/src/core/wrapper/layout/adapt/inline.center.js b/src/core/wrapper/layout/adapt/inline.center.js index cdfcadf11..a33a138f3 100644 --- a/src/core/wrapper/layout/adapt/inline.center.js +++ b/src/core/wrapper/layout/adapt/inline.center.js @@ -24,33 +24,21 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { render: function () { BI.InlineCenterAdaptLayout.superclass.render.apply(this, arguments); this.element.css({ - whiteSpace: "nowrap" + whiteSpace: "nowrap", + textAlign: "center" }); this.populate(this.options.items); }, _addElement: function (i, item, length) { var o = this.options; - if (!this.hasWidget(this.getName() + i)) { - var t = BI.createWidget(item); - t.element.css({ - position: "relative" - }); - var w = BI.createWidget({ - type: "bi.horizontal_auto", - items: [t] - }); - this.addWidget(this.getName() + i, w); - } else { - var w = this.getWidgetByName(this.getName() + i); - } + var w = BI.InlineVerticalAdaptLayout.superclass._addElement.apply(this, arguments); w.element.css({ position: "relative", display: "inline-block", "vertical-align": "middle", "*display": "inline", - "*zoom": 1, - "min-width": 100 / length + "%" + "*zoom": 1 }); if (o.vgap + o.tgap + (item.tgap || 0) + (item.vgap || 0) !== 0) { w.element.css({ @@ -59,7 +47,7 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { } if (o.hgap + o.lgap + (item.lgap || 0) + (item.hgap || 0) !== 0) { w.element.css({ - "margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) +"px" + "margin-left": (i === 0 ? o.hgap : 0) + o.lgap + (item.lgap || 0) + (item.hgap || 0) + "px" }); } if (o.hgap + o.rgap + (item.rgap || 0) + (item.hgap || 0) !== 0) {