Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transition.remove() fix #2377

Closed
wants to merge 1 commit into from

Conversation

robinhouston
Copy link

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
Copy link
Member

mbostock commented Apr 2, 2015

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
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
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.

None yet

2 participants