Skip to content

transition.remove() fix - #2377

Closed
robinhouston wants to merge 1 commit into
d3:masterfrom
robinhouston:transition-remove-fix
Closed

robinhouston wants to merge 1 commit into
d3:masterfrom
robinhouston:transition-remove-fix

Conversation

@robinhouston

Copy link
Copy Markdown

We at Kiln recently noticed that calling .remove() on a transition would not always work as expected (though explicitly removing the element from an .each("end", …) handler did work).

It turns out that it wasn’t working in the situation where the running transition had preempted a transition that had not yet started (due to a delay).

This patch (with test) seems to resolve the problem, though you may have a better idea for how to deal with it. In any case it seems to me that the this[ns].count < 2 check is too simplistic, since there may be transitions with ids less than the active one, that will therefore never run.

@mbostock mbostock added the bug Something isn’t working label Apr 2, 2015
@mbostock mbostock added this to the 3.5.x milestone Apr 2, 2015
@mbostock

mbostock commented Apr 2, 2015

Copy link
Copy Markdown
Member

Interesting. That sounds correct. I should think a bit about whether this is an alternative solution but your approach seems reasonable.

transition.remove() ought to work even when a delayed transition
was preempted by the current transition.
@mbostock

Copy link
Copy Markdown
Member

This is related to d3/d3-timer#5 (and d3/d3-transition#9, #2189), in that if we greedily canceled transitions—rather than waiting for them to self-terminate on start—then the count check would be safe.

mbostock added a commit that referenced this pull request Oct 25, 2015
When a scheduled transition is pre-empted by a newer transition starting, we now
cancel the old transition’s timers immediately, rather than waiting for the old
transition to start.

Fixes #2377. Related #2189.
@mbostock

Copy link
Copy Markdown
Member

Fixed in #2600, merged into #2591 for 3.5.7.

@mbostock mbostock closed this Oct 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn’t working

Development

Successfully merging this pull request may close these issues.

2 participants