Skip to content

Instantly share code, notes, and snippets.

@chadsten
Created June 19, 2013 14:47
Show Gist options
  • Select an option

  • Save chadsten/5814893 to your computer and use it in GitHub Desktop.

Select an option

Save chadsten/5814893 to your computer and use it in GitHub Desktop.
jQuery(function($) {
// settings
var $slider = $('.full-images.jquery-load'); // class or id of carousel slider
var $slide = 'li'; // could also use 'img' if you're not using a ul
var $transition_time = 8000; // 1 second
var $time_between_slides = 4000; // 4 seconds
function slides(){
return $slider.find($slide);
}
slides().fadeOut();
// set active classes
slides().first().addClass('active');
slides().first().fadeIn($transition_time);
// auto scroll
//
//1 I WANT THIS TO FIRE WHEN
$interval = setInterval(
function(){
var $i = $slider.find($slide + '.active').index();
slides().eq($i).removeClass('active');
slides().eq($i).fadeOut($transition_time);
if (slides().length == $i + 1) $i = -1; // loop to start
slides().eq($i + 1).fadeIn($transition_time);
slides().eq($i + 1).addClass('active');
}
, $transition_time + $time_between_slides
);
$(document).ready(function() {
$('.jcarousel-item-1').addClass('active-carousel-item');
});
//2 THIS HAPPENS
$(".jcarousel-item").click(function() {
$(this).siblings().removeClass('active-carousel-item');
$(this).addClass('active-carousel-item');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment