Created
January 18, 2015 23:20
-
-
Save mikemcalister/d477a51cd239a06d44d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This carousel works like it should, but has a little hiccup on mobile where it doesn't calculate the width properly sometimes. If you rotate your phone to landscape and back to portrait, it kicks the carousel back into place. The fix would be to trigger a refresh after the carousel is initialized, so that it recalculates but I can't get it to take. | |
// Helpful links: | |
// See the bug on mobile here: https://preview.arraythemes.com/camera/2014/01/18/test-gallery/ | |
// Owl events: http://www.owlcarousel.owlgraphic.com/docs/api-events.html#refresh-owl-carousel | |
// On how to initialize: https://github.com/OwlFonk/OwlCarousel2/issues/489 | |
// Owl Carousel | |
function run_owl() { | |
// Initialize each carousel independently | |
$( ".owl-carousel" ).each( function() { | |
var $carousel = $( this ); //.owl-carousel | |
var $gallery = $( this ).parent(); //.owl-gallery | |
$carousel.owlCarousel( { | |
items : 1, | |
navSpeed : 500, | |
paginationSpeed : 400, | |
autoWidth: true, | |
margin : 15, | |
loop : true, | |
center : true | |
} ); | |
}); | |
} | |
run_owl(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi guys,
It looks like the autoWidth setting is causing my issue here. I've done a check on the viewport size to toggle the autoWidth setting off on mobile. Looks like it does the trick so far, but I'll test it a bit further in the AM. Thanks for your help!