Skip to content
Discussion options

You must be logged in to vote

Hi @maoi-dev,

Is there a way to dynamically update or lock the drag on a specific axis in embla-carousel-react—using, for example, a dynamic watchDrag callback or another API—so that I can prevent simultaneous dragging in both directions when I have nested carousels (one vertical and one horizontal) without needing to reinitialize the carousel each time the lock state changes?

Thank you for your question. If I understand your question correctly, then yes, it's possible. Embla options are reactive so you don't want to change the state of options because that will trigger a reset of a carousel (and stop any ongoing animation). Simply use a react ref to prevent this:

const isMainCarouselDr…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@doriancottin
Comment options

Answer selected by doriancottin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
resolved This issue is resolved question Question about how to achieve something
2 participants