如何在移动 safari 上获得以用户当前视图端口为中心的 GWT PopupPanel?
调用 .center() 使面板在整个页面上居中。我想让它位于当前视图端口的正中心...另外我想防止滚动..但也许我会回到那个。
calling .center() makes the panel center on the entire page.. I'd like to have it dead center of the current view port... additionally I'd like to prevent scrolling.. but maybe I'll come back to that one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
留出死点给用户练习,但关键组件是 Window.getScrollTop() 和 Window.getScrollLeft()
Dead center is left for an exercise for the user, but the key component is Window.getScrollTop() and Window.getScrollLeft()
标准
center()
方法不能满足您的要求。所以你必须自己计算位置。有一个大问题是您的弹出窗口在实际显示之前没有尺寸。任何 DOM 元素的大小在完全附加到 DOM 之前都无法查询。您必须继承 GWT 弹出窗口类并重写onLoad()
方法才能获取弹出窗口的大小。尝试这样的事情:The standard
center()
method does not do what you want. So you have to calculate the position yourself. There is one big problem that is your popup does not have a size before it is actually shown. The size of any DOM element can not be queried until it is fully attached to the DOM. You have to inherit the GWT popup class and overriding theonLoad()
method to get the size of the popup. Try something like this: