Commit a3cc2936 authored by Eugene Lazutkin's avatar Eugene Lazutkin

Implemented autoscroll. Tested on FF, IE, Op, and Safari -- the last two...

Implemented autoscroll. Tested on FF, IE, Op, and Safari -- the last two suffer from giblets --- probably need to file bugs to them. Implemented a condenced version of getViewport(). It is quite small --- probably it should go to html.js.
Fixes #1597.

git-svn-id: http://svn.dojotoolkit.org/src/dojo/trunk@9372 560b804f-0ae3-0310-86f3-f6aa0a117693
parent 8fe2d5c3
......@@ -17,4 +17,40 @@ dojo.dnd.getUniqueId = function(){
id = "dojoUnique" + (++dojo.dnd._uniqueId);
}while(dojo.byId(id));
return id;
};
dojo.dnd.getViewport = function(){
// summary: returns a viewport size (visible part of the window)
var d = dojo.doc, dd = d.documentElement, w = window, b = dojo.body();
if(dojo.isMozilla){
return {w: dd.clientWidth, h: w.innerHeight}; // Object
}else if(!dojo.isOpera && w.innerWidth){
return {w: w.innerWidth, h: w.innerHeight}; // Object
}else if (!dojo.isOpera && dd && dd.clientWidth){
return {w: dd.clientWidth, h: dd.clientHeight}; // Object
}else if (b.clientWidth){
return {w: b.clientWidth, h: b.clientHeight}; // Object
}
return null; // Object
};
dojo.dnd.V_TRIGGER_AUTOSCROLL = 32;
dojo.dnd.H_TRIGGER_AUTOSCROLL = 32;
dojo.dnd.V_AUTOSCROLL_VALUE = 16;
dojo.dnd.H_AUTOSCROLL_VALUE = 16;
dojo.dnd.autoScroll = function(e){
var v = dojo.dnd.getViewport(), dx = 0, dy = 0;
if(e.clientX < dojo.dnd.H_TRIGGER_AUTOSCROLL){
dx = -dojo.dnd.H_AUTOSCROLL_VALUE;
}else if(e.clientX > v.w - dojo.dnd.H_TRIGGER_AUTOSCROLL){
dx = dojo.dnd.H_AUTOSCROLL_VALUE;
}
if(e.clientY < dojo.dnd.V_TRIGGER_AUTOSCROLL){
dy = -dojo.dnd.V_AUTOSCROLL_VALUE;
}else if(e.clientY > v.h - dojo.dnd.V_TRIGGER_AUTOSCROLL){
dy = dojo.dnd.V_AUTOSCROLL_VALUE;
}
window.scrollBy(dx, dy);
};
\ No newline at end of file
......@@ -95,6 +95,7 @@ dojo.extend(dojo.dnd.Manager, {
// e: Event: mouse event
var a = this.avatar;
if(a){
dojo.dnd.autoScroll(e);
dojo.marginBox(a.node, {l: e.pageX + this.OFFSET_X, t: e.pageY + this.OFFSET_Y});
var copy = Boolean(this.source.copyState(dojo.dnd.getCopyKeyState(e)));
if(this.copy != copy){
......
......@@ -30,6 +30,7 @@ dojo.extend(dojo.dnd.Mover, {
onMouseMove: function(e){
// summary: event processor for onmousemove
// e: Event: mouse event
dojo.dnd.autoScroll(e);
var m = this.marginBox;
dojo.marginBox(this.node, {l: m.l + e.pageX, t: m.t + e.pageY});
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment