-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix react node destruction logic (#5787)
* fix: fix unexpect drag-canvas update * refactor(elements): define base-element * fix: fix html and react node destroy logic * test: update test case
- Loading branch information
Showing
8 changed files
with
147 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { IAnimation } from '@antv/g'; | ||
import { Keyframe } from '../types'; | ||
import type { BaseShapeStyleProps } from './shapes'; | ||
import { BaseShape } from './shapes'; | ||
|
||
export abstract class BaseElement<T extends BaseShapeStyleProps> extends BaseShape<T> { | ||
public get parsedAttributes() { | ||
return this.attributes as Required<T>; | ||
} | ||
|
||
/** | ||
* <zh/> 动画帧执行函数 | ||
* | ||
* <en/> Animation frame execution function | ||
*/ | ||
protected onframe() {} | ||
|
||
public animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions | undefined): IAnimation | null { | ||
const animation = super.animate(keyframes, options); | ||
|
||
if (animation) { | ||
animation.onframe = () => this.onframe(); | ||
animation.finished.then(() => this.onframe()); | ||
} | ||
|
||
return animation; | ||
} | ||
|
||
/** | ||
* <zh/> 在元素完成创建并执行完入场动画后调用 | ||
* | ||
* <en/> Called after the element is created and the entrance animation is completed | ||
* @override | ||
*/ | ||
public onCreate() {} | ||
|
||
/** | ||
* <zh/> 在元素更新并执行完过渡动画后调用 | ||
* | ||
* <en/> Called after the element is updated and the transition animation is completed | ||
* @override | ||
*/ | ||
public onUpdate() {} | ||
|
||
/** | ||
* <zh/> 在元素完成退场动画并销毁后调用 | ||
* | ||
* <en/> Called after the element completes the exit animation and is destroyed | ||
* @override | ||
*/ | ||
public onDestroy() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters