We've encountered issues with beta version (v2.0.0beta2.4 code I think - downloaded 20/04/2015) has issues with adding/removing items.
Removing ONLY ONE item destroys the whole carousel.
and when adding an item, the code doesn't calculate properly the overall width of the slider.
Is this an issue you're aware of?
I've encountered the same, working on a project using Owl Carousel today. Trying to poke through the code to figure out why.
Well, we've roughly pinpointed that the problem is in the event triggering core of Owl.
We're a bit pressed for time to fix it properly, so we've settled on doing things The Naughty Way. Something like this:
var owlCarousel = $('.your-owl-carousel').data('owlCarousel');
owlCarousel.remove(1); // or whatever
works, although it completely bypasses a whole lot of internal updating. This is not a good solution long-term. However, it does indicate that something is askew in the internal event dispatcher.
To make this work, you also need to comment out this line from Owl Carousel's internals:
this.trigger('remove', { content: this._items[position], position: position });
inside Owl.prototype.remove
That's what causes the issue - something in there.
I set up a Codepen that illustrates removing a single item.
$('.owl-carousel').trigger('remove.owl.carousel', [1]);
This successfully removes the second item in the list (the items are 0 indexed).
var owlCarousel = $('.owl-carousel').data('owl.carousel');
owlCarousel.remove(1);
This works as well, but notice it's .data('owl.carousel') not .data('owlCarousel').
This is using the 2.0.0-beta.3 version of Owl Carousel. Both code snippets seem to work, although the dots aren't updated correctly. The last dot isn't removed, and clicking it goes to the first slide.
Aha, I'm using beta 2.4 - in that, the data element is 'owlCarousel'. I'm going to try migrating to beta 3, but it could be a bit messy as I've hacked a lot of Owl to fix its myriad issues (granted, we do push this carousel in ways that are outside its basic scope, adding things like dynamic thumbnails and such). Fun times.
Most helpful comment
I set up a Codepen that illustrates removing a single item.
This successfully removes the second item in the list (the items are 0 indexed).
This works as well, but notice it's
.data('owl.carousel')not.data('owlCarousel').This is using the 2.0.0-beta.3 version of Owl Carousel. Both code snippets seem to work, although the dots aren't updated correctly. The last dot isn't removed, and clicking it goes to the first slide.