Provide mouse position to collision detection algorithm
See original GitHub issueFirst off just wanted to say thanks for building this! Loving it so far and I’ve barely got it working.
My goal is to implement a version of useSortable
that also allows dropping something inside another target.
I’m still working on this, but I believe in order to do so, I need to use a collision detection algorithm that takes into account the position of the cursor inside the dragging item since it’s frequently the case that the draggable is over a droppable, but the cursor is not.
Any advice on how to achieve this with the existing architecture? Is the mouse position already being tracked somewhere that could be passed?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:29 (9 by maintainers)
Top Results From Across the Web
Collision Detection - Happy Coding
This code stores the position (center) of the circle and its radius in variables. It then uses the dist() function to check whether...
Read more >2D collision detection - Game development - MDN Web Docs
This algorithm works by taking the center points of the two circles and ensuring the distance between the center points are less than...
Read more >Is it a bad idea to "map" the mouse position on the screen so ...
Is it a bad idea to "map" the mouse position on the screen so that collision detection works regardless of resolution? Ask Question....
Read more >Flawless mouse collision detection and movement with ...
The final approach I tried was by using line segment intersections. I would define a main line from the cursor to the mouse,...
Read more >Line/Point - Collision Detection - Jeff Thompson
A line (see note) is defined by two sets of X/Y coordinates. ... float px = 0; // point position (set by mouse)...
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
@sean-esper you can test your use-case against this WIP PR https://github.com/clauderic/dnd-kit/pull/558. In my example, I wrote some very scrappy code to determine if there was a matching “combining” element:
UPDATE: I realized this is as simple as keeping track of mousemove and using that to determine if the current mouse position is over a given rect.