Jump to content
Search Community

Using a "handle" touchpoint to manipulate a draggable object - allowing for form interaction

waldrus test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I am looking to have a form-modal presented using the Draggable plugin. However - I've been encountering an issue where the form fields are not intractable (I suspect due to the inline `style="touch-action: none;"` style that is embedded into all children of the Draggable element)

My approach to get around this was to create a "handle" element, a child that acts as the point of contact when dragging the parent, so that only it's children would receive the `touch-action` attributes.

Is this a sound approach?

If so, I keep hitting a point where both the handle and the parent are being dragged - and transform attributes are being applied to both elements. I do not want the handle to ever change its relative position to the parent... But at the moment they're dragging, and accelerating, at different speeds

Any insight would be appreciated, thank you :)

Link to comment
Share on other sites

  • Solution

Yep, it looks like React adds an onclick handler on the root element. When you set dragClickables: false, Draggable will check to see if the element is a link, button, textarea, etc. and it'll also check to see if it's inside an element that meets any of the "clickable" criteria. One of those criteria is if the element has an onclick handler defined. So again, since React assigns one to the root element, that essentially makes everything get flagged as "clickable". 


I'm going to update Draggable to remove that criterion to avoid this, but in the meantime you can easily work around it using the clickableTest function: 


const clickableTagExp = /^(?:a|input|textarea|button|select)$/i;
const isClickable = (element, data) => !element || !element.getAttribute || element === document.body ? false : (data = element.getAttribute("data-clickable")) === "true" || (data !== "false" && (clickableTagExp.test(element.nodeName + "") || element.getAttribute("contentEditable") === "true")) ? true : isClickable(element.parentNode);

Draggable.create(... {
  clickableTest: isClickable


Does that clear things up? 

  • Like 3
Link to comment
Share on other sites

Thank you Jack (and Cassie!), I appreciate you both jumping in here. Yes, the const clickableTagExp = /^(?:a|input|textarea|button|select)$/i; is a great solution for me moving forward.
Thanks again

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...