haltu / muuri

Infinite responsive, sortable, filterable and draggable layouts
https://muuri.dev
MIT License
10.77k stars 643 forks source link

How to initiate a grid.move() based on the dragged item's position, even when the item is outside the grid? #568

Closed tlietz closed 5 months ago

tlietz commented 5 months ago

When dragging items quickly, or outside the range of the grid, muuri sometimes doesn't initiate a grid.move(). I realize that this is a feature of muuri, not a bug, because in the case of multiple grids, you wouldn't want your currentGrid to be shifting around while you're dragging the item to the targetGrid.

However, my usecase calls for only a single grid. Is there a way to do this with the muuri API?

If not, which part of the source code should I look into changing?

tlietz commented 5 months ago

For example, I want to trigger a grid.move in this situation where an item was dragged quickly to the top of the page. Overall, the goal would be to emit an event when the location of an item is passed a certain portion of an element given by threshold, so that a grid.move can be initiated even when the item is outside the grid element, and even when the item is not moving (but is still being held onto).:

https://github.com/haltu/muuri/assets/25965706/91a7433f-ea0a-42d5-8f1c-9f2d5e0740a9