forked from Crise420WMT/crise420wmt.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist_dragFly.html
50 lines (46 loc) · 1.46 KB
/
list_dragFly.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
body{background: silver;cursor: pointer;}
#div1{width:190px;height: 190px;background:url("image/dragFly_tannis.png");border-radius:50%;position: absolute;left: 0;top:0;}
</style>
<script src="js/collsion.js"></script>
<script>
window.onload=function(){
var oDiv=document.getElementById('div1');
var speedX=0;
var speedY=0;
var lastX=0;
var lastY=0;
oDiv.onmousedown=function(ev){
var oEvent=ev||event;
var disX=oEvent.clientX-oDiv.offsetLeft;
var disY=oEvent.clientY-oDiv.offsetTop;
document.onmousemove=function(ev){
var oEvent=ev||event;
var l=oEvent.clientX-disX;
var t=oEvent.clientY-disY;
oDiv.style.left=l+'px';
oDiv.style.top=t+'px';
speedX=l-lastX;
speedY=t-lastY;
lastX=l;
lastY=t;
};
document.onmouseup=function(){
document.onmousemove=null;
document.onmouseup=null;
collsion(oDiv,speedX,speedY);
};
return false;
};
};
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>