Skip to content

Instantly share code, notes, and snippets.

@asharirfan
Created January 14, 2016 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asharirfan/4f22ac5f739931f45480 to your computer and use it in GitHub Desktop.
Save asharirfan/4f22ac5f739931f45480 to your computer and use it in GitHub Desktop.
Owl Carousel 2 (Custom function: triggering actions on base of slide number)
/**
* function for triggering different events
* on base of slide number in
* Owl Carousel 2
* @url (http://www.owlcarousel.owlgraphic.com/)
*/
vr_slider_detailsPage.on('change.owl.carousel', function(event) {
//console.log(event.item.index);
var vr_slide_index = event.item.index;
if ( vr_slide_index == 2 ) {
$('.vr_carousel__pagDiv > div').removeClass('vr_carousel__currentSlide');
$('.vr_carousel__pagDiv:nth-child(2) > div').addClass('vr_carousel__currentSlide');
}
if ( vr_slide_index == 3 ) {
$('.vr_carousel__pagDiv > div').removeClass('vr_carousel__currentSlide');
$('.vr_carousel__pagDiv:nth-child(3) > div').addClass('vr_carousel__currentSlide');
}
if ( vr_slide_index == 4 ) {
$('.vr_carousel__pagDiv > div').removeClass('vr_carousel__currentSlide');
$('.vr_carousel__pagDiv:nth-child(1) > div').addClass('vr_carousel__currentSlide');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment