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

perf: optimize performance when disable animation #6651

Merged
merged 2 commits into from
Dec 19, 2024
Merged

Conversation

Aarebecca
Copy link
Contributor

  • 优化禁用动画场景下的性能
  • 跳过非必须的样式拷贝
  • 更新主题类型

Copy link

Walkthrough

此PR优化了在禁用动画时的性能,避免了不必要的样式深拷贝,并更新了主题类型以支持布尔值。通过这些改进,减少了不必要的计算和内存使用。

Changes

文件 概要
packages/g6/src/runtime/element.ts 优化了动画禁用时的样式处理,避免了不必要的深拷贝。
packages/g6/src/spec/theme.ts 更新了主题类型定义,支持布尔值。
packages/g6/src/utils/animation.ts 优化了动画配置的判断逻辑,减少了不必要的计算。

const { stage = 'enter' } = context;
const { stage = 'enter', animation } = context;

const enableAnimation = animation && this.context.options.animation;

Choose a reason for hiding this comment

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

The introduction of enableAnimation is a good optimization to prevent unnecessary deep copying of styles when animation is disabled. This change should help in reducing memory usage and improving performance.

@Aarebecca Aarebecca merged commit 9be7f4f into v5 Dec 19, 2024
2 checks passed
@Aarebecca Aarebecca deleted the perf/optimize branch December 19, 2024 08:15
@hustcc
Copy link
Member

hustcc commented Dec 19, 2024

这个优化了多少~

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.

2 participants