Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 28, 2016

Conversation

richvdh
Copy link
Contributor

@richvdh richvdh commented Apr 20, 2016

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 added 2 commits March 18, 2016 15:35
... so that we can correctly update the scrollbars when the parent div changes
size.
If we're creating a resize-monitor with native scrollbars, we still need to
move the child elements into a viewElement, otherwise the resize monitor ends
up monitoring the size of the scroll area, not the visible area.
@noeldelgado
Copy link
Owner

Thanks for the pull request (and sorry for the late response), @richvdh! let me take a look to make sure it's ready for merging, it seems pretty useful. 👍

@noeldelgado
Copy link
Owner

BTW, @richvdh do you know if this will fix #18?

@richvdh
Copy link
Contributor Author

richvdh commented May 20, 2016

Empirically, not on its own, unfortunately.

Possibly the problem is that, as the zoom level changes, the relative size of the native scrollbar also changes - but we only check that relationship at first load.

@noeldelgado noeldelgado merged commit bcb291f into noeldelgado:master May 28, 2016
@rhukster
Copy link

rhukster commented Jun 3, 2016

FWIW the z-index: -1 in the CSS for this object doesn't seem to work in IE at all.

It just causes the object to overlay everything as a white box. Seems to be ok with visibility: hidden; however.

@noeldelgado
Copy link
Owner

Thanks for the heads up @rhukster.
I will check it and update it accordingly. Also, PR's are welcome. ;)

@noeldelgado
Copy link
Owner

@rhukster, fixed in v1.4.1 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants