After encountering an issue with a page jumping due to the appearance of a vertical scroll bar, I have decided to always display the scroll bar by applying
html { overflow-y: scroll !important; }
, instead of using a script to monitor and adjust window/document width. Another idea is to style the bar as transparent and button-less after page load to give the illusion of no scrollbar. Some suggest replacing RootPanel
with RootLayoutPanel
, but that's not an option here.
Is there a way to style the native vertical scroll bar without adding another wrapper panel or custom bar? More information can be found here.
This code snippet shows how to detect if a vertical scroll bar is present:
if( RootPanel.getBodyElement().getOffsetHeight() > Window.getClientHeight() )
//bar is present
The goal is to implement these changes without the user noticing any difference in appearance.