React-grid-layout: resize items, when react-grid-layout(div) width is changed

Created on 19 Apr 2019  路  3Comments  路  Source: STRML/react-grid-layout

For example, we have sider on the left and react-grid-layout(div) on the right.
We toggle the sider, then the width of the react-grid-layout(div) is changed, but items are not resized.
image
image

Most helpful comment

You can trigger resize event when you expand/collapse sidebar:

window.dispatchEvent(new Event('resize'));

All 3 comments

You can trigger resize event when you expand/collapse sidebar:

window.dispatchEvent(new Event('resize'));

@MaksZhukov Can you please confirm that this solved your issue? Thanks!

@bartoszkrawczyk2
This worked for me. If you have a transition on your sidebar, you can do a setTimeout at 0ms, 10ms, 20ms, etc. until the end of your transition to make the resize smooth.

for (let t = 0; t <= 300; t += 10) {
  setTimeout(() => {
    window.dispatchEvent(new Event('resize'))
  }, t)
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fsalamida picture fsalamida  路  3Comments

ConfigurableUIComponents picture ConfigurableUIComponents  路  4Comments

derisen picture derisen  路  3Comments

moritzschaefer picture moritzschaefer  路  3Comments

victor-unsw picture victor-unsw  路  3Comments