Skip to content

collision: more edge case fixes#1663

Merged
adumesny merged 1 commit into
gridstack:developfrom
adumesny:develop
Mar 20, 2021
Merged

collision: more edge case fixes#1663
adumesny merged 1 commit into
gridstack:developfrom
adumesny:develop

Conversation

@adumesny

Copy link
Copy Markdown
Member

Description

fix #1094

  • found I needed to take entire row (not just new location) when doing collision to correctly push down bottom items first so they keep their order and prevent large objects from leapfrogging smaller ones.
    (like old code used to do)
  • removed _beforeDrag and _packY fields and re-use existing _orig position data which simplifies things
  • removed yOffset during _fixCollisions() as it was incorrect (reverse sorting should take care of that)
  • on _leave() of external item, we now restore all items to original position using restoreInitial() (prevents any error from sticking)

NEEDLESS to say, this is MUCH more complicated than the old _fixCollision() that moved to new loc then pushed anything down in that row and below (bottom first) which is dead simple... but required you to move 90% past the item when moving down.

Checklist

  • Created tests which fail without the change (if possible)
  • All tests passing (yarn test)
  • Extended the README / documentation, if necessary

fix gridstack#1094

* found I needed to take entire row (not just new location) when doing collision to correctly push down bottom items first so they keep their order and prevent large objects from leapfrogging smaller ones.
(like old code used to do)
* removed _beforeDrag and _packY fields and re-use existing _orig position data which simplifies things
* removed yOffset during _fixCollisions() as it was incorrect (reverse sorting should take care of that)
* on _leave() of external item, we now restore all items to original position using restoreInitial() (prevents any error from sticking)

NEEDLESS to say, this is MUCH more complicated than the old _fixCollision() that moved to new loc then pushed anything down in that row and below (bottom first) which is dead simple... but required you to move 90% past the item when moving down.
@adumesny adumesny merged commit 37523cf into gridstack:develop Mar 20, 2021
@Prid13

Prid13 commented Mar 20, 2021

Copy link
Copy Markdown

Thank you soo much for you hard work! I really, truly appreciate it and wish more people could donate to reward your continued effort. I'm just really glad you took the time to do this :)

@adumesny

Copy link
Copy Markdown
Member Author

@Prid13 thank you for the comment. Would be great if you would follow on that donation. I've been thinking of making this commercial version as it take a huge amount of time and very few do contribute.

@Prid13

Prid13 commented Mar 20, 2021

Copy link
Copy Markdown

I've already donated a while back but will try donating a bit more (won't be as much, unfortunately) :) I'm thinking of using this in a commercial product myself and will be sure to donate more if I ever manage to turn a profit on it :)

@gridstack gridstack deleted a comment from Prid13 Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drag heuristics can make it hard to place items (ex: web demo)

2 participants