Skip to content

enableMove() removes snapping on existing items #1658

Closed

Description

@NealonF

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

  • 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)

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.

Activity

  1. adumesny commented on Mar 21, 2021

    @adumesny
    Member

    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...

  2. NealonF commented on Mar 21, 2021

    @NealonF
    Author

    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

  3. adumesny commented on Mar 21, 2021

    @adumesny
    Member

    I can access the links again... looking...

  4. added a commit that references this issue on Mar 22, 2021
    39aff94
  5. adumesny commented on Mar 22, 2021

    @adumesny
    Member

    fix in 4.0.2 - took a little longer than I though... if you find lib useful, don't forget to donate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions