Trigger Next Previous click event callback before changed.owl.carousel or translate.owl.carousel

59 views Asked by At

I have an owl carousel on a page.

I need to run some code when the next and prev buttons are clicked before the changed.owl.carousel event callback.

$("#owl-carousel").on("click", ".owl-prev,.owl-next", function() {
  console.log("slide change is triggered"); 
});

$("#owl-demo").on("changed.owl.carousel", function() {
  console.log("slide has changed"); 
});

The problem is that the callback for changed.owl.carousel is triggered before the click events on next and prev buttons.

I've looked around and it seems there's no event that triggers on next and prev buttons click.

One potential solution I can think of is to have custom next and prev buttons that manually triggers transition of slides and I can run some code before.

But I'm looking for a different solution that can support my case. Thank you.

0

There are 0 answers