* Plugin drag/drop now can scroll up/down/left/right when touching
the borders. Thanks to onli!
This commit is contained in:
@ -3,6 +3,9 @@
|
|||||||
Version 1.5 ()
|
Version 1.5 ()
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
* Plugin drag/drop now can scroll up/down/left/right when touching
|
||||||
|
the borders. Thanks to onli!
|
||||||
|
|
||||||
* Changed shoutbox plugin. Shoutbox input size is configurable now.
|
* Changed shoutbox plugin. Shoutbox input size is configurable now.
|
||||||
Wrong description for dateformat fixed.
|
Wrong description for dateformat fixed.
|
||||||
(brockhaus)
|
(brockhaus)
|
||||||
|
32
templates/default/dragdrop.js
vendored
32
templates/default/dragdrop.js
vendored
@ -151,6 +151,8 @@ var Drag = {
|
|||||||
BIG_Z_INDEX : 10000,
|
BIG_Z_INDEX : 10000,
|
||||||
group : null,
|
group : null,
|
||||||
isDragging : false,
|
isDragging : false,
|
||||||
|
scrolledY : 0,
|
||||||
|
scrolledX : 0,
|
||||||
|
|
||||||
makeDraggable : function(group) {
|
makeDraggable : function(group) {
|
||||||
group.handle = group;
|
group.handle = group;
|
||||||
@ -288,6 +290,7 @@ var Drag = {
|
|||||||
"SE offset: " + seOffset.toString();*/
|
"SE offset: " + seOffset.toString();*/
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
onMouseMove : function(event) {
|
onMouseMove : function(event) {
|
||||||
event = Drag.fixEvent(event);
|
event = Drag.fixEvent(event);
|
||||||
var group = Drag.group;
|
var group = Drag.group;
|
||||||
@ -317,12 +320,15 @@ var Drag = {
|
|||||||
group.style["opacity"] = 0.75;
|
group.style["opacity"] = 0.75;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: need better constraint API
|
// TODO: need better constraint API
|
||||||
var adjusted = mouse.constrain(group.mouseMin, group.mouseMax);
|
var adjusted = mouse.constrain(group.mouseMin, group.mouseMax);
|
||||||
nwPosition = nwPosition.plus(adjusted.minus(group.dragCoordinate));
|
nwPosition = nwPosition.plus(adjusted.minus(group.dragCoordinate));
|
||||||
nwPosition.reposition(group);
|
nwPosition.reposition(group);
|
||||||
group.dragCoordinate = adjusted;
|
group.dragCoordinate = adjusted;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// once dragging has started, the position of the group
|
// once dragging has started, the position of the group
|
||||||
// relative to the mouse should stay fixed. They can get out
|
// relative to the mouse should stay fixed. They can get out
|
||||||
// of sync if the DOM is manipulated while dragging, so we
|
// of sync if the DOM is manipulated while dragging, so we
|
||||||
@ -335,14 +341,40 @@ var Drag = {
|
|||||||
// changed to be recursive/use absolute offset for corrections
|
// changed to be recursive/use absolute offset for corrections
|
||||||
var offsetBefore = Coordinates.northwestOffset(group, true);
|
var offsetBefore = Coordinates.northwestOffset(group, true);
|
||||||
group.onDrag(nwPosition, sePosition, nwOffset, seOffset);
|
group.onDrag(nwPosition, sePosition, nwOffset, seOffset);
|
||||||
|
|
||||||
|
//sroll window if reaching the border
|
||||||
|
if(event.clientX < 20) {
|
||||||
|
window.scrollBy(-20, 0);
|
||||||
|
Drag.scrolledX = -20;
|
||||||
|
}
|
||||||
|
if (event.clientX > window.innerWidth -20) {
|
||||||
|
window.scrollBy(20, 0);
|
||||||
|
Drag.scrolledX = 20;
|
||||||
|
}
|
||||||
|
if(event.clientY < 20) {
|
||||||
|
window.scrollBy(0, -20);
|
||||||
|
Drag.scrolledY = -20;
|
||||||
|
}
|
||||||
|
if (event.clientY > window.innerHeight -20) {
|
||||||
|
window.scrollBy(0, 20);
|
||||||
|
Drag.scrolledY = 20;
|
||||||
|
}
|
||||||
|
|
||||||
var offsetAfter = Coordinates.northwestOffset(group, true);
|
var offsetAfter = Coordinates.northwestOffset(group, true);
|
||||||
|
|
||||||
|
offsetAfter.x = offsetAfter.x - Drag.scrolledX;
|
||||||
|
offsetAfter.y = offsetAfter.y - Drag.scrolledY;
|
||||||
|
|
||||||
|
|
||||||
if (!offsetBefore.equals(offsetAfter)) {
|
if (!offsetBefore.equals(offsetAfter)) {
|
||||||
var errorDelta = offsetBefore.minus(offsetAfter);
|
var errorDelta = offsetBefore.minus(offsetAfter);
|
||||||
|
Drag.scrolledX = 0;
|
||||||
|
Drag.scrolledY = 0;
|
||||||
nwPosition = Coordinates.northwestPosition(group).plus(errorDelta);
|
nwPosition = Coordinates.northwestPosition(group).plus(errorDelta);
|
||||||
nwPosition.reposition(group);
|
nwPosition.reposition(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user