File: D:/HostingSpaces/BVerhoeven/verhoevendak.nl/wwwroot/js/overviewSlider.js
/**
* Created by Pascal on 16/06/17.
*/
var index = 0;
var maxIndex = 1;
var scrolled = 0;
$(function () {
initSlider();
});
function initSlider() {
index = 0;
maxIndex = $('.image-slider figure .image').length - 1;
$('.image-slider .image-slider-nav .nav-button').click(function () {
index = $(this).data('image');
setImage();
});
if (typeof $.swipe === "undefined") rebindTouchSwipe();
$('figure').swipe({
swipeLeft: function () {
nextImage();
},
swipeRight: function () {
index--;
setImage();
}
});
$('.image-slider .slider-bg, .close-button').click(function () {
$('.image-slider').hide();
// $('body').removeClass('preventScroll');
$(window).scrollTop(scrolled);
});
}
function nextImage() {
index++;
setImage();
}
function setImage() {
var previousIndex = index - 1;
var nextIndex = index + 1;
if (previousIndex <= -1) previousIndex = maxIndex;
if (nextIndex > maxIndex) nextIndex = 0;
if (maxIndex < index) index = 0;
if (index < 0) index = maxIndex;
$('.image-slider figure .image').removeClass('active');
$('.image-slider figure .image[data-image="' + index + '"]').addClass('active');
$('.image-slider .image-slider-nav .previous').data('image', previousIndex);
$('.image-slider .image-slider-nav .next').data('image', nextIndex);
}
function showSlider(num) {
index = num;
setImage();
$('.image-slider').show();
scrolled = $(window).scrollTop();
// setTimeout(function(){
// $('body').addClass('preventScroll');
// }, 400);
}