d3.selection.prototype.record = function() { var self = this, tweeners = []; // Get tweeners on each element in the selection self.each(function(d,i){ // using .count should work as long as it's called right after the transition is created? // can use .active if you wait for the "start" event var node = this, pending = this.__transition__[this.__transition__.count], ease = pending.ease; // Loop through the element's tweens d3.values(pending.tween._).forEach(function(tween){ // Create a tweener with the tween function and the element's datum and index var tweener = tween.call(node,d,i).bind(node); // Function that calls the tweener with an eased time value tweeners.push(function(t){ tweener(ease(t)); }); }); }); // Return a function that takes t between 0 and 1 return function(t){ // Interrupt any transitions on the selection self.interrupt(); // Apply every tweener function with the provided value t tweeners.forEach(function(tweener){ tweener(t); }); }; }