Skip to content

Instantly share code, notes, and snippets.

@munts
Created August 26, 2020 23:57
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 munts/14867582f967bcaeedf4244c2a64b2ca to your computer and use it in GitHub Desktop.
Save munts/14867582f967bcaeedf4244c2a64b2ca to your computer and use it in GitHub Desktop.
change classes on owl items based on active item so that active item can get special treatment, but remove class as it passes by...
$(function(){
$('.loop').on('initialized.owl.carousel translate.owl.carousel', function(e){
idx = e.item.index;
$('.owl-item.active.big').removeClass('big');
$('.owl-item.medium').removeClass('medium');
$('.owl-item').eq(idx).addClass('big');
$('.owl-item').eq(idx-1).addClass('medium');
$('.owl-item').eq(idx+1).addClass('medium');
$('.owl-item').eq(idx+2).addClass('medium');
$('.owl-item').eq(idx+3).addClass('medium');
$('.owl-item').eq(idx+4).addClass('medium');
});
$('.loop').owlCarousel({
center: true,
items:2,
loop:true,
margin:10,
nav: true,
navText: ['<i class="fa fa-arrow-left"></i> ','<i class="fa fa-arrow-right"></i>'],
dots:false,
// autoplay: true,
// autoPlay: 3000
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment