From a6e5185eb11328c7689757b12b749d4f4cf95962 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 25 Oct 2021 18:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E9=83=BD=E9=87=87=E7=94=A8ma?= =?UTF-8?q?xWidth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/single/label/abstract.label.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/base/single/label/abstract.label.js b/src/base/single/label/abstract.label.js index 1e787e17b..0d0d28c24 100644 --- a/src/base/single/label/abstract.label.js +++ b/src/base/single/label/abstract.label.js @@ -26,7 +26,7 @@ var o = this.options; return { type: "bi.text", - textAlign: o.textAlign, + textAlign: "left", whiteSpace: o.whiteSpace, lineHeight: o.textHeight, maxWidth: "100%", @@ -50,7 +50,6 @@ _createCenterEl: function () { var o = this.options; var json = this._createJson(); - json.textAlign = "left"; if (BI.isNumber(o.width) && o.width > 0) { if (BI.isNumber(o.textWidth) && o.textWidth > 0) { json.maxWidth = o.textWidth; @@ -246,6 +245,12 @@ return; } if (BI.isNumber(o.height) && o.height > 0) { // 2.3 + if (o.whiteSpace !== "normal") { + this.element.css({ + "line-height": (o.height - (o.vgap * 2)) / BI.pixRatio + BI.pixUnit + }); + } + json.textAlign = o.textAlign; this.text = BI.createWidget(BI.extend(json, { element: this, hgap: o.hgap, @@ -255,11 +260,6 @@ tgap: o.tgap, bgap: o.bgap })); - if (o.whiteSpace !== "normal") { - this.element.css({ - "line-height": (o.height - (o.vgap * 2)) / BI.pixRatio + BI.pixUnit - }); - } return; } json.maxWidth = o.width - 2 * o.hgap - o.lgap - o.rgap; @@ -309,6 +309,7 @@ "line-height": (o.height - (o.vgap * 2)) / BI.pixRatio + BI.pixUnit }); } + json.textAlign = o.textAlign; this.text = BI.createWidget(BI.extend(json, { // 2.6 element: this, hgap: o.hgap,