accommodate scrollbar when setting maxHeight & maxWidth#82
accommodate scrollbar when setting maxHeight & maxWidth#82joshuahiggins wants to merge 5 commits into
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
I signed the CLA. This PR is one solution for addressing #81. Here is a gif showing it in action: |
|
CLAs look good, thanks! |
This is the raw logs from Travis:Any thoughts on how to resolve? It looks like everything passes. (edited by bicknellr so that this doesn't take up a mile of screen :) |
| /** | ||
| * The browser scrollbar size, allowing overflowing containers to compensate. | ||
| */ | ||
| get _scrollbarSize() { |
There was a problem hiding this comment.
Can you do this only once and save it as a variable? Right now this gets run every time position() is invoked (which can be lots of times, e.g. at each scroll event)
Maybe just add this into the properties object, and make it a read-only, shared property:
properties: {
//...
/**
* @private
*/
_scrollbarSize: {
type: Number,
readOnly: true,
// Shared value across instances.
value: (function computeScrollbarSize() {
// your implementation here
})(),
}@e111077 are IIFEs ok for modulizer?
There was a problem hiding this comment.
I think they are fine as long as they don't do a lot of crazy namespace things inside of them.
| var maxHeight = Math.max(bottom - top, this._fitInfo.sizedBy.minHeight); | ||
|
|
||
| // Determine if scrollbar will display and increase max size if necessary | ||
| if (maxHeight < this.sizingTarget.clientHeight) { maxWidth += this._scrollbarSize; } |
There was a problem hiding this comment.
Calling clientHeight/clientWidth would force layout on sizingTarget. You can store these values in this._fitInfo object, which gets updated only once and reused. The place where we measure the sizingTarget is in the _discoverInfo method. Over there you could add a new key to _fitInfo, e.g. this._fitInfo.sizerDimensions = { clientWidth, clientHeight} and read them here
|
LGTM for modulizer side of this PR for me. Pending review from Valdrin |
|
@valdrinkoshi Apologies for the delayed response to your review. I somehow missed the notification. Great suggestions! I implemented both. |

This approach creates an element on the fly to determine scrollbar sizing at the moment of the resize. This allows it to work with browser zooming which, while visually the same to the end user, will result in different measurements.
When a scrollbar is needed, the overall
maxWidthormaxHeightis increased by the size of the scrollbar.