noeldelgado / gemini-scrollbar

:first_quarter_moon: Custom overlay-scrollbars with native scrolling mechanism for web applications
https://noeldelgado.github.io/gemini-scrollbar/
MIT License
429 stars 63 forks source link

Add a handler to detect resizes of the scrolling element #25

Closed richvdh closed 8 years ago

richvdh commented 8 years ago

In moderately complex applications, the size of the HTMLElement containing our scrolling content can be affected by many other changes to the DOM. Every time our HTMLElement is resized, we need to make sure that we call GeminiScrollbar.update. Trying to track each and every change to the DOM which results in a resize is difficult and fragile.

This PR proposes the following solution: we overlay the HTMLElement with an invisible <object> with 100% width and height. To this object, we can attach an eventlistener which will be called whenever the parent element is resized; we can then use that to call GeminiScrollbar.update.

This also makes the window resize event listener redundant.

We also provide a hook by which clients can be notified of resize events, with an onResize member in the constructor options.

richvdh commented 8 years ago

Sorry, I'm going to have to reopen this PR, as I've based it on the wrong branch :(

richvdh commented 8 years ago

superceded by #26