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

Easier syntax for looped transitions? #2423

Closed
mbostock opened this issue May 7, 2015 · 1 comment
Closed

Easier syntax for looped transitions? #2423

mbostock opened this issue May 7, 2015 · 1 comment
Milestone

Comments

@mbostock
Copy link
Member

mbostock commented May 7, 2015

This isn’t a particularly constructive comment, but I’m writing it down anyway. I find the syntax for chained transitions to be difficult to remember, e.g.,

selection.transition()
    .duration(2500)
    .delay(function(d) { return d * 40; })
    .each(slide);

function slide() {
  var circle = d3.select(this);
  (function repeat() {
    circle = circle.transition()
        .attr("cx", width)
      .transition()
        .attr("cx", 0)
        .each("end", repeat);
  })();
}

First you have a selection, then an initial transition, but then you call transition.each to create a selection again, before using a self-executing closure that overwrites itself, and circle is initially a selection but then later a transition… blech.

@mbostock mbostock added the req label Oct 21, 2015
@mbostock mbostock added this to the Icebox milestone Oct 21, 2015
@mbostock mbostock modified the milestones: 4.0, Icebox Mar 1, 2016
@mbostock
Copy link
Member Author

mbostock commented Mar 1, 2016

d3-transition adds d3.active, so this is much easier in D3 4.0.

@mbostock mbostock closed this as completed Mar 1, 2016
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