Skip to content

Instantly share code, notes, and snippets.

@mariojankovic
Last active August 29, 2015 14:15
Show Gist options
  • Save mariojankovic/827427be552ea0cdef6d to your computer and use it in GitHub Desktop.
Save mariojankovic/827427be552ea0cdef6d to your computer and use it in GitHub Desktop.
This is a simple navigation/tab example for slick slider.
var afterChange = false;
$('.js-HomeSlider').slick({
arrows: false,
dots: false
});
$('.js-HomeSlider').on('beforeChange', function(event, slick, currentSlide, nextSlide) {
afterChange = true;
});
$('.js-HomeSlider').on('afterChange', function(event, slick, currentSlide, nextSlide) {
afterChange = false;
});
// Slick slider navigation
var $sliderNav = $('.js-SliderNav');
$sliderNav.find('li:first-child').find('a').addClass('is-Active');
$sliderNav.find('a').click(function() {
console.log(afterChange);
if(afterChange === false) {
var index = $(this).parent().index();
var $targetSlider = $($sliderNav.data('nav'));
$sliderNav.find('a').removeClass('is-Active');
$(this).addClass('is-Active');
$targetSlider[0].slick.slickGoTo(parseInt(index));
}
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment