okonet / react-container-dimensions

Wrapper component that detects element resize and passes new dimensions down the tree. Based on https://github.com/wnr/element-resize-detector
MIT License
229 stars 26 forks source link

What is the best way of getting updated top and left values? #24

Closed alexanderwallin closed 4 years ago

alexanderwallin commented 7 years ago

Hi there!

I am making a X/Y control pad thingy where the user can drag an object around within a confined space. I use this module to provide the control pad with the bounds that constraints the objects. This works well when at the top of the page, but as soon as one scrolls, the top and/or left values fetched using getBoundingClientRect() will no longer be true.

I could solve this by composing <ControlDimensions> with another scroll detecting component, but I would first just like to check here if it would be within the scope of the module to support my scenario?

alexanderwallin commented 7 years ago

One could imagine an updateOnOffsetChange prop or similar.

okonet commented 7 years ago

I think it might be interesting to have inside the library. Mind creating a PR?

alexanderwallin commented 7 years ago

Sure, I'll take a look.