A
A
Alexander Ivanov2018-07-28 09:37:54
JavaScript
Alexander Ivanov, 2018-07-28 09:37:54

How to get the current position of an OWL slider?

<div>slider</div>
<div>текущая позиция</div>

$('.area-range').owlCarousel({
            startPosition: startPos,
            loop: false,
            margin: 30,
            nav: false,
            dots: false,
            responsiveClass:true,
            responsive:{
                0:{
                    items:1
                },
                750:{
                    items:2
                }
            }
        })
    
        // drag.owl.carousel

There is a startPosition parameter by default equal to zero. Is it possible to somehow get the current position, like it has shifted by 1 by 2, etc. ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2018-07-28
@cimonlebedev

I have already written many times, but I will repeat for you:
Remember the golden rule of the developer:
In any incomprehensible situation, see the documentation.
If the documentation did not clarify the situation, see the source codes and objects in the console.

In this case, the documentation https://owlcarousel2.github.io/OwlCarousel2/docs/a... tells us that there are essentially no public methods in the carousel for getting data. There are a bunch of events from which we can learn something, or, by generating them ourselves, influence the behavior.
And then it all depends on your specific case. It may be enough for you to listen to the event changed.owl.carouselto know which slide the carousel has twisted on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question