Skip to content

fix: fix issue of custom type#2013

Merged
xuefei1313 merged 2 commits intodevelopfrom
feat/fix-issue-of-animation-custom-type
Dec 17, 2025
Merged

fix: fix issue of custom type#2013
xuefei1313 merged 2 commits intodevelopfrom
feat/fix-issue-of-animation-custom-type

Conversation

@xuefei1313
Copy link
Contributor

@xuefei1313 xuefei1313 commented Dec 17, 2025

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Site / documentation update
  • Demo update
  • Workflow
  • Release
  • Other (about what?)

🔗 Related issue link

🐞 Bugserver case id

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@xuefei1313 xuefei1313 requested a review from xile611 December 17, 2025 07:45
@xuefei1313 xuefei1313 merged commit 585ef8b into develop Dec 17, 2025
9 of 12 checks passed
@xuefei1313 xuefei1313 deleted the feat/fix-issue-of-animation-custom-type branch December 17, 2025 07:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a bug in the animation custom type detection logic by extracting duplicated code into a reusable utility function. The refactoring reduces code duplication but introduces a critical logic error in one location.

  • Extracts repeated custom type detection logic into a new getCustomType utility function
  • Replaces three instances of duplicated code with calls to the new utility function
  • Adds a conditional check at line 563 that incorrectly determines when to reuse cached custom type values

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/vrender-animate/src/executor/utils.ts New utility function to detect custom animation types (class vs function vs non-function)
packages/vrender-animate/src/executor/animate-executor.ts Refactors duplicate code to use new utility function; introduces conditional logic for custom type caching
common/changes/@visactor/vrender-components/feat-fix-issue-of-animation-custom-type_2025-12-17-07-45.json Changelog entry for vrender-components package
common/changes/@visactor/vrender-animate/feat-fix-issue-of-animation-custom-type_2025-12-17-07-45.json Changelog entry for vrender-animate package

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
const custom = effect.custom ?? AnimateExecutor.builtInAnimateMap[type];
const customType = (effect as any).customType;
const customType = effect.custom ? (effect as any).customType : getCustomType(custom);
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks effect.custom instead of checking if customType already exists on the effect object. This is incorrect because:

  1. At line 562, custom can be either effect.custom OR a built-in animation from AnimateExecutor.builtInAnimateMap[type]
  2. In the parseParams function (lines 173-180), effects that go through the timeline path have customType computed and stored
  3. When effect.custom is not provided but a built-in animation is used, this condition will be false even though customType might already exist on the effect

The condition should check for the presence of customType on the effect, not effect.custom. For example: (effect as any).customType !== undefined ? (effect as any).customType : getCustomType(custom)

Suggested change
const customType = effect.custom ? (effect as any).customType : getCustomType(custom);
const customType =
(effect as any).customType !== undefined ? (effect as any).customType : getCustomType(custom);

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,5 @@
import { isFunction } from '@visactor/vutils';

Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function lacks documentation explaining what the return values (0, 1, 2) represent. Based on the implementation:

  • 0: not a function or falsy value
  • 1: ES6 class constructor
  • 2: regular function

Adding JSDoc documentation would improve code maintainability and help other developers understand the purpose and return values of this function.

Suggested change
/**
* Determines the type of the given `custom` value.
*
* Return values:
* - `0`: `custom` is falsy or not a function.
* - `1`: `custom` is an ES6 class constructor.
* - `2`: `custom` is a regular (non-class) function.
*
* @param custom - The value to check.
* @returns A numeric code indicating the type of `custom`.
*/

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants