为什么滚动是通过处理程序处理的,而调整大小是通过 ScrollPanel 中的重写方法处理的?
为什么GWT要这样设计呢?调整大小和滚动事件之间的主要区别是什么?
Why is GWT designed in such a way? What is the principal difference between resize and scroll events?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为浏览器中没有用于调整大小的事件(在窗口级别调整大小,但不是元素级别),这与滚动事件相反。
因此,调整“通知”大小在 GWT 中是“模拟”的:如果您使用
RootLayoutPanel
或ResizeLayoutPanel
,它将侦听窗口调整大小事件并将它们向下传播到其 < code>RequiresResize 子级(如果它们本身是ProvidesResize
小部件,它们也会向下传播)。显式设置
ProvidesResize
小部件的大小也会通知其RequiresResize
子部件;以及调整布局面板区域的大小(以编程方式用于DockLayoutPanel
和LayoutPanel
以及其他),和/或由用户为SplitLayoutPanel
完成> 或 StackLayoutPanel)。您会注意到,
ScrollPanel
既是RequiresResize
(将由其父ProvidesResize
小部件通知其大小可能已更改),又是>ProvidesResize
(如果它是RequiresResize
,将通知其子小部件)。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
orResizeLayoutPanel
, it'll listen for window resize events and propagates them downwards to itsRequiresResize
children (which will propagate downwards too, if they areProvidesResize
widgets themselves).Explicitly setting the size of a
ProvidesResize
widget will also notify itsRequiresResize
children; as well as resizing areas of a layout panel (programmatically forDockLayoutPanel
andLayoutPanel
–among others–, and/or done by the user for aSplitLayoutPanel
orStackLayoutPanel
).You'll note that
ScrollPanel
is both aRequiresResize
(will be notified by its parentProvidesResize
widget that its size might have changed) andProvidesResize
(will notify its child widget if its aRequiresResize
).