Skip to content

Prevent slide being draggable on some specific elements by a classname or attribute #581

Closed Answered by davidjerleke
huannn1 asked this question in Help
Discussion options

You must be logged in to vote

Hi @huannn1,

Inputs shouldn't trigger any drag interaction. Here's a list of all excluded elements by default that won't trigger drag interactions. As you can see here, the drag interaction is cancelled for these elements.

However, if you want to add custom elements, the way to do it is to use the watchDrag option like so:

const options = {
  watchDrag: (emblaApi, event) => {
    // do your thing here
   
   // return true if Embla should start dragging
   return true
   
   // return false if Embla should cancel dragging
   return false
  }
}

🚨 Please note that you need v8.0.0-rc14 for this to work.

Best,
David

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@plrthink
Comment options

@davidjerleke
Comment options

Answer selected by davidjerleke
Comment options

You must be logged in to vote
0 replies
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
3 participants