Ovilia commented on code in PR #18491:
URL: https://github.com/apache/echarts/pull/18491#discussion_r1241097964
##########
src/chart/tree/TreeView.ts:
##########
@@ -603,28 +603,46 @@ function removeNodeEdge(
data: SeriesData,
group: graphic.Group,
seriesModel: TreeSeriesModel,
- removeAnimationOpt: AnimationOption
+ removeAnimationOpt: AnimationOption,
+ currentSymbol?: TreeSymbol,
+ sourceSymbol?: TreeSymbol
) {
const virtualRoot = data.tree.root;
const { source, sourceLayout } = getSourceNode(virtualRoot, node);
- const symbolEl: TreeSymbol = data.getItemGraphicEl(node.dataIndex) as
TreeSymbol;
+ // use the current symbol when the node is delete immediately
+ const symbolEl: TreeSymbol = data.getItemGraphicEl(node.dataIndex) as
TreeSymbol ?? currentSymbol;
if (!symbolEl) {
return;
}
- const sourceSymbolEl = data.getItemGraphicEl(source.dataIndex) as
TreeSymbol;
- const sourceEdge = sourceSymbolEl.__edge;
+ // use the source symbol when the node is delete immediately
+ const sourceSymbolEl = data.getItemGraphicEl(source.dataIndex) as
TreeSymbol ?? sourceSymbol;
+ const sourceEdge = sourceSymbolEl?.__edge;
+
+
+ const symbolChildren = source.children.map(
+ item => data.getItemGraphicEl(item.dataIndex)
+ ).filter(item => !!item);
Review Comment:
For compatibility consideration, we should use `zrUtil.filter` instead of
`Array.filter`. See `zrender/src/core/util.ts`.
##########
src/chart/tree/TreeView.ts:
##########
@@ -603,28 +603,46 @@ function removeNodeEdge(
data: SeriesData,
group: graphic.Group,
seriesModel: TreeSeriesModel,
- removeAnimationOpt: AnimationOption
+ removeAnimationOpt: AnimationOption,
+ currentSymbol?: TreeSymbol,
+ sourceSymbol?: TreeSymbol
) {
const virtualRoot = data.tree.root;
const { source, sourceLayout } = getSourceNode(virtualRoot, node);
- const symbolEl: TreeSymbol = data.getItemGraphicEl(node.dataIndex) as
TreeSymbol;
+ // use the current symbol when the node is delete immediately
+ const symbolEl: TreeSymbol = data.getItemGraphicEl(node.dataIndex) as
TreeSymbol ?? currentSymbol;
if (!symbolEl) {
return;
}
- const sourceSymbolEl = data.getItemGraphicEl(source.dataIndex) as
TreeSymbol;
- const sourceEdge = sourceSymbolEl.__edge;
+ // use the source symbol when the node is delete immediately
+ const sourceSymbolEl = data.getItemGraphicEl(source.dataIndex) as
TreeSymbol ?? sourceSymbol;
+ const sourceEdge = sourceSymbolEl?.__edge;
+
+
+ const symbolChildren = source.children.map(
+ item => data.getItemGraphicEl(item.dataIndex)
+ ).filter(item => !!item);
+ const notLeaveChildren = symbolChildren.filter(
+ item => !item?.animators?.length || item?.animators?.find(animator =>
animator.scope !== 'leave')
Review Comment:
It's probaly not a good idea to check `item.animators` to know if there is
series animation. You should probably use `animatableModel &&
animatableModel.isAnimationEnabled()` instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]