-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enableMove() removes snapping on existing items #1658
Comments
hey I can't access your demo anymore (502 bad gateway) but realized we do have an example that works so you must be doing something different... |
That's strange, it still works for me, and I sent it to some other people to see if it works for them too and it does. Maybe if I link it again? Worth a shot! Took a little video of what I'm talking about. For some reason the capture program I used has the mouse misaligned, but notice when I toggle the grid to allow dragging by the method I explained, the items in the grid no longer attach to cells, you can just drag them to any spot. However, if you add a new item WHILE the dragging is already enabled, they will snap to cells when you drag them. Then, that same item will stop snapping to cells if you toggle off dragging and toggle it back on. A little hard to explain, hopefully this makes some sense. And if for some reason you still can't view the code, i'll paste it here. edit: code doesnt post normally here. i'll attach it as a txt file instead. |
I can access the links again... looking... |
* fix gridstack#1658 * we now set the grid options BEFORE we update each item as that override * enableMove() and enableResize() no longer take a second optional param as we must set grid options for things to work (if you want to enable current items but not change the grid itself, there is already the `movable('.grid-stack-item')` method that doesn't change the grid (no need for 2 ways) * did some more cleanup and added test case.
fix in 4.0.2 - took a little longer than I though... if you find lib useful, don't forget to donate! |
Subject of the issue
When you call enableMove on a drag-disabled grid with existing items, the existing items will have drag unlocked but will not snap into grid cells as normal. Instead they just stay exactly wherever you drag them to. However, if you add a new item to the grid while enableMove is used this way, then the new item will have normal snapping behavior. This is for the JQ version. On the h5 version, the existing items will stay undraggable instead of the floating behavior. The rest of the results seem to be the same as JQ. The difference between versions should probably be verified just to make sure what I found is true.
Your environment
Steps to reproduce
https://jsfiddle.net/q904xvfu/12/
push add button to add widget.
try dragging and see that it's locked.
press toggle button (confirmed in console output)
(JQ) drag existing widget and see that it does not snap into a cell. (h5) drag existing widget and see that it is still locked
add another widget and drag that one to see that it DOES snap into cell.
can click toggle again to lock the grid, then again to see that the issue applies to all existing items.
Expected behavior
Items should be snapping into cells when dragged, when drag is enabled this way
Actual behavior
on JQ, items wont snap and will float instead. on h5 they stay undraggable.
The text was updated successfully, but these errors were encountered: