Good evening. Help to display not the number of items in the calculation, but the number of groups of items http://prntscr.com/c40jbw , which include, as in this example, 3 items. thank

jsfiddle.net/vnpm1y06/153 here is an example. but this example counts the number of turquoise blocks, and it is necessary to count the number of screens, i.e. groups of these blocks. in this case, 2 blocks in the group prntscr.com/c40p1r

    1 answer 1

    As an option this.items().length divided by the number of items in the items: 1 block

    script

     var owl = $('.owl-carousel'); var items = 3; owl.owlCarousel({ loop: true, items: items, margin: 10, nav: true, onInitialized: function(e) { $('.counter').text('1 из ' + Math.ceil(this.items().length/items)) console.log(); } }); owl.on('changed.owl.carousel', function(e) { $('.counter').text(Math.ceil((e.item.index - 1)/items) + ' из ' + Math.ceil(e.item.count/items)) }); 

    `

    • He already knows the total amount of the item. - Arnial
    • These values ​​are needed: // Provided by the navigation plugin var pages = event.page.count; // Number of pages var page = event.page.index; // Position of the current page var size = event.page.size; // Number of items per page - Dima
    • @ Dima this data is available only inside the event changed.owl.carousel . In the onInitialized method, onInitialized will onInitialized to use what @Dmitry Kondratiuk suggested. There is no need to save items to a separate variable, this can be obtained through this.settings.items - Arnial