From 91a483b9856f67a6ac4312c1681d61752f16aab7 Mon Sep 17 00:00:00 2001 From: youki Date: Tue, 23 Feb 2021 13:40:32 +0800 Subject: [PATCH] =?UTF-8?q?DEC-17252=20fix:=20=E6=89=80=E6=9C=89=E5=B0=8F?= =?UTF-8?q?=E6=95=B0*100=E7=9A=84=E5=9C=B0=E6=96=B9=E5=81=9A=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E5=A4=84=E7=90=86=EF=BC=8Cwidth=E4=BC=A0=E5=85=A5?= =?UTF-8?q?=E7=99=BE=E5=88=86=E6=95=B0=E7=9A=84=E6=97=B6=E5=80=99=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=80=E4=BD=8D=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/base.js | 2 +- src/core/wrapper/layout/adapt/adapt.table.js | 2 +- src/core/wrapper/layout/adapt/inline.center.js | 2 +- .../wrapper/layout/adapt/inline.horizontal.js | 2 +- src/core/wrapper/layout/adapt/inline.vertical.js | 2 +- src/core/wrapper/layout/flex/flex.horizontal.js | 2 +- src/core/wrapper/layout/flex/flex.vertical.js | 2 +- .../flex/wrapper/flex.wrapper.horizontal.js | 2 +- .../layout/flex/wrapper/flex.wrapper.vertical.js | 2 +- src/core/wrapper/layout/layout.horizontal.js | 2 +- src/core/wrapper/layout/layout.table.js | 12 ++++++------ src/core/wrapper/layout/layout.tape.js | 8 ++++---- src/core/wrapper/layout/layout.td.js | 2 +- src/core/wrapper/layout/layout.window.js | 16 ++++++++-------- 14 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/core/base.js b/src/core/base.js index 59dda2342..b7948bf33 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -504,7 +504,7 @@ if (!_global.BI) { if (typeof w === "number") { return w >= 0; } else if (typeof w === "string") { - return /^\d{1,3}%$/.exec(w) || w == "auto" || /^\d+px$/.exec(w); + return /^\d{1,3}(\.\d)?%$/.exec(w) || w == "auto" || /^\d+px$/.exec(w); } }, diff --git a/src/core/wrapper/layout/adapt/adapt.table.js b/src/core/wrapper/layout/adapt/adapt.table.js index 27d6992f4..c612227ef 100644 --- a/src/core/wrapper/layout/adapt/adapt.table.js +++ b/src/core/wrapper/layout/adapt/adapt.table.js @@ -35,7 +35,7 @@ BI.TableAdaptLayout = BI.inherit(BI.Layout, { _addElement: function (i, item) { var o = this.options; var td; - var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; + var width = o.columnSize[i] <= 1 ? ((o.columnSize[i] * 100).toFixed(1) + "%") : o.columnSize[i]; if (!this.hasWidget(this._getChildName(i))) { var w = BI._lazyCreateWidget(item); w.element.css({position: "relative", top: "0", left: "0", margin: "0px auto"}); diff --git a/src/core/wrapper/layout/adapt/inline.center.js b/src/core/wrapper/layout/adapt/inline.center.js index 78fe7175e..819252093 100644 --- a/src/core/wrapper/layout/adapt/inline.center.js +++ b/src/core/wrapper/layout/adapt/inline.center.js @@ -38,7 +38,7 @@ BI.InlineCenterAdaptLayout = BI.inherit(BI.Layout, { var o = this.options; var w = BI.InlineCenterAdaptLayout.superclass._addElement.apply(this, arguments); w.element.css({ - width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit), + width: o.columnSize[i] <= 1 ? ((o.columnSize[i] * 100).toFixed(1) + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit), position: "relative", "vertical-align": o.verticalAlign }); diff --git a/src/core/wrapper/layout/adapt/inline.horizontal.js b/src/core/wrapper/layout/adapt/inline.horizontal.js index 79ed9e99f..7667d4587 100644 --- a/src/core/wrapper/layout/adapt/inline.horizontal.js +++ b/src/core/wrapper/layout/adapt/inline.horizontal.js @@ -38,7 +38,7 @@ BI.InlineHorizontalAdaptLayout = BI.inherit(BI.Layout, { var o = this.options; var w = BI.InlineHorizontalAdaptLayout.superclass._addElement.apply(this, arguments); w.element.css({ - width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit), + width: o.columnSize[i] <= 1 ? ((o.columnSize[i] * 100).toFixed(1) + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit), position: "relative", "vertical-align": o.verticalAlign }); diff --git a/src/core/wrapper/layout/adapt/inline.vertical.js b/src/core/wrapper/layout/adapt/inline.vertical.js index 9938ab582..9918066b6 100644 --- a/src/core/wrapper/layout/adapt/inline.vertical.js +++ b/src/core/wrapper/layout/adapt/inline.vertical.js @@ -38,7 +38,7 @@ BI.InlineVerticalAdaptLayout = BI.inherit(BI.Layout, { var o = this.options; var w = BI.InlineVerticalAdaptLayout.superclass._addElement.apply(this, arguments); w.element.css({ - width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit), + width: o.columnSize[i] <= 1 ? ((o.columnSize[i] * 100).toFixed(1) + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit), position: "relative", "vertical-align": o.verticalAlign }); diff --git a/src/core/wrapper/layout/flex/flex.horizontal.js b/src/core/wrapper/layout/flex/flex.horizontal.js index 89550608d..11f751526 100644 --- a/src/core/wrapper/layout/flex/flex.horizontal.js +++ b/src/core/wrapper/layout/flex/flex.horizontal.js @@ -42,7 +42,7 @@ BI.FlexHorizontalLayout = BI.inherit(BI.Layout, { } } if (o.columnSize[i] > 0) { - w.element.width(o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit)); + w.element.width(o.columnSize[i] <= 1 ? ((o.columnSize[i] * 100).toFixed(1) + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit)); } if (o.columnSize[i] === "fill") { w.element.addClass("fill"); diff --git a/src/core/wrapper/layout/flex/flex.vertical.js b/src/core/wrapper/layout/flex/flex.vertical.js index 28d8fd222..d071d410a 100644 --- a/src/core/wrapper/layout/flex/flex.vertical.js +++ b/src/core/wrapper/layout/flex/flex.vertical.js @@ -41,7 +41,7 @@ BI.FlexVerticalLayout = BI.inherit(BI.Layout, { } } if (o.rowSize[i] > 0) { - w.element.height(o.rowSize[i] <= 1 ? (o.rowSize[i] * 100 + "%") : (o.rowSize[i] / BI.pixRatio + BI.pixUnit)); + w.element.height(o.rowSize[i] <= 1 ? ((o.rowSize[i] * 100).toFixed(1) + "%") : (o.rowSize[i] / BI.pixRatio + BI.pixUnit)); } if (o.rowSize[i] === "fill") { w.element.addClass("fill"); diff --git a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js index 064560b5d..33fd1e4d6 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.horizontal.js @@ -43,7 +43,7 @@ BI.FlexWrapperHorizontalLayout = BI.inherit(BI.Layout, { } } if (o.columnSize[i] > 0) { - w.element.width(o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit)); + w.element.width(o.columnSize[i] <= 1 ? ((o.columnSize[i] * 100).toFixed(1) + "%") : (o.columnSize[i] / BI.pixRatio + BI.pixUnit)); } if (o.columnSize[i] === "fill") { w.element.addClass("fill"); diff --git a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js index 3e170b9a7..f11e1bf15 100644 --- a/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js +++ b/src/core/wrapper/layout/flex/wrapper/flex.wrapper.vertical.js @@ -43,7 +43,7 @@ BI.FlexWrapperVerticalLayout = BI.inherit(BI.Layout, { } } if (o.rowSize[i] > 0) { - w.element.height(o.rowSize[i] <= 1 ? (o.rowSize[i] * 100 + "%") : (o.rowSize[i] / BI.pixRatio + BI.pixUnit)); + w.element.height(o.rowSize[i] <= 1 ? ((o.rowSize[i] * 100).toFixed(1) + "%") : (o.rowSize[i] / BI.pixRatio + BI.pixUnit)); } if (o.rowSize[i] === "fill") { w.element.addClass("fill"); diff --git a/src/core/wrapper/layout/layout.horizontal.js b/src/core/wrapper/layout/layout.horizontal.js index 831f98f13..c8103ad2d 100644 --- a/src/core/wrapper/layout/layout.horizontal.js +++ b/src/core/wrapper/layout/layout.horizontal.js @@ -39,7 +39,7 @@ BI.HorizontalLayout = BI.inherit(BI.Layout, { _addElement: function (i, item) { var o = this.options; var td; - var width = o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i]; + var width = o.columnSize[i] <= 1 ? ((o.columnSize[i] * 100).toFixed(1) + "%") : o.columnSize[i]; if (!this.hasWidget(this._getChildName(i))) { var w = BI._lazyCreateWidget(item); w.element.css({position: "relative", margin: "0px auto"}); diff --git a/src/core/wrapper/layout/layout.table.js b/src/core/wrapper/layout/layout.table.js index 7938d6347..ec1c96646 100644 --- a/src/core/wrapper/layout/layout.table.js +++ b/src/core/wrapper/layout/layout.table.js @@ -79,8 +79,8 @@ BI.TableLayout = BI.inherit(BI.Layout, { abs.push(BI.extend({ top: 0, bottom: 0, - left: o.columnSize[i] <= 1 ? left * 100 + "%" : left, - width: o.columnSize[i] <= 1 ? o.columnSize[i] * 100 + "%" : o.columnSize[i] + left: o.columnSize[i] <= 1 ? (left * 100).toFixed(1) + "%" : left, + width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100).toFixed(1) + "%" : o.columnSize[i] }, arr[i])); left += o.columnSize[i] + (o.columnSize[i] < 1 ? 0 : o.hgap); } else { @@ -93,8 +93,8 @@ BI.TableLayout = BI.inherit(BI.Layout, { abs.push(BI.extend({ top: 0, bottom: 0, - right: o.columnSize[j] <= 1 ? right * 100 + "%" : right, - width: o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] + right: o.columnSize[j] <= 1 ? (right * 100).toFixed(1) + "%" : right, + width: o.columnSize[j] <= 1 ? (o.columnSize[j] * 100).toFixed(1) + "%" : o.columnSize[j] }, arr[j])); right += o.columnSize[j] + (o.columnSize[j] < 1 ? 0 : o.hgap); } else { @@ -106,8 +106,8 @@ BI.TableLayout = BI.inherit(BI.Layout, { abs.push(BI.extend({ top: 0, bottom: 0, - left: left <= 1 ? left * 100 + "%" : left, - right: right <= 1 ? right * 100 + "%" : right + left: left <= 1 ? (left * 100).toFixed(1) + "%" : left, + right: right <= 1 ? (right * 100).toFixed(1) + "%" : right }, arr[i])); } var w = BI._lazyCreateWidget({ diff --git a/src/core/wrapper/layout/layout.tape.js b/src/core/wrapper/layout/layout.tape.js index ec52a41df..485dcf83e 100644 --- a/src/core/wrapper/layout/layout.tape.js +++ b/src/core/wrapper/layout/layout.tape.js @@ -69,7 +69,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { left[i] = left[i - 1] + items[i - 1].width + (items[i - 1].lgap || 0) + 2 * (items[i - 1].hgap || 0) + o.hgap + o.lgap + o.rgap; } if (item.width < 1 && item.width >= 0) { - w.element.css({left: left[i] * 100 + "%", width: item.width * 100 + "%"}); + w.element.css({left: (left[i] * 100).toFixed(1) + "%", width: (item.width * 100).toFixed(1) + "%"}); } else { w.element.css({ left: (left[i] + (item.lgap || 0) + (item.hgap || 0) + o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit, @@ -86,7 +86,7 @@ BI.HTapeLayout = BI.inherit(BI.Layout, { right[i] = right[i + 1] + items[i + 1].width + (items[i + 1].rgap || 0) + 2 * (items[i + 1].hgap || 0) + o.hgap + o.lgap + o.rgap; } if (item.width < 1 && item.width >= 0) { - w.element.css({right: right[i] * 100 + "%", width: item.width * 100 + "%"}); + w.element.css({right: (right[i] * 100).toFixed(1) + "%", width: (item.width * 100).toFixed(1) + "%"}); } else { w.element.css({ right: (right[i] + (item.rgap || 0) + (item.hgap || 0) + o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit, @@ -186,7 +186,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { top[i] = top[i - 1] + items[i - 1].height + (items[i - 1].tgap || 0) + 2 * (items[i - 1].vgap || 0) + o.vgap + o.tgap + o.bgap; } if (item.height < 1 && item.height >= 0) { - w.element.css({top: top[i] * 100 + "%", height: item.height * 100 + "%"}); + w.element.css({top: (top[i] * 100).toFixed(1) + "%", height: (item.height * 100).toFixed(1) + "%"}); } else { w.element.css({ top: (top[i] + (item.vgap || 0) + (item.tgap || 0) + o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit, @@ -203,7 +203,7 @@ BI.VTapeLayout = BI.inherit(BI.Layout, { bottom[i] = bottom[i + 1] + items[i + 1].height + (items[i + 1].bgap || 0) + 2 * (items[i + 1].vgap || 0) + o.vgap + o.tgap + o.bgap; } if (item.height < 1 && item.height >= 0) { - w.element.css({bottom: bottom[i] * 100 + "%", height: item.height * 100 + "%"}); + w.element.css({bottom: (bottom[i] * 100).toFixed(1) + "%", height: (item.height * 100).toFixed(1) + "%"}); } else { w.element.css({ bottom: (bottom[i] + (item.vgap || 0) + (item.bgap || 0) + o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit, diff --git a/src/core/wrapper/layout/layout.td.js b/src/core/wrapper/layout/layout.td.js index a54f56e12..46b42f238 100644 --- a/src/core/wrapper/layout/layout.td.js +++ b/src/core/wrapper/layout/layout.td.js @@ -100,7 +100,7 @@ BI.TdLayout = BI.inherit(BI.Layout, { first(w, this.rows++, i); var td = BI._lazyCreateWidget({ type: "bi.default", - width: o.columnSize[i] <= 1 ? (o.columnSize[i] * 100 + "%") : o.columnSize[i], + width: o.columnSize[i] <= 1 ? ((o.columnSize[i] * 100).toFixed(1) + "%") : o.columnSize[i], tagName: "td", items: [w] }); diff --git a/src/core/wrapper/layout/layout.window.js b/src/core/wrapper/layout/layout.window.js index 3bba16d1e..10dd2e2b4 100644 --- a/src/core/wrapper/layout/layout.window.js +++ b/src/core/wrapper/layout/layout.window.js @@ -114,9 +114,9 @@ BI.WindowLayout = BI.inherit(BI.Layout, { if (BI.isNull(top[i])) { top[i] = top[i - 1] + (o.rowSize[i - 1] < 1 ? o.rowSize[i - 1] : o.rowSize[i - 1] + o.vgap + o.bgap); } - var t = top[i] <= 1 ? top[i] * 100 + "%" : (top[i] + o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit, h = ""; + var t = top[i] <= 1 ? (top[i] * 100).toFixed(1) + "%" : (top[i] + o.vgap + o.tgap) / BI.pixRatio + BI.pixUnit, h = ""; if (BI.isNumber(o.rowSize[i])) { - h = o.rowSize[i] <= 1 ? o.rowSize[i] * 100 + "%" : o.rowSize[i] / BI.pixRatio + BI.pixUnit; + h = o.rowSize[i] <= 1 ? (o.rowSize[i] * 100).toFixed(1) + "%" : o.rowSize[i] / BI.pixRatio + BI.pixUnit; } wi.element.css({top: t, height: h}); first(wi, i, j); @@ -132,9 +132,9 @@ BI.WindowLayout = BI.inherit(BI.Layout, { if (BI.isNull(bottom[i])) { bottom[i] = bottom[i + 1] + (o.rowSize[i + 1] < 1 ? o.rowSize[i + 1] : o.rowSize[i + 1] + o.vgap + o.tgap); } - var b = bottom[i] <= 1 ? bottom[i] * 100 + "%" : (bottom[i] + o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit, h = ""; + var b = bottom[i] <= 1 ? (bottom[i] * 100).toFixed(1) + "%" : (bottom[i] + o.vgap + o.bgap) / BI.pixRatio + BI.pixUnit, h = ""; if (BI.isNumber(o.rowSize[i])) { - h = o.rowSize[i] <= 1 ? o.rowSize[i] * 100 + "%" : o.rowSize[i] / BI.pixRatio + BI.pixUnit; + h = o.rowSize[i] <= 1 ? (o.rowSize[i] * 100).toFixed(1) + "%" : o.rowSize[i] / BI.pixRatio + BI.pixUnit; } wi.element.css({bottom: b, height: h}); first(wi, i, j); @@ -150,9 +150,9 @@ BI.WindowLayout = BI.inherit(BI.Layout, { if (BI.isNull(left[j])) { left[j] = left[j - 1] + (o.columnSize[j - 1] < 1 ? o.columnSize[j - 1] : o.columnSize[j - 1] + o.hgap + o.rgap); } - var l = left[j] <= 1 ? left[j] * 100 + "%" : (left[j] + o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit, w = ""; + var l = left[j] <= 1 ? (left[j] * 100).toFixed(1) + "%" : (left[j] + o.hgap + o.lgap) / BI.pixRatio + BI.pixUnit, w = ""; if (BI.isNumber(o.columnSize[j])) { - w = o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] / BI.pixRatio + BI.pixUnit; + w = o.columnSize[j] <= 1 ? (o.columnSize[j] * 100).toFixed(1) + "%" : o.columnSize[j] / BI.pixRatio + BI.pixUnit; } wi.element.css({left: l, width: w}); first(wi, i, j); @@ -168,9 +168,9 @@ BI.WindowLayout = BI.inherit(BI.Layout, { if (BI.isNull(right[j])) { right[j] = right[j + 1] + (o.columnSize[j + 1] < 1 ? o.columnSize[j + 1] : o.columnSize[j + 1] + o.hgap + o.lgap); } - var r = right[j] <= 1 ? right[j] * 100 + "%" : (right[j] + o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit, w = ""; + var r = right[j] <= 1 ? (right[j] * 100).toFixed(1) + "%" : (right[j] + o.hgap + o.rgap) / BI.pixRatio + BI.pixUnit, w = ""; if (BI.isNumber(o.columnSize[j])) { - w = o.columnSize[j] <= 1 ? o.columnSize[j] * 100 + "%" : o.columnSize[j] / BI.pixRatio + BI.pixUnit; + w = o.columnSize[j] <= 1 ? (o.columnSize[j] * 100).toFixed(1) + "%" : o.columnSize[j] / BI.pixRatio + BI.pixUnit; } wi.element.css({right: r, width: w}); first(wi, i, j);