From 5c59e27272e8ec493a415a9de92fd67f61ad54cf Mon Sep 17 00:00:00 2001 From: CPPAlien Date: Fri, 22 Nov 2019 10:13:17 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E9=99=90=E5=88=B6=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=8F=AF=E7=BC=A9=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pen.js | 3 +++ painter.js | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/pen.js b/lib/pen.js index d14617d..10ec8b1 100644 --- a/lib/pen.js +++ b/lib/pen.js @@ -343,6 +343,9 @@ export default class Painter { view.rect.top = view.rect.top - pd[0]; view.rect.right = view.rect.right + pd[1]; view.rect.bottom = view.rect.bottom + pd[2]; + if (view.type === 'text') { + view.rect.minWidth = view.css.fontSize.toPx() + pd[1] + pd[3]; + } this.ctx.rotate(angle); if (!notClip && view.css && view.css.borderRadius && view.type !== 'rect') { diff --git a/painter.js b/painter.js index dff7a26..c03c9d4 100644 --- a/painter.js +++ b/painter.js @@ -462,6 +462,16 @@ Component({ let css = {} if (this.isScale) { const newW = this.startW + offsetX > 1 ? this.startW + offsetX : 1 + if (this.touchedView.css && this.touchedView.css.minWidth) { + if (newW < this.touchedView.css.minWidth.toPx()) { + return + } + } + if (this.touchedView.rect && this.touchedView.rect.minWidth) { + if (newW < this.touchedView.rect.minWidth) { + return + } + } const newH = this.startH + offsetY > 1 ? this.startH + offsetY : 1 css = { width: `${newW}px`,