fix: web text maxLines
This commit is contained in:
parent
87a485e5a2
commit
afb3de1fbc
5
doric-web/dist/index.js
vendored
5
doric-web/dist/index.js
vendored
@ -7301,7 +7301,7 @@ var doric_web = (function (exports, axios, sandbox) {
|
|||||||
if (this.maxLines > 0) {
|
if (this.maxLines > 0) {
|
||||||
const computedStyle = window.getComputedStyle(this.view);
|
const computedStyle = window.getComputedStyle(this.view);
|
||||||
const currentContentHeight = this.view.clientHeight - pixelString2Number(computedStyle.paddingTop) - pixelString2Number(computedStyle.paddingBottom);
|
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) {
|
if (currentContentHeight > 0) {
|
||||||
maxHeight = Math.min(maxHeight, Math.ceil(currentContentHeight));
|
maxHeight = Math.min(maxHeight, Math.ceil(currentContentHeight));
|
||||||
}
|
}
|
||||||
@ -7318,6 +7318,8 @@ var doric_web = (function (exports, axios, sandbox) {
|
|||||||
tempEle.style.font = style.font;
|
tempEle.style.font = style.font;
|
||||||
tempEle.textContent = this.textElement.innerText;
|
tempEle.textContent = this.textElement.innerText;
|
||||||
tempEle.style.whiteSpace = 'normal';
|
tempEle.style.whiteSpace = 'normal';
|
||||||
|
this.view.style.overflow = 'hidden';
|
||||||
|
tempEle.style.lineHeight = `${this.lineHeight()}em`;
|
||||||
tempEle.style.width = this.view.style.width;
|
tempEle.style.width = this.view.style.width;
|
||||||
document.body.appendChild(tempEle);
|
document.body.appendChild(tempEle);
|
||||||
const height = tempEle.offsetHeight;
|
const height = tempEle.offsetHeight;
|
||||||
@ -7331,6 +7333,7 @@ var doric_web = (function (exports, axios, sandbox) {
|
|||||||
tempEle.style.font = style.font;
|
tempEle.style.font = style.font;
|
||||||
tempEle.style.whiteSpace = 'normal';
|
tempEle.style.whiteSpace = 'normal';
|
||||||
this.view.style.overflow = 'hidden';
|
this.view.style.overflow = 'hidden';
|
||||||
|
tempEle.style.lineHeight = `${this.lineHeight()}em`;
|
||||||
tempEle.style.width = this.view.style.width;
|
tempEle.style.width = this.view.style.width;
|
||||||
document.body.appendChild(tempEle);
|
document.body.appendChild(tempEle);
|
||||||
while (start <= end) {
|
while (start <= end) {
|
||||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -102,7 +102,7 @@ export class DoricTextNode extends DoricViewNode {
|
|||||||
if (this.maxLines > 0) {
|
if (this.maxLines > 0) {
|
||||||
const computedStyle = window.getComputedStyle(this.view)
|
const computedStyle = window.getComputedStyle(this.view)
|
||||||
const currentContentHeight = this.view.clientHeight - pixelString2Number(computedStyle.paddingTop) - pixelString2Number(computedStyle.paddingBottom)
|
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) {
|
if (currentContentHeight > 0) {
|
||||||
maxHeight = Math.min(maxHeight, Math.ceil(currentContentHeight))
|
maxHeight = Math.min(maxHeight, Math.ceil(currentContentHeight))
|
||||||
}
|
}
|
||||||
@ -115,12 +115,14 @@ export class DoricTextNode extends DoricViewNode {
|
|||||||
lineHeight() {
|
lineHeight() {
|
||||||
return 1.3
|
return 1.3
|
||||||
}
|
}
|
||||||
|
|
||||||
computedHeight(style:CSSStyleDeclaration) {
|
computedHeight(style:CSSStyleDeclaration) {
|
||||||
const tempEle = document.createElement('div')
|
const tempEle = document.createElement('div')
|
||||||
tempEle.style.font = style.font
|
tempEle.style.font = style.font
|
||||||
tempEle.textContent = this.textElement.innerText
|
tempEle.textContent = this.textElement.innerText
|
||||||
tempEle.style.whiteSpace = 'normal'
|
tempEle.style.whiteSpace = 'normal'
|
||||||
|
this.view.style.overflow = 'hidden'
|
||||||
|
tempEle.style.lineHeight = `${this.lineHeight()}em`
|
||||||
tempEle.style.width = this.view.style.width
|
tempEle.style.width = this.view.style.width
|
||||||
document.body.appendChild(tempEle)
|
document.body.appendChild(tempEle)
|
||||||
|
|
||||||
@ -137,6 +139,7 @@ export class DoricTextNode extends DoricViewNode {
|
|||||||
tempEle.style.font = style.font
|
tempEle.style.font = style.font
|
||||||
tempEle.style.whiteSpace = 'normal'
|
tempEle.style.whiteSpace = 'normal'
|
||||||
this.view.style.overflow = 'hidden'
|
this.view.style.overflow = 'hidden'
|
||||||
|
tempEle.style.lineHeight = `${this.lineHeight()}em`
|
||||||
tempEle.style.width = this.view.style.width
|
tempEle.style.width = this.view.style.width
|
||||||
document.body.appendChild(tempEle);
|
document.body.appendChild(tempEle);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user