-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo7.html
More file actions
206 lines (181 loc) · 4.77 KB
/
demo7.html
File metadata and controls
206 lines (181 loc) · 4.77 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<meta charset="utf-8">
<title>aslider - 動作例</title>
<link rel="stylesheet" href="style.css">
<style>
#slider {
width: 95%;
max-width: 800px;
height: 150px;
border: 1px solid #55a;
margin: 0 auto;
overflow: hidden;
box-shadow: 0px 0px 2px 2px rgba(0, 0, 0, 0.5);
}
#slider ul {
list-style-type: none;
margin: 0;
padding: 0;
display: none;
_width: 999999px !important; /* IE6対策 */
}
#slider li {
margin: 10px 5px;
padding: 0;
border: 1px solid #55a;
float: left;
}
#step {
width: 100%;
position: absolute;
bottom: 0;
margin-bottom: 3px;
}
#move_mark {
margin-top: 5px;
}
#move_mark a {
color: #666;
font-size: 20px;
font-weight: bold;
text-decoration: none;
}
#move_mark a.active, #move_mark a:hover {
color: #333;
}
#slider_link {
margin: 10px 0;
}
#slider_link a {
font-size: 22px;
margin: 0 10px;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="jquery.aslider.min.js"></script>
<script>
$(function () {
var aslider = null;
// デフォルトの状態で生成
$("#create1").click(function () {
$("#slider ul").show();
$("#slider ul li").show();
$(".move").show();
aslider = $("#slider").aslider({
offset: {left: 0.5, top: 0.5}
, elem_offset: {left: -0.5, top: -0.5}
});
aslider.moveByIndex(0, 0);
changeActive(); // 選択状態にする丸印も再設定
return false;
});
// 左上の位置にして生成
$("#create2").click(function () {
$("#slider ul").show();
$("#slider ul li").show();
$(".move").show();
aslider = $("#slider").aslider({
offset: {left: 0, top: 0}
, elem_offset: {left: 0, top: 0}
});
aslider.moveByIndex(0, 0);
changeActive(); // 選択状態にする丸印も再設定
return false;
});
// 2番目の要素を非表示にして生成
$("#create3").click(function () {
$("#slider ul").show();
$("#slider ul li").eq(1).hide();
$(".move").eq(1).hide();
aslider = $("#slider").aslider({
offset: {left: 0.5, top: 0.5}
, elem_offset: {left: -0.5, top: -0.5}
});
aslider.moveByIndex(0, 0);
changeActive(); // 選択状態にする丸印も再設定
return false;
});
// 3番目の要素を選択状態にして生成
$("#create4").click(function () {
$("#slider ul").show();
$("#slider ul li").show();
$(".move").show();
aslider = $("#slider").aslider({
offset: {left: 0.5, top: 0.5}
, elem_offset: {left: -0.5, top: -0.5}
});
aslider.moveByIndex(2, 0); // 0始まりなので3番目の要素なら2にする
changeActive(); // 選択状態にする丸印も再設定
return false;
});
// スライドの各要素リンク
$("#slider li a").click(function() {
if (aslider == null) return false;
var move = aslider.moveByElem($(this).parent());
changeActive(move);
return false;
});
// 丸印リンク
$(".move").click(function () {
if (aslider == null) return false;
var index = $(".move:visible").index(this);
if (index < 0) return false;
var move = aslider.moveByIndex(index);
changeActive(move);
return false;
});
// 選択した丸印のclassを変更
function changeActive(move) {
var index = aslider.getPos(move).index;
$(".move").removeClass("active");
$(".move:visible").eq(index).addClass("active");
}
// スライド幅が固定ではないので変化したときに更新します
$(window).resize(function () {
aslider.init();
});
});
</script>
</head>
<body>
<div id="header">
<div id="header_sub">
<div id="title" class="center">aslider</div>
<div id="title_sub"></div>
</div>
</div>
<div id="content">
<div class="content_sub center">
<h3>動的実行</h3>
<div id="slider_link">
<a id="create1" href="#">デフォルトの状態で生成</a><br>
<a id="create2" href="#">左上の位置にして生成</a><br>
<a id="create3" href="#">2番目の要素を非表示にして生成</a><br>
<a id="create4" href="#">3番目の要素を初期位置にして生成</a>
</div>
<div id="slider">
<ul>
<li><a href="#"><img src="img1.jpg" width="133" height="100"></a></li>
<li><a href="#"><img src="img2.jpg" width="133" height="100"></a></li>
<li><a href="#"><img src="img3.jpg" width="133" height="100"></a></li>
<li><a href="#"><img src="img4.jpg" width="133" height="100"></a></li>
<li><a href="#"><img src="img5.jpg" width="133" height="100"></a></li>
<li><a href="#"><img src="img6.jpg" width="133" height="100"></a></li>
</ul>
</div>
<div id="move_mark">
<a class="move" href="#">●</a>
<a class="move" href="#">●</a>
<a class="move" href="#">●</a>
<a class="move" href="#">●</a>
<a class="move" href="#">●</a>
<a class="move" href="#">●</a>
</div>
<div id="pad"></div>
</div>
</div>
</body>
</html>