bevacqua / dragula

:ok_hand: Drag and drop so simple it hurts
https://bevacqua.github.io/dragula/
MIT License
21.89k stars 1.97k forks source link

Disabling child's dragging #510

Open arkwl opened 6 years ago

arkwl commented 6 years ago

Hello! Firstly, thank you to the Dragula contributors, major fan of your product.

I have been running into an issue where I want to make only the top 50% of the div inside the bag to be draggable and the other not respond to a click. I was just wondering if there was a way to disable the dragging feature, similar to JQuery's e.stopPropogration().

Thank you in advance.

albohlabs commented 6 years ago

You can use the moves method and and return false for not draggable nodes.

You can define a moves method which will be invoked with (el, source, handle, sibling) whenever an element is clicked. If this method returns false, a drag event won't begin, and the event won't be prevented either. The handle element will be the original click target, which comes in handy to test if that element is an expected "drag handle".

source https://github.com/bevacqua/dragula#optionsmoves