feat: improve no compact mode without collision prevent#126
feat: improve no compact mode without collision prevent#126jakubbialas wants to merge 1 commit intokatoid:mainfrom
Conversation
|
Thanks again for the improvements @jakubbialas ! I’m from the Katoid team, and we’ve been discussing the feature with @llorenspujol. We’ll answer you step by step. CLONE LAYOUT MOVE ELEMENTS AWAY FROM COLISION RESIZING |
| itemToMove, | ||
| compactH ? itemToMove.x + 1 : undefined, | ||
| compactV ? itemToMove.y + 1 : undefined, | ||
| compactV ? itemToMove.y + 1 : (noCompact ? Math.max(itemToMove.y + 1, collidesWith.y + 1) : undefined), |
There was a problem hiding this comment.
Better mantain compactV ? itemToMove.y + 1 : undefined, and let the compact function handle it
| const newLayoutItems: LayoutItem[] = config.layout.map((item) => { | ||
| return item.id === gridItemId ? layoutItem : item; | ||
| }); | ||
| const layoutItems: LayoutItem[] = config.layout; |
There was a problem hiding this comment.
To avoid added complexity, we think it’s better to leave the resize behavior as it was.
I have been happily using grid with compact mode 'none' and 'prevent collision' enabled for the last 3 years, until my PO decided he want to enable collisions. As you might know it isn't working grate in that combination (items spread across the grid and single mis-drag can destroy whole layout):
before.mp4
I implemented feature,that should change behaviour in compact mode 'none' without 'prevent collision', It basically restores original layout before resolving collisions, that way items are returning to their places if not colliding with dragged item:
after.mp4
I also made resizing items more deterministic, by extending moveElement function into more like moveAndResizeElement.
@llorenspujol please have a look at it, I'm open to any questions and feedback.