You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

47 lines
950 B

//////////////// Drag ////////////////
var dragThis;
function beginDrag() {
dragThis = event.srcElement;
while (dragThis.id.indexOf("ForDrag") == -1) {
dragThis = dragThis.parentElement;
if (dragThis == null)
return;
}
dragThis=SetWin;
oldX = (event.clientX + document.body.scrollLeft);
oldY = (event.clientY + document.body.scrollTop);
}
function dragIt(){
if (dragThis == null) {
return
};
newX = (event.clientX + document.body.scrollLeft);
newY = (event.clientY + document.body.scrollTop);
var distanceX = (newX - oldX);
var distanceY = (newY - oldY);
oldX = newX;
oldY = newY;
dragThis.style.pixelLeft += distanceX;
dragThis.style.pixelTop += distanceY;
event.returnValue = false;
}
function endDrag() {
dragThis = null;
}
function setDrag() {
document.onmousemove = dragIt;
document.onmousedown = beginDrag;
document.onmouseup = endDrag;
oldX=oldY=newX=newY=0, dragThis=null;
}
setDrag();