question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Root element noop blocking GSAP Draggable

See original GitHub issue

Do you want to request a feature or report a bug? Honestly I don’t know

What is the current behavior? I’m a moderator in the GreenSock forums and the most recent update (16.5.X) is causing some issues with the Draggable tool. By default the Draggable tool ignores clicks on specific elements so by default those are not draggable elements, unless you specify that the element should be draggable. Starting on version 16.5.0 a noop function is passed on the onclick event of the root element of a react app, which is preventing a simple <div> tag from being used by the Draggable tool.

**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than React. https://codesandbox.io/s/jrkbkxeqy The blue square is not draggabl(should rotate). If you either uncomment line 24 or change the React and ReactDOM versions to 16.4.2,

What is the expected behavior? It shouldn’t be necessary to add the indication to make the element Draggable, it should work by default just in any regular application or web page.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? React: 16.5.0 - 16.5.1 Chrome 69 - Firefox 62 - IE11 - Edge 17 Windows 7 64 Also other users have tested in Chrome and Firefox in OSX (don’t know specific versions)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
jackdoylecommented, Sep 15, 2018

Hi @gaearon, thanks for addressing this. I think the best way to move forward here is for us to change the default behavior in Draggable to dragClickables:true. That way, you don’t need to do anything in React and if people want to disallow dragging clickable elements, they can just set dragClickables:false.

To answer your question, yes, it should resolve things if you switched from declaring an onclick to addEventListener(“click”…) but I totally see your point about the fragility, hence my recommendation to just switch behavior on our end. The down side for us, of course, is that this change could break some legacy code but I doubt it’ll be a widespread problem and there’s an easy fix (setting dragClickables:false).

We’ll plan on making this change in our next GSAP release.

Thanks again for your consideration. And thanks, @rhernandog, for reporting this!

2reactions
gaearoncommented, Nov 1, 2018

I think we ended up changing this back (except for portal roots – kept a targeted fix) so it probably fixed this anyway.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Block dragging of specific element inside another draggable ...
Hi guys I have a horizontal fullscreen draggable slider. When I click and drag the slides get smaller and you can drag through...
Read more >
Draggable with create-react-app - GSAP - GreenSock
I am trying to get a div to rotate on drag using the Draggable api in a ... In the inspector comes as...
Read more >
Momentum Based Range Input with Draggable - GreenSock
I've been playing with this demo some more and attempting to create it without a "proxy" element in the DOM. It works for...
Read more >
Docs | Utilities | Draggable - GreenSock
Impose bounds - tell a draggable element to stay within the bounds of another ... Lock movement along a certain axis - set...
Read more >
gsap.context() - GreenSock Docs
[optionally] Scopes all selector text to a particular Element or Ref. ... Let's say you've got a big block of GSAP code that's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found