Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect interpolate for text attribute #1753

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading