You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
enableMove() removes snapping on existing items #1658
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
JQ 3.2 and JQ 3.3 and h5 3.3
Version 88.0.4324.190 (Official Build) (64-bit) and firefox 86 (64 bit)
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.
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! https://jsfiddle.net/7s694twh/3/
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. https://drive.google.com/file/d/1qwWewDb198IQTOGhFbV_c2R9uese4ryr/view
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. code.txt
Activity
adumesny commentedon Mar 21, 2021
hey I can't access your demo anymore (502 bad gateway) but realized we do have an example that works
https://gridstackjs.com/demo/static.html
https://github.com/gridstack/gridstack.js/blob/master/demo/static.html
so you must be doing something different...
NealonF commentedon Mar 21, 2021
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!
https://jsfiddle.net/7s694twh/3/
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.
https://drive.google.com/file/d/1qwWewDb198IQTOGhFbV_c2R9uese4ryr/view
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.
code.txt
adumesny commentedon Mar 21, 2021
I can access the links again... looking...
enableMove() fix
adumesny commentedon Mar 22, 2021
fix in 4.0.2 - took a little longer than I though... if you find lib useful, don't forget to donate!