I have dynatree with fixed height and vertical scrollbar.
node.activate(); selects the node i’m searching for, but doesnt move the vertical scrollbar, so i have to scroll manualy to see active node.
How do i scroll it programmaticlly?
Thanks to mar10, I solved this problem:
var activeLi = node.li;
$('#tree').animate({
scrollTop: $(activeLi).offset().top - $('#tree').offset().top + $('#tree').scrollTop()
}, 'slow');
Dynatree does not have a built-in scrollTo functionality.
But you should be able to use one of the existing methods and plugins, once you have the DOM element that you want to make visible.
In your case, you already seem to have a
nodeobject, so you can get the the associated<li>and<span>tag usingnode.liornode.span.In general you can get the active node at any time by calling
then get the associated DOM element:
or handle the activation event:
Once you have the element, use a standard method:
Scroll to a div using jquery ,
jQuery scroll to element ,
How to scroll to an element in jQuery? ,
…
Edit 2014-05 Starting with Fancytree 2.0 autoScroll was added as a standard option.