React-grid-layout: Add 'oldLayout' to onLayoutChange callback params

Created on 17 May 2016  路  3Comments  路  Source: STRML/react-grid-layout

It would be nice to have access to the 'oldLayout' (layout before change) in the onLayoutChange callback. The problem is that the onLayoutChange callback gets fired even if the layout did not change. This happens for instance when you drag an item and drop it on the same position.

The problem without having the 'oldLayout' available in the onLayoutChange callback is that you can't reproduce if the layout did change. As we need to compute other stuff according to layout changes it would be nice if we could skip the computations when the layout didn't change.

As you keep the layout on the state I think the best idea for solving this would be to create a deep copy of the state before manipulation and also pass it to onLayoutChange. This wouldn't grant shallow compare but a deep equal check would be nice though.

stale

Most helpful comment

In my opinion, onLayoutChange should only be called when the library changes the layout, but not when we explicitly pass down a new layout.

All 3 comments

Is there anything in the API now to workaround this? I've looked over the updates and surrounding topics but looks like i'll have to implement a timeout and nullify the call to onLayoutChange manually, as per https://github.com/STRML/react-grid-layout/issues/558

In my opinion, onLayoutChange should only be called when the library changes the layout, but not when we explicitly pass down a new layout.

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 7 days

Was this page helpful?
0 / 5 - 0 ratings