Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Michal Smolinski on Feb 16, 2009 07:10
open dhtmlx forum
scrolling while dragging in tree

How to speed up scrolling while item is dragged? Scrolling is a real pain if you have to scroll up a few pages to drag item. Is there any way to scroll to the top at once? Like the "home" key? Or scroll with the right scroll-bar while item is dragged?
Answer posted by Alex (support) on Feb 16, 2009 08:56

>> How to speed up scrolling while item is dragged? 

You can make scrolling faster by modification in the dhtmlxtree.js. You can try to increase the step in the _autScroll method: currently this step is 20.

dhtmlXTreeObject.prototype._autoScroll=function(node,a1,a2){
  if (this.autoScroll)
  {
  if (node){
  a1=getAbsoluteTop(node);
  a2=getAbsoluteTop(this.allTree);
  }
  //scroll down
  if ( (a1-a2-parseInt(this.allTree.scrollTop))>(parseInt(this.allTree.offsetHeight)-50) )
  this.allTree.scrollTop=parseInt(this.allTree.scrollTop)+20;
  //scroll top
  if ( (a1-a2)<(parseInt(this.allTree.scrollTop)+30) )
  this.allTree.scrollTop=parseInt(this.allTree.scrollTop)-20;
  }
}

>> Is there any way to scroll to the top at once?

You can try to use focusItem(itemId) to set focus at the first item.

tree.focusItem(tree.getItemIdByIndex(rootId,0));

Answer posted by Michal Smolinski on Feb 17, 2009 07:35
Thanks, the trick with focusItem worked fine for me.