Take notice that I have deliberately moved next previous buttons and indicators below the slider. I did this to demonstrate the freedom that you will have when designing your own slider.
<!-- Can be DIV or UL structures -->
<ul id="mySlider" class="my-slider">
<li style="background-image: url('images/branches.jpg')">One</li>
<li style="background-image: url('images/flower.jpg')">Two</li>
<li style="background-image: url('images/shack.jpg')">Three</li>
<li style="background-image: url('images/waterfall.jpg')">Four</li>
</ul>
Click the buttons to see the effect on the slider.
<button id="myPrevious" class="btn btn-default">←</button>
<button id="myNext" class="btn btn-default">→</button>
<!-- default -->
<div id="myIndicators"></div>
<!-- custom -->
<div id="myIndicators">
<img src="one.jpg" alt="your alt text">
<img src="two.jpg" alt="your alt text">
<div>Three</div>
<div><img src="four.jpg" alt="your alt text"></div>
</div>
.gabs-initiated
.gabs-indicator
.gabs-active
<style>
/* .gabs-initiated is added to the slider element when it's initiated */
.my-slider.gabs-initiated ~ .my-previous,
.my-slider.gabs-initiated ~ .my-next {
display: block;
}
/* .gabs-indicator is added to the indicator root element */
.gabs-indicator {
font-size: 30px;
padding: 10px;
}
/* .gabs-active is added to the active indicator child element */
.gabs-active {
color: red;
}
</style>
<script>
var params = {
slider: document.getElementById('mySlider'),
btnNext: document.getElementById('myNext'),
btnPrevious: document.getElementById('myPrevious'),
indicators: document.getElementById('myIndicators')
};
var mySlider = new gaBasicSlider(params);
</script>
Parameter | Type | Default |
---|---|---|
slider | Node | null |
indicators | Node | null |
btnNext | Node | null |
btnPrevious | Node | null |
animate | Boolean | true |
animationDelay | Number (milliseconds) | 6000 |
animationDuration | Number (milliseconds) | 300 |
<script>
// mySlider.start()
document.getElementById('myStart').addEventListener('click', mySlider.start);
// mySlider.stop();
document.getElementById('myStop').addEventListener('click', mySlider.stop);
</script>
<script>
var slider = document.getElementById('mySlider');
slider.addEventListener('initiated', function (e) {
// called when initiated
}, false);
slider.addEventListener('start', function (e) {
// called when animation is started
}, false);
slider.addEventListener('stop', function (e) {
// called when animation is stopped';
}, false);
</script>