Commit 5c9b0c97 authored by liujiaxin's avatar liujiaxin

scale text

parent 7f093726
...@@ -35,7 +35,7 @@ export class ScaleTextDirective implements AfterViewInit { ...@@ -35,7 +35,7 @@ export class ScaleTextDirective implements AfterViewInit {
word-spacing: normal; word-spacing: normal;
word-break: keep-all; word-break: keep-all;
white-space: nowrap; white-space: nowrap;
margin-left: 8px; margin-left: 16px;
`; `;
const span = document.createElement('span'); const span = document.createElement('span');
span.innerHTML = `${this.Element.nativeElement.textContent}`; span.innerHTML = `${this.Element.nativeElement.textContent}`;
...@@ -43,7 +43,7 @@ export class ScaleTextDirective implements AfterViewInit { ...@@ -43,7 +43,7 @@ export class ScaleTextDirective implements AfterViewInit {
this.Element.nativeElement.childNodes.forEach(n => n.remove()); this.Element.nativeElement.childNodes.forEach(n => n.remove());
this.Element.nativeElement.append(span); this.Element.nativeElement.append(span);
setTimeout(() => { setTimeout(() => {
const fitWidth = this.Element.nativeElement.offsetWidth - 8; const fitWidth = this.Element.nativeElement.offsetWidth - 16;
const textWidth = span.offsetWidth; const textWidth = span.offsetWidth;
console.log(textWidth, fitWidth); console.log(textWidth, fitWidth);
if (textWidth > fitWidth) { if (textWidth > fitWidth) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment