sdecima / javascript-detect-element-resize

A Cross-Browser, Event-based, Element Resize Detection
MIT License
881 stars 151 forks source link

Performance issues when nesting DIVs subscribed to element-resize #28

Open oodesign opened 9 years ago

oodesign commented 9 years ago

Hello!

We're facing performance "issues" while nesting several DIVs subscribed to element-resize. We tried having a container DIV with 9 inner DIVs. The main container is subscribed to element-resize (and changes its children's width dynamically), and the 9 inner DIVs are also subscribing to their element-resize, and perform other actions to their children.

It takes lots of time of javascript processing (most of it in ResetTriggers()), and the frame rate drops to 1fps, 2fps... Have you encountered the same? Or have any solution or hint for that?

Thank you!

rjgotten commented 8 years ago

resetTriggers not only read/write thrashes the DOM, but because it manipulates scroll offsets on DOM elements it also triggers a paint operation on those DOM elements. When said DOM elements don't have their own isolated compositing layer, it will trigger a repaint on the entire layer.

That's just the way this library works and there's little you can do about it without completely changing how resizes are detected.