Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pitfalls when using flex layouts #120

Open
ctrlplusb opened this issue Aug 2, 2017 · 1 comment
Open

Pitfalls when using flex layouts #120

ctrlplusb opened this issue Aug 2, 2017 · 1 comment

Comments

@ctrlplusb
Copy link
Owner

ctrlplusb commented Aug 2, 2017

The behaviour of element-resize-detector causes a div to be injected which helps with tracking. Unfortunately this can break your flex layouts. To resolve you need to create a wrapping div around the flex layout div.

@mattjohnsonpint
Copy link

mattjohnsonpint commented Dec 12, 2018

Just wanted to share my experience in case it helps others. I also ran into this, but more than just needing any old div, I wanted to take up the whole width and height of the client area created by the flexbox. Unfortunately, this did't work so well with Edge (it would grow on resize, but not shrink), until I tried using relative and absolutely positioned divs. Now it works great in all browsers I tested.

<SizeMe monitorHeight>
  {({ size }) => 
    <div style={{ position: 'relative', height: '100%' }}>
      <div style={{ position: 'absolute', width: '100%', height: size.height }}>
        {/* remaining content here */}
      </div>
    </div>
  }
</SizeMe>

My size-aware content is mostly using react-window controls, passing the size.height to the height prop.

This works great for me. YMMV, of course.

markhepburn added a commit to IMASau/Seamap that referenced this issue Sep 1, 2021
Turns out the sizeme component isn't a complete drop-in replacement:
* props are size:{width, height} rather than just width/height
* its own props need tuning, and in particular extra markup around the
child

Credit to
ctrlplusb/react-sizeme#120 (comment)
for the latter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants