8000 feat: optimize datazoom animation by xiaoluoHe · Pull Request #4055 · VisActor/VChart · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: optimize datazoom animation #4055

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

Merged
merged 2 commits into from
Jun 25, 2025
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
8000 Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "feat: optimize datazoom animation effect",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}
14 changes: 2 additions & 12 deletions packages/vchart/src/chart/base/base-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1270,22 +1270,12 @@ export class BaseChart<T extends IChartSpec> extends CompilableBase implements I

protected _enableMarkAnimation(states: string | string[]) {
const marks = this.getAllMarks();
marks.forEach(mark => {
const product = mark.getProduct();
if (product && product.animate) {
// product.animate.enableAnimationState(states);
}
});
marks.forEach(mark => mark.enableAnimationByState(states));
}

protected _disableMarkAnimation(states: string | string[]) {
const marks = this.getAllMarks();
marks.forEach(mark => {
const product = mark.getProduct();
if (product && product.animate) {
// product.animate.disableAnimationState(states);
}
});
marks.forEach(mark => mark.disableAnimationByState(states));
}

filterGraphicsByDatum(
Expand Down
19 changes: 18 additions & 1 deletion packages/vchart/src/mark/base/base-mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ export class BaseMark<T extends ICommonSpec> extends GrammarItem implements IMar
this._animationConfig = animationConfig;
}

protected _disabledAnimationStates?: string[] = [];

disableAnimationByState(state: string | string[]) {
const states = array(state);
this._disabledAnimationStates = [...new Set([...this._disabledAnimationStates, ...states])];
}

enableAnimationByState(state: string | string[]) {
const states = array(state);
this._disabledAnimationStates = this._disabledAnimationStates.filter(s => !states.includes(s));
}

/** 布局标记 */
private _skipBeforeLayouted = false;

Expand Down Expand Up @@ -1989,7 +2001,12 @@ export class BaseMark<T extends ICommonSpec> extends GrammarItem implements IMar
}

hasAnimationByState(state: AnimationStateValues) {
if (!state || !this._animationConfig || !(this._animationConfig as any)[state]) {
if (
!state ||
!this._animationConfig ||
!(this._animationConfig as any)[state] ||
this._disabledAnimationStates.includes(state)
) {
return false;
}
const stateAnimationConfig = (this._animationConfig as any)[state];
Expand Down
4 changes: 4 additions & 0 deletions packages/vchart/src/mark/interface/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ export interface IMarkRaw<T extends ICommonSpec> extends ICompilableMark {
runAnimation: () => void;
/** 是否需要清除旧的数据 */
needClear?: boolean;
/** 禁用状态动画 */
disableAnimationByState: (state: string | string[]) => void;
/** 启用状态动画 */
enableAnimationByState: (state: string | string[]) => void;
}

export type IMark = IMarkRaw<ICommonSpec>;
Expand Down
Loading
0