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.style(name, function<null>) doesn’t remove style on end. #49

Closed
mbostock opened this issue Jul 14, 2016 · 1 comment
Closed

Comments

@mbostock
Copy link
Member

We do remove the style on transition end in this case:

transition.style("foo", null);

But we don’t in this case:

transition.style("foo", function() { return null; });
@mbostock mbostock self-assigned this Jul 14, 2016
@mbostock mbostock changed the title transition.style(name, function<null>) doesn’t delete style on end. transition.style(name, function<null>) doesn’t remove style on end. Jul 14, 2016
@mbostock
Copy link
Member Author

When the target value is specified as a function, the target value is not known until the tween is initialized and the function is called. And a transition’s tweens are initialized immediately after the transition starts; at that point, it’s too late to register an end event listener, as is done in the constant case. Per the README:

The transition then dispatches a start event to registered listeners. This is the last moment at which the transition may be modified: after starting, the transition’s timing, tweens, and listeners may no longer be changed.

So either: (1) we need to defer the state change from STARTING to STARTED until after the tweens are initialized, allowing them to add or remote transition event listeners (which is a bit confusing since at that point the start event was already dispatched… but probably okay) or (2) we need to use a different mechanism for removing the style after the transition ends, say by registering a tween that removes the style when t === 1 (which is icky because due to easing that could occur at times other than the exact end of the transition) or perhaps a tween that checks that state === ENDING.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant