better native scrollbar width compensation for FF
instead of having to offset the padding of children of the autohiding scrollbar container, which gets fiddly quickly, add a new child to the scrollbar container that gets a negative margin of the scrollbar width when needed (on hover and overflowing when overlay is not supported). This needs an extra DOM element, but as it doesn't do anything weird layout-wise (like set position), it shouldn't affect styling at all. It also makes the auto hide scrollbar workarounds completely transparent to the rest of the code.
This commit is contained in:
parent
3c70c2b82f
commit
c9dc273cb0
4 changed files with 16 additions and 25 deletions
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||
1. for browsers that support native overlay auto-hiding scrollbars
|
||||
*/
|
||||
.mx_AutoHideScrollbar {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
-ms-overflow-style: -ms-autohiding-scrollbar;
|
||||
}
|
||||
|
@ -34,23 +35,20 @@ body.mx_scrollbar_overlay_noautohide .mx_AutoHideScrollbar:hover {
|
|||
}
|
||||
/*
|
||||
3. as a last fallback, compensate for the scrollbar taking up space in the layout
|
||||
by playing with the paddings. the default below will add a right padding
|
||||
of the scrollbar width and clear that on hover.
|
||||
this won't work well on classes that also need to set their padding,
|
||||
so this needs to be overriden and adjust the padding with calc like so:
|
||||
```
|
||||
body.mx_scrollbar_nooverlay .componentClass.mx_AutoHideScrollbar_overflow:hover {
|
||||
padding-right: calc(15px - var(--scrollbar-width)) !important;
|
||||
}
|
||||
```
|
||||
by having giving the child element (.mx_AutoHideScrollbar_offset) a
|
||||
negative right margin of the width of the scrollbar when the container
|
||||
is overflowing. This is what Firefox ends up using. Overflow is detected
|
||||
in javascript, and adds the mx_AutoHideScrollbar_overflow class to the container.
|
||||
This only works in Firefox, which should be fine as this fallback is only needed there.
|
||||
*/
|
||||
body.mx_scrollbar_nooverlay .mx_AutoHideScrollbar {
|
||||
box-sizing: border-box;
|
||||
overflow-y: hidden;
|
||||
padding-right: var(--scrollbar-width);
|
||||
}
|
||||
|
||||
body.mx_scrollbar_nooverlay .mx_AutoHideScrollbar:hover {
|
||||
overflow-y: auto;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
body.mx_scrollbar_nooverlay .mx_AutoHideScrollbar:hover.mx_AutoHideScrollbar_overflow > .mx_AutoHideScrollbar_offset {
|
||||
margin-right: calc(-1 * var(--scrollbar-width));
|
||||
}
|
||||
|
|
|
@ -118,22 +118,13 @@ limitations under the License.
|
|||
.mx_RoomSubList_scroll {
|
||||
/* let rooms list grab all available space */
|
||||
flex: 0 1 auto;
|
||||
padding: 0 15px !important;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
/*
|
||||
for browsers that don't support overlay scrollbars,
|
||||
subtract scrollbar width from right padding on hover when overflowing
|
||||
so the content doesn't jump when showing the scrollbars
|
||||
*/
|
||||
body.mx_scrollbar_nooverlay .mx_RoomSubList_scroll.mx_AutoHideScrollbar_overflow:hover {
|
||||
padding-right: calc(15px - var(--scrollbar-width)) !important;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.collapsed {
|
||||
|
||||
.mx_RoomSubList_scroll {
|
||||
padding: 0px !important;
|
||||
padding: 0;
|
||||
}
|
||||
.mx_RoomSubList_label {
|
||||
height: 17px;
|
||||
|
|
|
@ -36,7 +36,7 @@ limitations under the License.
|
|||
}
|
||||
|
||||
// toggle menuButton and badge on hover/menu displayed
|
||||
.mx_RoomTile:hover, .mx_RoomTile_menuDisplayed {
|
||||
.mx_LeftPanel_container:not(.collapsed) .mx_RoomTile:hover, .mx_RoomTile_menuDisplayed {
|
||||
.mx_RoomTile_menuButton {
|
||||
display: block;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,9 @@ export default class AutoHideScrollbar extends React.Component {
|
|||
ref={this._collectContainerRef}
|
||||
className={["mx_AutoHideScrollbar", this.props.className].join(" ")}
|
||||
>
|
||||
{ this.props.children }
|
||||
<div className="mx_AutoHideScrollbar_offset">
|
||||
{ this.props.children }
|
||||
</div>
|
||||
</div>);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue