Jump to content
Search Community

Canceling the drag event with the right click

MR FIX IT test
Moderator Tag

Recommended Posts

9 hours ago, GreenSock said:

I'm not sure what you mean. By default, Draggable has allowContextMenu set to false so that right-clicking (which normally brings up the context menu in the browser natively) doesn't interfere. You can set it to true if you prefer. 

just to clarify my question I want add an add event listener during the onDrag event so while I'm dragging my element if I right clicked I re-place the draggable element where it was ... is there a way of doing that??  

Link to comment
Share on other sites

Heya, thanks for being part of Club GreenSock 🥳!

 

You can still use normal event listeners alongside Draggable. Not everything has to be done with the methods available to you from GSAP. I guess you'd just need a way to tell if the user is dragging and then listen for right clicks and check that. I assume as Jack said that allowContextMenu would have to be true so that the event fires and then in the event listener you'd have to prevent default to avoid the popup menu...

Maybe this sort of thing will work? I can't actually test it to see though because I'm using a touchpad at the moment - so I can't drag and right click simultaneously.
(Probably a little sign that you shouldn't be hiding functionality behind this interaction as it's not going to be possible for every user)

See the Pen YzaJdKv?editors=0010 by GreenSock (@GreenSock) on CodePen

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...