dojo.dnd.autoScrollNodes
dojo.require("dojo.dnd.autoscroll");
defined in dojo/dnd/autoscroll.js
a handler for onmousemove event, which scrolls the first avaialble Dom element, it falls back to dojo.dnd.autoScroll()
Usage
function (e) (view source)
// FIXME: needs more docs!
for(var n = e.target; n;){
if(n.nodeType == 1 && (n.tagName.toLowerCase() in dojo.dnd._validNodes)){
var s = dojo.getComputedStyle(n);
if(s.overflow.toLowerCase() in dojo.dnd._validOverflow){
var b = dojo._getContentBox(n, s), t = dojo._abs(n, true);
// console.debug(b.l, b.t, t.x, t.y, n.scrollLeft, n.scrollTop);
b.l += t.x + n.scrollLeft;
b.t += t.y + n.scrollTop;
var w = Math.min(dojo.dnd.H_TRIGGER_AUTOSCROLL, b.w / 2),
h = Math.min(dojo.dnd.V_TRIGGER_AUTOSCROLL, b.h / 2),
rx = e.pageX - b.l, ry = e.pageY - b.t, dx = 0, dy = 0;
if(rx > 0 && rx < b.w){
if(rx < w){
dx = -dojo.dnd.H_AUTOSCROLL_VALUE;
}else if(rx > b.w - w){
dx = dojo.dnd.H_AUTOSCROLL_VALUE;
}
}
//console.debug("ry =", ry, "b.h =", b.h, "h =", h);
if(ry > 0 && ry < b.h){
if(ry < h){
dy = -dojo.dnd.V_AUTOSCROLL_VALUE;
}else if(ry > b.h - h){
dy = dojo.dnd.V_AUTOSCROLL_VALUE;
}
}
var oldLeft = n.scrollLeft, oldTop = n.scrollTop;
n.scrollLeft = n.scrollLeft + dx;
n.scrollTop = n.scrollTop + dy;
// if(dx || dy){ console.debug(oldLeft + ", " + oldTop + "\n" + dx + ", " + dy + "\n" + n.scrollLeft + ", " + n.scrollTop); }
if(oldLeft != n.scrollLeft || oldTop != n.scrollTop){ return; }
}
}
try{
n = n.parentNode;
}catch(x){
n = null;
}
}
dojo.dnd.autoScroll(e);
parameter | type | description |
---|
e | | onmousemove event |