diff --git a/common/changes/@visactor/vrender-animate/feat-fix-issue-of-animation-custom-type_2025-12-17-07-45.json b/common/changes/@visactor/vrender-animate/feat-fix-issue-of-animation-custom-type_2025-12-17-07-45.json new file mode 100644 index 000000000..bc52f37cb --- /dev/null +++ b/common/changes/@visactor/vrender-animate/feat-fix-issue-of-animation-custom-type_2025-12-17-07-45.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: fix issue of custom type\n\n", + "type": "none", + "packageName": "@visactor/vrender-animate" + } + ], + "packageName": "@visactor/vrender-animate", + "email": "lixuef1313@163.com" +} \ No newline at end of file diff --git a/common/changes/@visactor/vrender-components/feat-fix-issue-of-animation-custom-type_2025-12-17-07-45.json b/common/changes/@visactor/vrender-components/feat-fix-issue-of-animation-custom-type_2025-12-17-07-45.json new file mode 100644 index 000000000..571895cb1 --- /dev/null +++ b/common/changes/@visactor/vrender-components/feat-fix-issue-of-animation-custom-type_2025-12-17-07-45.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: fix issue of custom type\n\n", + "type": "none", + "packageName": "@visactor/vrender-components" + } + ], + "packageName": "@visactor/vrender-components", + "email": "lixuef1313@163.com" +} \ No newline at end of file diff --git a/packages/vrender-animate/src/executor/animate-executor.ts b/packages/vrender-animate/src/executor/animate-executor.ts index dce97e05a..e0797f57a 100644 --- a/packages/vrender-animate/src/executor/animate-executor.ts +++ b/packages/vrender-animate/src/executor/animate-executor.ts @@ -12,6 +12,7 @@ import type { IAnimationChannelInterpolator } from './executor'; import { cloneDeep, isArray, isFunction } from '@visactor/vutils'; +import { getCustomType } from './utils'; interface IAnimateExecutor { execute: (params: IAnimationConfig) => void; @@ -171,8 +172,7 @@ export class AnimateExecutor implements IAnimateExecutor { duration: (slice.duration as number) * scale, effects: effects.map(effect => { const custom = effect.custom ?? AnimateExecutor.builtInAnimateMap[(effect.type as any) ?? 'fromTo']; - const customType = - custom && isFunction(custom) ? (/^class\s/.test(Function.prototype.toString.call(custom)) ? 1 : 2) : 0; + const customType = getCustomType(custom); return { ...effect, custom, @@ -198,12 +198,7 @@ export class AnimateExecutor implements IAnimateExecutor { (params as IAnimationTypeConfig).custom ?? AnimateExecutor.builtInAnimateMap[(params as IAnimationTypeConfig).type ?? 'fromTo']; - const customType = - parsedParams.custom && isFunction(parsedParams.custom) - ? /^class\s/.test(Function.prototype.toString.call(parsedParams.custom)) - ? 1 - : 2 - : 0; + const customType = getCustomType(parsedParams.custom); parsedParams.customType = customType; if (totalTime) { @@ -565,7 +560,7 @@ export class AnimateExecutor implements IAnimateExecutor { from = parsedFromProps.from; } const custom = effect.custom ?? AnimateExecutor.builtInAnimateMap[type]; - const customType = (effect as any).customType; + const customType = effect.custom ? (effect as any).customType : getCustomType(custom); this._handleRunAnimate( animate, custom, diff --git a/packages/vrender-animate/src/executor/utils.ts b/packages/vrender-animate/src/executor/utils.ts new file mode 100644 index 000000000..a34e9f523 --- /dev/null +++ b/packages/vrender-animate/src/executor/utils.ts @@ -0,0 +1,5 @@ +import { isFunction } from '@visactor/vutils'; + +export function getCustomType(custom: any): number { + return custom && isFunction(custom) ? (/^class\s/.test(Function.prototype.toString.call(custom)) ? 1 : 2) : 0; +}