Answer the question
In order to leave comments, you need to log in
How to make Owl Carousel events work?
Hello.
The task is to perform some actions after the changed event in the Owl slider.
The documentation says that it can be done in this way
var owl = $('.owl-carousel');
owl.owlCarousel();
// Listen to owl events:
owl.on('changed.owl.carousel', function(event) {
...
})
$('.owl-carousel').owlCarousel({
onDragged: callback
});
function callback(event) {
...
}
var slider = $('.autopark-slider');
slider.owlCarousel({
pagination: false,
navigation: true,
slideSpeed: 444,
paginationSpeed: 333,
singleItem: true,
touchDrag: true,
autoPlay: false,
afterAction: afterAction(),
onDragged: callback,
navigationText: false
});
function callback(event) {
console.log('Этот консоль лог не срабатывает');
}
function afterAction() {
console.log('А этот срабатывает, но только один раз при запуске слайдера');
};
var slider = $('.autopark-slider');
slider.owlCarousel({
pagination: false,
navigation: true,
slideSpeed: 444,
paginationSpeed: 333,
singleItem: true,
touchDrag: true,
autoPlay: false,
afterAction: afterAction(),
onDragged: callback,
navigationText: false
});
function callback(event) {
console.log('Этот консоль лог не срабатывает');
}
function afterAction() {
console.log('А этот срабатывает, но только один раз при запуске слайдера');
};
slider.on('changed.owl.carousel', function(event) {
callback();
});
Answer the question
In order to leave comments, you need to log in
In short, I figured it out myself, this is done through afterMove .
slider.owlCarousel({
pagination: false,
navigation: true,
slideSpeed: 444,
paginationSpeed: 333,
singleItem: true,
touchDrag: true,
autoPlay: false,
// afterInit: afterAction(),
afterMove: callback,
navigationText: false
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question