React-grid-layout: preventCollision doesn't allow the tile resize

Created on 17 Nov 2017  路  2Comments  路  Source: STRML/react-grid-layout

Most helpful comment

I've created PR to fix this long time ago https://github.com/STRML/react-grid-layout/pull/656

All 2 comments

Problem is in the getFirstCollision function in utils.js.

A resizing object doesn't have the same dimensions as its previous incarnation, so it fails the strict equality check and reports a collision.

Potential solution: check if item indexes match; I'm not sure if these are usable as unique identifiers or not.

export function getFirstCollision(layout: Layout, layoutItem: LayoutItem): ?LayoutItem {
  for (let i = 0, len = layout.length; i < len; i++) {
    const indexMatches = layoutItem.i === layout[i].i;
    const itemsCollide = collides(layout[i], layoutItem); 
    if (itemsCollide && !indexMatches) {
      return layout[i];
    }
  }
}

I've created PR to fix this long time ago https://github.com/STRML/react-grid-layout/pull/656

Was this page helpful?
0 / 5 - 0 ratings