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 "step" events. #46

Closed
mbostock opened this issue Feb 7, 2011 · 5 comments · May be fixed by Skitionek/d3#4
Closed

Transition "step" events. #46

mbostock opened this issue Feb 7, 2011 · 5 comments · May be fixed by Skitionek/d3#4
Milestone

Comments

@mbostock
Copy link
Member

mbostock commented Feb 7, 2011

And possibly allowing "text" tweening.

@xaedes
Copy link

xaedes commented Apr 13, 2011

A simple text tweening implementation I use:

  var textTweenID = 0;
  transition.textTween = function(tween, precision) {

    /** @this {Element} */
    function textTween(d, i) {
      var f = tween.call(this, d, i, this.textContent);
      return function(t) {
        this.textContent = f(t);
      };
    }
    tweens["text." + textTweenID] = textTween;
    textTweenID++;
    return transition;
  };
  
  transition.text = function(value) {

    return transition.textTween(d3_transitionTween(value));
  };

Btw: I would love to see transition "step" events!

@mbostock
Copy link
Member Author

Thanks for the suggestion. Text transitions will be in the next release! See commit @222629a7a774ce15f3c8 for details.

I haven't decided whether to add "step" events yet. I'm a bit worried about the overhead on dispatching every tick times every element, when in the common case there is no step event listener. If I can find a way around that, it should be a no-brainer to add.

@mbostock
Copy link
Member Author

Fixed in 2.0.0, using custom tweens.

@tandu
Copy link

tandu commented Jan 2, 2012

Should I write custom tween as in example above to fire step events?

@mbostock
Copy link
Member Author

mbostock commented Jan 2, 2012

Something like this:

transition.tween("name", function(d, i) {
  return function(t) {
    // this function is called with the easing parameter t in [0,1]
  };
});

The name is used as an identifier so that you can replace the tween later. For example, attr("foo", "bar") uses the name "attr.foo".

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

Successfully merging a pull request may close this issue.

3 participants