Skip to content
Advertisement

Owl Carousel 2 – Getting Active Items

I have an Owl Carousel 2 that’s being generated by a WordPress theme and I’ve set up some custom scripts similar to this:

JavaScript

This places the image caption of the middle image below the carousel in a full-width container.

The issue I’m having is, when I assign the active items to activeEls – it’s grabbing the active items BEFORE the click – rather than after.

Is there any way to wait for the Owl Carousel to update the active items and THEN assign those to activeEls?

OR – is there any way to detect whether the Previous or the Next button was clicked? Right now, I’m only able to detect a change but not which change.

Advertisement

Answer

A .setTimeout() as short as 1ms does the trick here.

JavaScript
JavaScript
JavaScript
Advertisement