Skip to content

Instantly share code, notes, and snippets.

@brejoc
Created May 24, 2015 18:27
Show Gist options
  • Select an option

  • Save brejoc/5d7c53812291063131bd to your computer and use it in GitHub Desktop.

Select an option

Save brejoc/5d7c53812291063131bd to your computer and use it in GitHub Desktop.
FancyBox2 and Bootstrap Carousel - You spin me round!
/*
With this afterLoad callback, the bootstrap gallery
switches pages with the current image displayed in
the FancyBox modal.
*/
$(".fancybox").fancybox({
loop : false,
afterLoad: function(current, previous) {
if(previous) {
var carouselItems = 6;
if(current.index > previous.index && current.index % carouselItems == 0) {
$('#myCarousel').carousel('next');
} else if(current.index < previous.index && previous.index % carouselItems == 0) {
$('#myCarousel').carousel('prev');
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment