HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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);
    }

}