| Author |
Message |
hortonj
Joined: 04 Nov 2008 Posts: 1
|
Posted: Tue Nov 04, 2008 11:34 pm Post subject: Center scrollbar to specific node. |
|
|
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
|
Posted: Wed Feb 10, 2010 4:54 pm Post subject: |
|
|
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
|
Posted: Thu Feb 11, 2010 10:15 am Post subject: |
|
|
I got a reply from Sergey at got it to work
| 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 |
|
 |
|