Skip to content

Commit

Permalink
fix: 🐛 issue with animating text with print animation
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Mar 26, 2020
1 parent 5055370 commit b55f6bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/kittik-shape-fig-text/spec/FigText.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ describe('Shape::FigText', () => {

expect(shape).toBeInstanceOf(FigText);
expect(shape.cursor).toBeInstanceOf(Canvas);
expect(shape.text.length).toEqual(386);
expect(shape.text).toEqual('test');
expect(shape.renderedText.length).toEqual(386);
expect(shape.x).toEqual('0');
expect(shape.y).toEqual('0');
expect(shape.background).toEqual('red');
Expand Down
14 changes: 5 additions & 9 deletions src/kittik-shape-fig-text/src/FigText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,16 @@ export class FigText extends Shape implements FigTextOptions, ShapeRenderable {
}

get width (): string {
const lengths = this.text.split('\n').map(item => item.length);
const lengths = this.renderedText.split('\n').map(item => item.length);
return Math.max(...lengths).toString();
}

get height (): string {
return this.text.split('\n').length.toString();
return this.renderedText.split('\n').length.toString();
}

set text (text: string) {
this._text = text;
}

get text (): string {
return figlet.textSync(this._text, {
get renderedText (): string {
return figlet.textSync(this.text, {
font: this.font,
horizontalLayout: this.horizontalLayout,
verticalLayout: this.verticalLayout,
Expand All @@ -63,7 +59,7 @@ export class FigText extends Shape implements FigTextOptions, ShapeRenderable {

render (): void {
const cursor = this.cursor;
const text = this.text.split('\n');
const text = this.renderedText.split('\n');
const x = parseInt(this.x);
const y = parseInt(this.y);
const background = this.background;
Expand Down

0 comments on commit b55f6bd

Please sign in to comment.