diff --git a/common/changes/@visactor/vgrammar-core/fix-check-ACustomAnimate_2024-05-11-07-08.json b/common/changes/@visactor/vgrammar-core/fix-check-ACustomAnimate_2024-05-11-07-08.json new file mode 100644 index 00000000..9dd23e1f --- /dev/null +++ b/common/changes/@visactor/vgrammar-core/fix-check-ACustomAnimate_2024-05-11-07-08.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vgrammar-core", + "comment": "fix: adapt custom animation to different vrender version", + "type": "none" + } + ], + "packageName": "@visactor/vgrammar-core" +} \ No newline at end of file diff --git a/packages/vgrammar-core/src/graph/animation/animator.ts b/packages/vgrammar-core/src/graph/animation/animator.ts index cae5d68a..aecc10e1 100644 --- a/packages/vgrammar-core/src/graph/animation/animator.ts +++ b/packages/vgrammar-core/src/graph/animation/animator.ts @@ -21,7 +21,17 @@ Animate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY; let GlobalAnimatorId = 0; const isCustomAnimateCtor = (custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor) => { - return !isNil(custom) && custom.prototype instanceof ACustomAnimate; + if (isNil(custom)) { + return false; + } + return ( + custom.prototype instanceof ACustomAnimate || + // similar to ACustomAnimate, apply for different vrender version + ('onBind' in custom.prototype && + 'onStart' in custom.prototype && + 'onEnd' in custom.prototype && + 'onUpdate' in custom.prototype) + ); }; export class Animator implements IAnimator {