DragHandler erroneous starting offset
See original GitHub issueThere is a bug in the DragHandler
class. The
basePotition = capture.getWorldTranslation().clone()
line in startDrag()
should probably instead be
basePosition = capture.getLocalTranslation().clone()
because everywhere else the handler is working with the local translation and getting the world translation here introduces an abnormal initial offset on drag start if the spatial is a child of some other spatial and its relative location is not 0, 0, 0.
It is easy to demonstrate this behavior by modifying the com.simsilica.lemur.demo.BasicDemo
class: replace the line
guiNode.attachChild( testPanel );
in simpleInitApp()
with
Node node = new Node();
node.attachChild(testPanel);
node.setLocalTranslation(200, 200, 0);
guiNode.attachChild(node);
and try to drag the testPanel.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
jQuery draggable shows helper in wrong place after page ...
I'm using jQuery 1.6.0 and jQuery UI 1.8.12. I'm sure there's a offset function I need to add but I don't know where...
Read more >Draggable Window in Lemur - gui - jMonkeyEngine Hub
Great! Looking forward to it! Formulated the issue: DragHandler erroneous starting offset · Issue #64 · jMonkeyEngine-Contributions/Lemur · GitHub, thanks!
Read more >HTMLElement: drag event - Web APIs | MDN
The drag event is fired every few hundred milliseconds as an element or text selection is being dragged by the user.
Read more >Problem with dragging - Unity Forum
I have been trying to learn how to use the IDragHandler interface to drag some UI elements around on the canvas. However, I...
Read more >Gesture options - @use-gesture documentation
The initial position offset should start from. threshold, all, The handler will fire only when the gesture displacement is greater than the threshold....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fix committed and confirmed it works in the demo. Closing this issue.
I don’t think it requires all that. I haven’t tested it or anything but I believe it’s as simple as: -continue calculating dragging in world space as before -instead of calling spatial.setLocalTranslation() with the world space coordinate, convert that world space coordinate to local space with spatial.getParent().worldToLocal()