-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
119 lines (116 loc) · 3.02 KB
/
demo.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>旋转木马轮播图</title>
<link rel="stylesheet" href="css.css"/>
</head>
<body>
<div class="wrap" id="wrap">
<div class="slide" id="slide">
<ul>
<li><a href="#"><img src="images/slidepic1.jpg" alt=""/></a></li>
<li><a href="#"><img src="images/slidepic2.jpg" alt=""/></a></li>
<li><a href="#"><img src="images/slidepic3.jpg" alt=""/></a></li>
<li><a href="#"><img src="images/slidepic4.jpg" alt=""/></a></li>
<li><a href="#"><img src="images/slidepic5.jpg" alt=""/></a></li>
</ul>
<div class="arrow" id="arrow">
<a href="javascript:;" class="prev"></a>
<a href="javascript:;" class="next"></a>
</div>
</div>
</div>
</body>
</html>
<script src="js/animate.js" type="text/javascript"></script>
<script>
var wrap = document.getElementById("wrap"); // 大盒子
var arrow = document.getElementById("arrow"); // 三角
var slider = document.getElementById("slide");
var lis = slider.getElementsByTagName("li"); // 所有要操作的盒子
wrap.onmouseover = function(){
animate(arrow,{opacity:100});
}
wrap.onmouseout = function(){
animate(arrow,{opacity:0});
}
// 存储了每个图片的信息
var json = [
{ // 1
width:400,
top:20,
left:50,
opacity:20,
z:2
},
{ // 2
width:600,
top:70,
left:0,
opacity:80,
z:3
},
{ // 3
width:800,
top:100,
left:200,
opacity:100,
z:4
},
{ // 4
width:600,
top:70,
left:600,
opacity:80,
z:3
},
{ //5
width:400,
top:20,
left:750,
opacity:20,
z:2
}
];
var jieliu = true;
var as = arrow.children;
change();
for(var k in as){
as[k].onclick = function(){
if(this.className == 'prev'){
if(jieliu == true)
{
change(false);
jieliu = false;
}
}
else
{
if(jieliu == true)
{
change(true);
jieliu = false;
}
}
}
}
function change(flag){
if(flag){
json.unshift(json.pop());
}else
{
json.push(json.shift());
}
for(var i=0;i<json.length; i++)
{
animate(lis[i],{
width: json[i].width,
top: json[i].top,
left: json[i].left,
opacity:json[i].opacity,
zIndex:json[i].z
},function(){ jieliu = true;}) // 回调函数是等动画执行完毕 才行
}
}
</script>