This commit is contained in:
Nathan Bierema 2022-12-31 19:29:27 -05:00
parent da544f3e6d
commit 2fd88bd8d0

View File

@ -511,12 +511,17 @@ export default function (
// blink updated nodes // blink updated nodes
node node
.filter(function flick(this: any, d) { .filter(function flick(
this: SVGGElement & {
__oldData__?: HierarchyPointNodeWithPrivateChildren<InternalNode>;
},
d
) {
// test whether the relevant properties of d match // test whether the relevant properties of d match
// the equivalent property of the oldData // the equivalent property of the oldData
// also test whether the old data exists, // also test whether the old data exists,
// to catch the entering elements! // to catch the entering elements!
return this.__oldData__ && d.value !== this.__oldData__.value; return !!this.__oldData__ && d.value !== this.__oldData__.value;
}) })
.select('g') .select('g')
.style('opacity', '0.3') .style('opacity', '0.3')
@ -526,13 +531,13 @@ export default function (
// transition exiting nodes to the parent's new position // transition exiting nodes to the parent's new position
const nodeExit = node const nodeExit = node
.exit() .exit<HierarchyPointNodeWithPrivateChildren<InternalNode>>()
.transition() .transition()
.duration(transitionDuration) .duration(transitionDuration)
.attr('transform', (d) => { .attr('transform', (d) => {
const position = findParentNodePosition( const position = findParentNodePosition(
previousNodePositionsById, previousNodePositionsById,
d.id, d.data.id,
(n) => !!nodePositionsById[n.id] (n) => !!nodePositionsById[n.id]
); );
const futurePosition = const futurePosition =