view 的长宽支持百分比
This commit is contained in:
parent
4005dd840e
commit
7138a38241
14
lib/pen.js
14
lib/pen.js
@ -201,7 +201,7 @@ export default class Painter {
|
|||||||
const linesArray = [];
|
const linesArray = [];
|
||||||
for (let i = 0; i < textArray.length; ++i) {
|
for (let i = 0; i < textArray.length; ++i) {
|
||||||
const textLength = this.ctx.measureText(textArray[i]).width;
|
const textLength = this.ctx.measureText(textArray[i]).width;
|
||||||
const partWidth = view.css.width ? view.css.width.toPx() : textLength;
|
const partWidth = view.css.width ? view.css.width.toPx(false, this.style.width) : textLength;
|
||||||
const calLines = Math.ceil(textLength / partWidth);
|
const calLines = Math.ceil(textLength / partWidth);
|
||||||
width = partWidth > width ? partWidth : width;
|
width = partWidth > width ? partWidth : width;
|
||||||
lines += calLines;
|
lines += calLines;
|
||||||
@ -234,14 +234,14 @@ export default class Painter {
|
|||||||
width = Math.round(view.sWidth / ratio);
|
width = Math.round(view.sWidth / ratio);
|
||||||
height = Math.round(view.sHeight / ratio);
|
height = Math.round(view.sHeight / ratio);
|
||||||
} else if (view.css.width === 'auto') {
|
} else if (view.css.width === 'auto') {
|
||||||
height = view.css.height.toPx();
|
height = view.css.height.toPx(false, this.style.height);
|
||||||
width = view.sWidth / view.sHeight * height;
|
width = view.sWidth / view.sHeight * height;
|
||||||
} else if (view.css.height === 'auto') {
|
} else if (view.css.height === 'auto') {
|
||||||
width = view.css.width.toPx();
|
width = view.css.width.toPx(false, this.style.width);
|
||||||
height = view.sHeight / view.sWidth * width;
|
height = view.sHeight / view.sWidth * width;
|
||||||
} else {
|
} else {
|
||||||
width = view.css.width.toPx();
|
width = view.css.width.toPx(false, this.style.width);
|
||||||
height = view.css.height.toPx();
|
height = view.css.height.toPx(false, this.style.height);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -250,8 +250,8 @@ export default class Painter {
|
|||||||
console.error('You should set width and height');
|
console.error('You should set width and height');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
width = view.css.width.toPx();
|
width = view.css.width.toPx(false, this.style.width);
|
||||||
height = view.css.height.toPx();
|
height = view.css.height.toPx(false, this.style.height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let x;
|
let x;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user