Jump to content
GreenSock

justin_hackin

Draggable right click

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

One thing I noticed with Draggable plugin is that when you right-click a Draggable element and then click outside the context menu, the mouse stays in the mousedown state dragging the object until you click again.  This is an undesirable feature for my application.  Any suggestions on how to disable this behavior ?

Link to comment
Share on other sites

Hi Justin,

 

Maybe by "controlling" the right-click event. So you could temporarily disable the Draggable.

 

Although to date I didn’t personally do much in regards of right-clicks in HTML5, I think "oncontextmenu" is the event to listen to.

Link to comment
Share on other sites

Please check that you're using the latest update of Draggable as well as TweenLite, Max and CSS Plugin.

 

Also it'd be very helpful if you could provide a reduce sample illustrating the issue.

 

I've tried several Draggable samples and I haven't been able to reproduce the issue you're referring to. The right click is in an element nested inside the Draggable's target or the target itself?. If it's in a nested one, what you could do is prevent the event bubbling up, but as stated before I don't see any issues with the mouse right button.

 

Rodrigo.

  • Like 1
Link to comment
Share on other sites

Yeah, im not seeing that behavior with right click either...

 

What browser, browser version, and operating system are you seeing this behavior on? 

Link to comment
Share on other sites

If I go here http://www.greensock.com/draggable/ and right click item, then click somewhere not on context menu, the items is held dragging until I click to release.  I'm using 

Google Chrome Version 31.0.1650.57

on 

Linux Mint 15 Olivia using Cinnamon WM

 

It doesn't happen on Firefox V 24.0 though.

 

Thanks for all the help.  I'm reluctant to disable the right-click altogether, it might be more annoying than this little inconsistency is.  Its nice to know the issue doesn't happen everywhere, curious to know what browsers/OSes don't produce this behavior.

Link to comment
Share on other sites

Yes, you could just listen for the "contextmenu" event on the document and inside that handler call endDrag() on your Draggable instance(s). 

 

Also, I've attached an updated version of Draggable that should implement that behavior automatically - does this resolve things for you? 

Draggable.min.js.zip

  • Like 1
Link to comment
Share on other sites

GreenSock, thank you for the awesome support.  I tried to drop in this Draggable replacement but it didn't seem to work, I got the following error in the console:

 

  1. Uncaught TypeError: Cannot read property 'parentNode' of null Draggable.min.js:14

 

Somewhat hard to debug with the .min ... any clue what's going on ?  This isn't a big deal so I wouldn't sweat too much over it.  But if there's a quick fix I'd much appreciate knowing about it :)

Link to comment
Share on other sites

I can't replicate that error anywhere. I've attached the uncompressed version. Would you mind providing more details, including a very simple codepen or jsfiddle that clearly demonstrates the problem? 

Draggable.js.zip

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