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
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