JavaScript.CoolDev.Com Support Forums

Any questions related to JavaScript menu and JavaScript tree menu by Javascript.CoolDev.Com

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Center scrollbar to specific node.

 
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsTree
Author Message
hortonj



Joined: 04 Nov 2008
Posts: 1

PostPosted: Tue Nov 04, 2008 11:34 pm    Post subject: Center scrollbar to specific node. Reply with quote

I am trying to center on a specific node in the left navigation tree when i click on a link to a node on the right frame.

Currently the node will highlight in the left frame but i have to manually center the scrollbar to the node myself. How can I get this to occur automatically?

I am currently using CooltreePro 2.8.7

Thanks
Back to top
Confuzer



Joined: 10 Feb 2010
Posts: 2

PostPosted: Wed Feb 10, 2010 4:54 pm    Post subject: Reply with quote

Well, if you can somehow get the elements ID you can use:

Code:

var desty =  document.getElementById('nttree1_4an').offsetTop;
var thisNode = document.getElementById('nttree1_4an');
while (thisNode.offsetParent && (thisNode.offsetParent != document.body))
{
  thisNode = thisNode.offsetParent;
  desty += thisNode.offsetTop;
}
window.scrollTo(0,desty);


But there is no function to make a match with the element ID and the tree ID... (that I could find). "'nttree1_4an" is one of the id attributes it generated in my tree...
Back to top
Confuzer



Joined: 10 Feb 2010
Posts: 2

PostPosted: Thu Feb 11, 2010 10:15 am    Post subject: Reply with quote

I got a reply from Sergey at got it to work Smile

Code:
var node = tree1.nodeByID("e145");
            if (node)
            {
               var thisNode = node.getLayer();
               var desty = thisNode.offsetTop;
               while (thisNode.offsetParent && (thisNode.offsetParent != document.body))
               {
               thisNode = thisNode.offsetParent;
               desty += thisNode.offsetTop;
               }
               window.scrollTo(0,desty)
            }
Back to top
Display posts from previous:   
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsTree All times are GMT
Page 1 of 1