Stiller Eugen
Stiller Eugen

Reputation: 701

owl carousel v2 navigation only if more then 2 slides

I'm using owl carousel v2 (because of the infinity loop). In version 1.3 if you had only one div-Slide, the navigation wasn't shown. In v2 the nav is always shown, how can i change that as on v1.3.

My code:

 $("#XX").owlCarousel({
         center: true,
         items: 1,
         nav: true
     });

Thanks for help.

Regards thomas

Upvotes: 1

Views: 1810

Answers (2)

p0d4r14n
p0d4r14n

Reputation: 681

I would not modify the core file. OwlCarousel has a good API and options implemented to make it without touching the .js file.

// Init owl-carousel and get your owlcarousel data
$('.owl-carousel').owlCarousel({});
var carousel = $('.owl-carousel').data('owlCarousel');

// and then you can use this function on window resize or do whatever you like
if (carousel._items.length <= carousel.settings.items) {
   carousel.settings.nav = false;
}

Upvotes: 1

joseantgv
joseantgv

Reputation: 2023

Modify file owl.carousel.js, function

Owl.prototype.optionsLogic = function()

Add the following:

if (this._items.length <= this.settings.items) {
    this.settings.nav = false;
}

Upvotes: 0

Related Questions