fix: web text maxLines

This commit is contained in:
钱泽虹
2023-09-12 19:08:12 +08:00
committed by osborn
parent 87a485e5a2
commit afb3de1fbc
3 changed files with 10 additions and 4 deletions

View File

@@ -7301,7 +7301,7 @@ var doric_web = (function (exports, axios, sandbox) {
if (this.maxLines > 0) {
const computedStyle = window.getComputedStyle(this.view);
const currentContentHeight = this.view.clientHeight - pixelString2Number(computedStyle.paddingTop) - pixelString2Number(computedStyle.paddingBottom);
let maxHeight = parseFloat(computedStyle.getPropertyValue('font-size')) * this.lineHeight() * this.maxLines;
let maxHeight = Math.ceil(parseFloat(computedStyle.getPropertyValue('font-size')) * this.lineHeight() * this.maxLines);
if (currentContentHeight > 0) {
maxHeight = Math.min(maxHeight, Math.ceil(currentContentHeight));
}
@@ -7318,6 +7318,8 @@ var doric_web = (function (exports, axios, sandbox) {
tempEle.style.font = style.font;
tempEle.textContent = this.textElement.innerText;
tempEle.style.whiteSpace = 'normal';
this.view.style.overflow = 'hidden';
tempEle.style.lineHeight = `${this.lineHeight()}em`;
tempEle.style.width = this.view.style.width;
document.body.appendChild(tempEle);
const height = tempEle.offsetHeight;
@@ -7331,6 +7333,7 @@ var doric_web = (function (exports, axios, sandbox) {
tempEle.style.font = style.font;
tempEle.style.whiteSpace = 'normal';
this.view.style.overflow = 'hidden';
tempEle.style.lineHeight = `${this.lineHeight()}em`;
tempEle.style.width = this.view.style.width;
document.body.appendChild(tempEle);
while (start <= end) {

File diff suppressed because one or more lines are too long