abouolia / sticky-sidebar

😎 Pure JavaScript tool for making smart and high performance sticky sidebar.
https://abouolia.github.io/sticky-sidebar/
MIT License
2.23k stars 487 forks source link

recalculate if container dom changed. #121

Open yaquawa opened 4 years ago

yaquawa commented 4 years ago

I think to use ResizeSensor.js is a bit overkill, why not just add a few lines to use MutationObserver instead ? (if the browser supports)

SlimerDude commented 4 years ago

ResizeSensor.js does use the Mutation Observer API, the problem is that mutations are a bad fit for resize events.

Instead I think you'll want to use a Resize Observer - but there's no support for IE and limited Firefox support.

yaquawa commented 4 years ago

Hi @SlimerDude , I mean if ResizeSensor.js is not detected, fallback to use MutationObserver or as you said the Resize Observer if browser supports. Chances are many people like me don't support IE, so no need to use ResizeSensor.js at all, it increase the bundle size a lot.

Currently I can use Mutation Observer to call the update method of sticky-sidebar when the content of the sidebar changed, but I would like see this tiny logic could be sit in the core in the first place.

I use this library in many of my projects, I really appreciate your great work, and hope this little change can be added to the core. Thanks.