Skip to content

Commit c92cf54

Browse files
committed
view 的长宽支持百分比
1 parent b2ec6e6 commit c92cf54

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

components/painter/lib/pen.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export default class Painter {
201201
const linesArray = [];
202202
for (let i = 0; i < textArray.length; ++i) {
203203
const textLength = this.ctx.measureText(textArray[i]).width;
204-
const partWidth = view.css.width ? view.css.width.toPx() : textLength;
204+
const partWidth = view.css.width ? view.css.width.toPx(false, this.style.width) : textLength;
205205
const calLines = Math.ceil(textLength / partWidth);
206206
width = partWidth > width ? partWidth : width;
207207
lines += calLines;
@@ -234,14 +234,14 @@ export default class Painter {
234234
width = Math.round(view.sWidth / ratio);
235235
height = Math.round(view.sHeight / ratio);
236236
} else if (view.css.width === 'auto') {
237-
height = view.css.height.toPx();
237+
height = view.css.height.toPx(false, this.style.height);
238238
width = view.sWidth / view.sHeight * height;
239239
} else if (view.css.height === 'auto') {
240-
width = view.css.width.toPx();
240+
width = view.css.width.toPx(false, this.style.width);
241241
height = view.sHeight / view.sWidth * width;
242242
} else {
243-
width = view.css.width.toPx();
244-
height = view.css.height.toPx();
243+
width = view.css.width.toPx(false, this.style.width);
244+
height = view.css.height.toPx(false, this.style.height);
245245
}
246246
break;
247247
}
@@ -250,8 +250,8 @@ export default class Painter {
250250
console.error('You should set width and height');
251251
return;
252252
}
253-
width = view.css.width.toPx();
254-
height = view.css.height.toPx();
253+
width = view.css.width.toPx(false, this.style.width);
254+
height = view.css.height.toPx(false, this.style.height);
255255
break;
256256
}
257257
let x;

0 commit comments

Comments
 (0)