File: D:/HostingSpaces/SBogers10/rentman.komma.pro/wwwroot/js/introSlider.js
/**
* Created by Pascal on 30/11/16.
*/
$(function () {
var index = 0;
var maxIndex = 0;
$('.intro-row .image-container .nav ul li').each(function () {
if(maxIndex < $(this).data('button')) maxIndex = $(this).data('button');
});
$('.intro-row .image-container .nav ul li').click(function () {
index = $(this).data('button');
setNewActive(index);
clearInterval(loopAnimation);
loopAnimation = setInterval(nextSlider, 4000);
});
loopAnimation = setInterval(nextSlider, 4000);
$('.intro-row .image-container').swipe({
swipeLeft: function () {
nextSlider();
},
swipeRight: function () {
previousSlider();
}
});
document.onkeydown = function (e) {
if ((e.keyCode || e.which) == 37)
{
nextSlider();
}
if ((e.keyCode || e.which) == 39)
{
previousSlider();
}
}
function nextSlider() {
index++;
if(maxIndex < index) index = 0;
setNewActive(index);
clearInterval(loopAnimation);
loopAnimation = setInterval(nextSlider, 4000);
}
function previousSlider() {
index--;
if(index < 0) index = maxIndex;
setNewActive(index);
clearInterval(loopAnimation);
loopAnimation = setInterval(nextSlider, 4000);
}
});
function setNewActive(i) {
$('.intro-row .image-container .nav ul li.active').removeClass('active');
$('.intro-row .image-container .label span').removeClass('active');
$('.intro-row .image-container span').removeClass('active');
$('.intro-row .image-container .nav ul li[data-button="' + i + '"]').addClass('active');
$('.intro-row .image-container .label span[data-label="' + i + '"]').addClass('active');
$('.intro-row .image-container span[data-image="' + i + '"]').addClass('active');
}