Skip to content

Visualize Your Ideas With Code

fix(2d): fix text height when tweening (#1118)

Jacobdc4f71bd2557
diff --git a/packages/2d/src/lib/components/Txt.ts b/packages/2d/src/lib/components/Txt.ts
index 9d524dea..797402a9 100644
--- a/packages/2d/src/lib/components/Txt.ts
+++ b/packages/2d/src/lib/components/Txt.ts
@@ -117,8 +117,11 @@ export class Txt extends Shape {
const newSize = this.size();
leaf.text(oldText ?? DEFAULT);
- if (this.height() === 0) {
+ const oldHeight = this.height();
+ if (oldHeight === 0) {
this.height(newSize.height);
+ } else if (newSize.height === 0) {
+ newSize.height = oldHeight;
}
yield* all(