Skip to content
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
2 changes: 2 additions & 0 deletions packages/vchart/src/animation/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export interface CommonAnimationConfigItem {
options?: GraphicFunctionValueType<any>;
/** 动画执行相关控制配置项 */
controlOptions?: IAnimationControlOptions;
/** 该动画是否需要忽略子图元 */
selfOnly?: boolean;
}

export interface TypeAnimationConfig extends CommonAnimationConfigItem {
Expand Down
37 changes: 24 additions & 13 deletions packages/vchart/src/mark/base/base-mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,36 @@ export class BaseMark<T extends ICommonSpec> extends GrammarItem implements IMar
return this._animationConfig;
}
setAnimationConfig(config: Partial<MarkAnimationSpec>) {
// group mark 动画默认只挂到自己
const defaultPrams = this.type === 'group' ? { selfOnly: true } : {};

// 封装options,批量添加一些默认参数
const animationConfig = { ...config };
Object.keys(animationConfig).forEach(key => {
const value = (animationConfig as any)[key];
const animationConfig: Partial<MarkAnimationSpec> = {};

Object.keys(config).forEach(key => {
const value = (config as any)[key];
if (isArray(value)) {
value.forEach(item => {
(animationConfig as any)[key] = value.map(item => {
const options = item!.options ?? {};
item.options = (...args: any[]) => {
const _options = typeof options === 'function' ? options(...args) : options;
return {
..._options,
layoutRect: (this.model as any).getLayoutRect?.()
};

return {
...defaultPrams,
...item,
options: (...args: any[]) => {
const _options = typeof options === 'function' ? options(...args) : options;
return {
..._options,
layoutRect: (this.model as any).getLayoutRect?.()
};
}
};
});
} else {
(animationConfig as any)[key] = {
...defaultPrams,
...(config as any)[key]
};
}
// if (isNil(animationConfig[key])) {
// animationConfig[key] = {};
// }
});
this._animationConfig = animationConfig;
}
Expand Down
Loading