_.fn.toggleTreeNode = function(animate) {
var node = this.filter('button');
if(animate) {
node.siblings('ol').slideToggle(animate)
}
else {
node.siblings('ol').toggle();
}
node.parent().toggleClass('closed');
};
You can see here the implementation is customized to the markup I needed for MY tree. CSS handles the rest, as it should.
Just track the actual number of frames an animation has taken so far and the number of frames it needs to take to complete in the time taken. For bonus points re-average your framerate each time an animation ends by keeping track of the number of frames an animation actually was able to take.
And as far as easing goes...
http://www.robertpenner.com/easing/