var rDrag =
{
o:null,
init:function(o){
o.onmousedown
= this.start;
},
start:function(e){
var
o;
e =
rDrag.fixEvent(e);
e.preventDefault &&
e.preventDefault();
rDrag.o = o = this;
o.x = e.clientX -
rDrag.o.offsetLeft;
o.y = e.clientY - rDrag.o.offsetTop;
document.onmousemove =
rDrag.move;
document.onmouseup =
rDrag.end;
},
move:function(e){
e =
rDrag.fixEvent(e);
var oLeft,oTop;
oLeft =
e.clientX - rDrag.o.x;
oTop = e.clientY -
rDrag.o.y;
rDrag.o.style.left = oLeft +
‘px‘;
rDrag.o.style.top = oTop +
‘px‘;
},
end:function(e){
e =
rDrag.fixEvent(e);
rDrag.o = document.onmousemove =
document.onmouseup = null;
},
fixEvent:
function(e){
if (!e)
{
e =
window.event;
e.target =
e.srcElement;
e.layerX =
e.offsetX;
e.layerY = e.offsetY;
}
return e;
}
}
window.onload =
function(){
var obj =
document.getElementById(‘draggable‘);
rDrag.init(obj);
}
相关文章
- 11-16topcoder srm 701 div1 -3
- 11-16Codeforces Round #345(Div. 2)-651A.水题 651B.。。。 651C.去重操作 真是让人头大
- 11-16Codeforces Round #321 (Div. 2) C Kefa and Park(深搜)
- 11-16Educational Codeforces Round 115 (Rated for Div. 2)
- 11-16#333 Div2 Problem B Approximating a Constant Range(尺取法)
- 11-16DevExpress TreeList 禁止节点拖动到其他节点上
- 11-16img标签在div中水平垂直居中--两种实现方式
- 11-16用CSS3 vh 简单实现DIV全屏居中
- 11-16设置vh使div元素高度充满屏幕
- 11-16codeforces-1140 (div2)