Skip to content

Commit

Permalink
Merge pull request #1753 from VisActor/fix/text-interpolate
Browse files Browse the repository at this point in the history
fix: incorrect interpolate for text attribute
  • Loading branch information
neuqzxy authored Feb 24, 2025
2 parents fbb36b0 + 13194bf commit 143ec08
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vrender-core",
"comment": "fix: issue where NAN appears during the text animation process, #1752",
"type": "none"
}
],
"packageName": "@visactor/vrender-core"
}
2 changes: 1 addition & 1 deletion packages/vrender-core/src/graphic/graphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ export abstract class Graphic<T extends Partial<IGraphicAttribute> = Partial<IGr
nextParsedProps: any,
ratio: number
) {
if (Number.isFinite(nextStepVal)) {
if (Number.isFinite(nextStepVal) && Number.isFinite(lastStepVal)) {
nextAttributes[key] = lastStepVal + (nextStepVal - lastStepVal) * ratio;
return true;
} else if (key === 'fill') {
Expand Down
6 changes: 6 additions & 0 deletions packages/vrender-core/src/graphic/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,12 @@ export class Text extends Graphic<ITextGraphicAttribute> implements IText {
return super.needUpdateTag(key, k);
}

protected _interpolate(key: string, ratio: number, lastStepVal: any, nextStepVal: any, nextAttributes: any) {
if (key === 'text') {
nextAttributes.text = nextStepVal;
}
}

clone(): Text {
return new Text({ ...this.attribute });
}
Expand Down

0 comments on commit 143ec08

Please sign in to comment.