Skip to content

Commit 449eff9

Browse files
committed
add button
1 parent 8798d19 commit 449eff9

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

slider/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<li class="slider-item"><img src="images/pic23.gif" alt="3"></li>
1616
<li class="slider-item"><img src="images/pic24.gif" alt="4"></li>
1717
</ul>
18-
<div class="slider-button prev">&lt;</div>
19-
<div class="slider-button next">&gt;</div>
2018
</div>
2119
<script>
22-
Slider('#slider')
20+
Slider('#slider',{
21+
buttons:true
22+
})
2323
</script>
2424
</body>
2525
</html>

slider/slider.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
autoplay: true,
2828
bounceRatio:0.1,
2929
pagination:true,
30+
loop:true,
31+
buttons:false,
3032
paginationClass:'slider-pagination',
3133
bulletClass:'slider-bullet',
32-
bulletActiveClass:'slider-bullet-active',
33-
loop:true
34+
bulletActiveClass:'slider-bullet-active'
3435
};
3536

3637
var isObject = function (obj) {
@@ -123,6 +124,10 @@
123124
this.createLoopItems();
124125
}
125126

127+
if(this.params.buttons){
128+
this.createButtons();
129+
}
130+
126131
if(this.params.autoplay){
127132
this.autoPlay();
128133
}
@@ -184,6 +189,17 @@
184189
this.setActivePagination();
185190
}
186191

192+
fn.createButtons = function(){
193+
var prev = document.createElement('div');
194+
var next = document.createElement('div');
195+
prev.className = 'slider-button prev';
196+
next.className = 'slider-button next';
197+
prev.innerHTML = '&lt;';
198+
next.innerHTML = '&gt';
199+
this.container.appendChild(prev);
200+
this.container.appendChild(next);
201+
}
202+
187203
fn.setActivePagination = function(){
188204
var prevIndex = this.activeBulletIndex;
189205
var activeIndex = this.activeIndex;

0 commit comments

Comments
 (0)