- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
"use strict"
var carousel = document.getElementById("carousel");
var carouselItems = document.getElementsByClassName("carousel-item");
var carouselIndecarors = document.getElementsByClassName("carousel-indicator");
var carouselActiveInt = 0;
var carouselInterval;
var carouselRefresh = function(){
}
for(var i=0;i<document.getElementsByClassName("carousel-indicator").length;i++){
document.getElementsByClassName("carousel-indicator")[i].onclick = function(){carouselIndecarorChange(this)};
}
var carouselIndecarorChange = function(id){
carouselItems[carouselActiveInt].classList.toggle("carousel-item__active");
carouselIndecarors[carouselActiveInt].classList.toggle("carousel-indicator__active");
carouselActiveInt = id.getAttribute("data-slide-to");
carouselItems[carouselActiveInt].classList.toggle("carousel-item__active");
carouselIndecarors[carouselActiveInt].classList.toggle("carousel-indicator__active");
}
var carouselNext = function(){
console.log(carouselActiveInt);
carouselItems[carouselActiveInt].classList.toggle("carousel-item__active");
carouselIndecarors[carouselActiveInt].classList.toggle("carousel-indicator__active");
if(carouselActiveInt == carouselItems.length-1){
carouselActiveInt=0;
}
else{
carouselActiveInt++;
}
carouselItems[carouselActiveInt].classList.toggle("carousel-item__active");
carouselIndecarors[carouselActiveInt].classList.toggle("carousel-indicator__active");
}
var carouselAutoPlay = function(time){
carouselInterval = setInterval(
function(){carouselNext()},time)
}
carouselAutoPlay(5000);
carousel.onmouseover = function(){clearInterval(carouselInterval)};
carousel.onmouseout = function(){carouselAutoPlay()};