Reputation: 161
When a GWT ScrollPanel is set to automatically show scrollbars, are there an event to tell when the scrollbars are shown or hidden?
I need this in order to update the layout for inner components when they are added or removed. When the toolbars pop into view after content being added, after subcomponents outside of my controls are expanded, I get both horizontal and vertical scrollbars because the content is slightly wider than scrollbar container with scrollbars added.
Upvotes: 0
Views: 1224
Reputation: 9741
There is no way to set a handler when scroll bars appear/disappear.
What you can do is, after adding/removing content, check whether the scroll bar is being shown and re-layout your components:
// To check if the window scroll is being shown
public static boolean isWindowVerticalScrollShown() {
return Document.get().getScrollHeight() > Document.get().getClientHeight();
}
// To check if an element scroll is being shown
public static boolean isElementVerticalScrollShown(Element el) {
return el.getScrollHeight() > el.getClientHeight();
}
Upvotes: 2