File: D:/HostingSpaces/SBogers10/signmania.komma.pro/wwwroot/js/clients.js
/**
* Created by Pascal on 03/11/17.
*/
$(function(){
initClients();
});
var indexClients = 0;
var maxIndexClients = 1;
var interval = 5500;
function initClients() {
indexClients = 0;
maxIndexClients = $('.clients-grid .group').length - 1;
$('.clients-grid .controller').click(function () {
if($(this).hasClass('next')) indexClients++;
if($(this).hasClass('previous')) indexClients--;
//console.log(indexClients);
setClients();
resetInterval();
});
// reset interval if already has been set, because of the ajax content pages
if(typeof loopAnimation !== 'undefined') clearInterval(loopAnimation);
loopAnimation = setInterval(function () {
indexClients++;
setClients();
}, interval);
if( typeof $.swipe === "undefined") rebindTouchSwipe();
$('.ajax-container .clients-grid').swipe({
swipeLeft: function () {
indexClients++;
resetInterval();
setClients();
},
swipeRight: function () {
indexClients--;
resetInterval();
setClients();
}
});
function setClients() {
if(maxIndexClients < indexClients) indexClients = 0;
if(indexClients < 0) indexClients = maxIndexClients;
$('.clients-grid .group').removeClass('active');
$('.clients-grid .group').eq(indexClients).addClass('active');
}
function resetInterval() {
clearInterval(loopAnimation);
loopAnimation = setInterval(function () {
indexClients++;
setClients();
}, interval);
}
}