Why is scroll processed via handler while resize i

2019-08-30 03:59发布

问题:

Why is GWT designed in such a way? What is the principal difference between resize and scroll events?

回答1:

Because there's no event for resizing in browsers (there's resizing at the window-level, but not element-level), contrary to scroll events.

Thus, resizing "notification" is "emulated" in GWT: if you use a RootLayoutPanel or ResizeLayoutPanel, it'll listen for window resize events and propagates them downwards to its RequiresResizechildren (which will propagate downwards too, if they are ProvidesResize widgets themselves).
Explicitly setting the size of a ProvidesResize widget will also notify its RequiresResize children; as well as resizing areas of a layout panel (programmatically for DockLayoutPanel and LayoutPanel –among others–, and/or done by the user for a SplitLayoutPanel or StackLayoutPanel).

You'll note that ScrollPanel is both a RequiresResize (will be notified by its parent ProvidesResize widget that its size might have changed) and ProvidesResize (will notify its child widget if its a RequiresResize).