-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.html
187 lines (165 loc) · 5.91 KB
/
test1.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="css/layui.css" media="all">
<!-- 注意:如果你直接复制所有代码到本地,上述css路径需要改成你本地的 -->
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
<legend>常规轮播</legend>
</fieldset>
<div class="layui-carousel" id="test1" lay-filter="test1">
<div carousel-item="">
<div>条目1</div>
<div>条目2</div>
<div>条目3</div>
<div>条目4</div>
<div>条目5</div>
</div>
</div>
<div class="layui-carousel" id="test2" style="margin-top: 15px;">
<div carousel-item="">
<div>条目1</div>
<div>条目2</div>
</div>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
<legend>设定各种参数</legend>
</fieldset>
<div class="layui-form">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">宽高</label>
<div class="layui-input-inline" style="width: 98px;">
<input type="tel" name="width" value="600" autocomplete="off" placeholder="width" class="layui-input demoSet">
</div>
<div class="layui-input-inline" style="width: 98px;">
<input type="tel" name="height" value="280" autocomplete="off" placeholder="height" class="layui-input demoSet">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">动画类型</label>
<div class="layui-input-block">
<div class="layui-btn-group demoTest" style="margin-top: 5px;">
<button class="layui-btn layui-btn-sm" style="background-color: #5FB878;" data-type="set" data-key="anim" data-value="default">左右切换</button>
<button class="layui-btn layui-btn-sm" data-type="set" data-key="anim" data-value="updown">上下切换</button>
<button class="layui-btn layui-btn-sm" data-type="set" data-key="anim" data-value="fade">渐隐渐显</button>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">箭头状态</label>
<div class="layui-input-block">
<div class="layui-btn-group demoTest" style="margin-top: 5px;">
<button class="layui-btn layui-btn-sm" style="background-color: #5FB878;" data-type="set" data-key="arrow" data-value="hover">悬停显示</button>
<button class="layui-btn layui-btn-sm" data-type="set" data-key="arrow" data-value="always">始终显示</button>
<button class="layui-btn layui-btn-sm" data-type="set" data-key="arrow" data-value="none">不显示</button>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">指示器位置</label>
<div class="layui-input-block">
<div class="layui-btn-group demoTest" style="margin-top: 5px;">
<button class="layui-btn layui-btn-sm" style="background-color: #5FB878;" data-key="indicator" data-type="set" data-value="inside">容器内部</button>
<button class="layui-btn layui-btn-sm" data-type="set" data-key="indicator" data-value="outside">容器外部</button>
<button class="layui-btn layui-btn-sm" data-type="set" data-key="indicator" data-value="none">不显示</button>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">自动切换</label>
<div class="layui-input-block">
<input type="checkbox" name="switch" lay-skin="switch" checked="" lay-text="ON|OFF" lay-filter="autoplay">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label" style="width: auto;">时间间隔</label>
<div class="layui-input-inline" style="width: 120px;">
<input type="tel" name="interval" value="3000" autocomplete="off" placeholder="毫秒" class="layui-input demoSet">
</div>
</div>
</div>
</div>
<div class="layui-carousel" id="test3" lay-filter="test4">
<div carousel-item="">
<div>条目1</div>
<div>条目2</div>
<div>条目3</div>
<div>条目4</div>
<div>条目5</div>
</div>
</div>
<script src="js/layui.js" charset="utf-8"></script>
<!-- 注意:如果你直接复制所有代码到本地,上述js路径需要改成你本地的 -->
<script>
layui.use(['carousel', 'form'], function(){
var carousel = layui.carousel
,form = layui.form;
//常规轮播
carousel.render({
elem: '#test1'
,arrow: 'always'
});
//改变下时间间隔、动画类型、高度
carousel.render({
elem: '#test2'
,interval: 1800
,anim: 'fade'
,height: '120px'
});
//设定各种参数
var ins3 = carousel.render({
elem: '#test3'
});
//图片轮播
carousel.render({
elem: '#test10'
,width: '778px'
,height: '440px'
,interval: 5000
});
//事件
carousel.on('change(test4)', function(res){
console.log(res)
});
var $ = layui.$, active = {
set: function(othis){
var THIS = 'layui-bg-normal'
,key = othis.data('key')
,options = {};
othis.css('background-color', '#5FB878').siblings().removeAttr('style');
options[key] = othis.data('value');
ins3.reload(options);
}
};
//监听开关
form.on('switch(autoplay)', function(){
ins3.reload({
autoplay: this.checked
});
});
$('.demoSet').on('keyup', function(){
var value = this.value
,options = {};
if(!/^\d+$/.test(value)) return;
options[this.name] = value;
ins3.reload(options);
});
//其它示例
$('.demoTest .layui-btn').on('click', function(){
var othis = $(this), type = othis.data('type');
active[type] ? active[type].call(this, othis) : '';
});
});
</script>
<!---->
</body>
</html>