forked from MarcelRaschke/bumbleboss.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slider.js
36 lines (33 loc) · 847 Bytes
/
slider.js
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
/*
AUTHOR: CodingBobby
DATE: 24/08/2018
VERSION: 1.2
*/
let sliderInit = 1;
let sliders = [];
let k = 0;
$(document).find(".slider").each(function() {
sliders.push({
getID: this.id,
slider: this,
slides: this.getElementsByClassName("slide"),
onSlide: sliderInit,
update: function() {
this.onSlide = (this.onSlide > this.slides.length) ? 1:this.onSlide;
this.onSlide = (this.onSlide < 1) ? this.slides.length:this.onSlide;
for(var i = 0; i < this.slides.length; i++) {
this.slides[i].style.display = "none";
}
this.slides[this.onSlide-1].style.display = "grid";
}
});
sliders[k++].update();
});
function moveSlides(clicked,dir) {
let s = clicked.closest(".slider");
let x = sliders.filter(obj => {
return obj.getID == s.id;
})[0];
x.onSlide += dir;
x.update();
}