[Help]: Disable mouse dragging while keeping touch dragging #1108
-
SummaryI apologize if this is mentioned in the documentation and I missed it, but is there an “official way” to disable mouse dragging while keeping touch dragging enabled? Specifically, I want the carousel to be swiped using controls only (arrow or dot buttons) when using a mouse, but on mobile devices, I’d like to allow swiping using touch gestures or controls. PS: I'm using the If applicable, which variants of Embla Carousel are relevant to this question?
Additional informationNo response CodeSandbox exampleNo response |
Beta Was this translation helpful? Give feedback.
Answered by
sarussss
Jan 16, 2025
Replies: 1 comment
-
Hi @pepew-le-boss, You can use the watchDrag option: <Carousel
opts={{
watchDrag: (emblaApi, event) => {
// The event parameter here is a TouchEvent or MouseEvent
return 'TouchEvent' in window && event instanceof TouchEvent;
},
}}
>
...
</Carousel> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pepew-le-boss
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @pepew-le-boss,
You can use the watchDrag option: