-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShare menu分享菜单
66 lines (60 loc) · 1.01 KB
/
Share menu分享菜单
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!Doctype HTML>
<html>
<head>
<meta charset='utf-8'/>
<title></title>
<style>
#div1{
width: 100px;
height: 200px;
background: #ccc;
position: absolute;
left: -100px;
top: 50px;
}
#div2{
width: 20px;
height: 60px;
line-height: 20px;
text-align: center;
background: yellow;
position: absolute;
left: 100px;
top: 70px;
}
</style>
</head>
<body>
<div id="div1">
<div id="div2">分享菜单</div>
</div>
</body>
<script>
var oDiv1 = document.getElementById('div1');
oDiv1.onmouseover = function (){
startMove(0);
}
oDiv1.onmouseout = function (){
startMove(-100);
}
var timer = null;
function startMove(iTarget){
clearInterval(timer);
timer = setInterval(function (){
var iSpeed = 0;
if( oDiv1.offsetLeft < iTarget ){
iSpeed = 10;
}
else{
iSpeed = -10;
}
if(oDiv1.offsetLeft == iTarget){
clearInterval(timer);
}
else{
oDiv1.style.left = oDiv1.offsetLeft + iSpeed + 'px';
}
},30);
}
</script>
</html>