Selections and callbacks - help needed

I am trying to understand the different behavior of
the two visualizations in this notebook:

I want to move a circle around following a mouse. In one case, I call “selectAll” on the circles inside the mousemove callback. In the other, it’s outside the “selectAll” callback. In the first case, I get what I want; in the second, I see a whole trail of circles following the moving mouse – which I don’t want.

I don’t understand what’s happening.

Thanks.

I can answer my own question, and it is illuminating (to me). Rather than try
to write a long explanation here, I updated the notebook to explain the situation here:

1 Like