wnr / element-resize-detector

Optimized cross-browser resize listener for elements.
MIT License
1.32k stars 118 forks source link

scroll-based approach doubles the size of elements #84

Closed chrisy-lili closed 6 years ago

chrisy-lili commented 7 years ago

I'm using react-sizeme (which leverages element-resize-detector) with react-dnd. When moving a component around the page, its dragging preview is twice its original size, b/c the default "scroll" strategy set the width/height to 200% here (https://github.com/wnr/element-resize-detector/blob/master/src/detection-strategy/scroll.js#L367). This happens only in Chrome. So, I switched the strategy to be "object" to fix the issue I'm having. Since the "object" approach will be deprecated in v2, do you have suggestions to solve the double-sized preview issue?

wnr commented 7 years ago

A movie or running example of this issue would help me understand it better. Yes, the object approach is a good alternative for this. As of now, there is no planned version 2 (because no good reasons to break the API has been found). So you can use the object approach if it works for you, it is just not maintained as much as the scroll one. If the problem is only in Chrome, perhaps you can use the native ResizeObserver? I don't know the status of it though.