T
T
tyrion12019-08-21 13:39:41
JavaScript
tyrion1, 2019-08-21 13:39:41

How to scroll Owl.Carousel to clicked slide?

There is a regular Owl/Carousel on the site.
How, when clicking on the previous slide or the next one from the current one, scroll to it?
5d5d1f666c04b736466174.jpeg5d5d1f6cdfbfd636223109.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tyrion1, 2019-08-21
@tyrion1

The solution may be useful to someone
var $owl = $('DOM Element');
$owl.children().each( function( index ) {
$(this).attr( 'data-position', index ); // NB: .attr() instead of .data()
});
$(document).on('click', '.owl-item>div', function() {
$owl.trigger('to.owl.carousel', $(this).data( 'position' ) );
});

L
Lord_Dantes, 2019-08-21
@Lord_Dantes

Alternatively, I would make an invisible block with a left and right button and place it as you indicated using styles, and that's it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question