gwt 弹出窗口未居中
我使用 gwt 弹出窗口显示一些消息,但它没有显示在 中心 如果我调用 popup.center(),则显示事件。实际上它并不居中 只有第一次,如果我关闭它并再次打开它,一切都会好的, 但不是第一次。如何解决这个问题?
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
Image fullImage = new Image(optionImageName);
fullImage.setAltText("Loading image ...");
imagePopup.setWidget(fullImage);
imagePopup.center();
}
});
我在 http://www.devcomments.com/ 上发现了这个问题gwt-Popup-is-not-centered-at107182.htm,今天我也遇到了这个问题。我找到了答案,并将其发布在这里以供将来参考。
I use gwt popup to show some messages, but it is not displayed in the
center
of the display event if i call popup.center(). Actually it is not centered
only the first time, if i close it and open it again every thing is ok,
but not the first time. How to fix that?
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
Image fullImage = new Image(optionImageName);
fullImage.setAltText("Loading image ...");
imagePopup.setWidget(fullImage);
imagePopup.center();
}
});
I found this question on http://www.devcomments.com/gwt-Popup-is-not-centered-at107182.htm, and today I have had this problem too. I found the answer and i will post it here for future reference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现问题是当您将弹出窗口居中时,图像未加载完成。第一次发生这种情况只是因为第二次图像被浏览器以某种方式兑现。
解决方案是将其也集中在 onLoad 事件上。
I found that the problem is that the image is not loaded completed when you center the popup. This happens the first time only because the second time the image is somehow cashed by the browser.
The solution is to center it on the onLoad event as well.
我也有这个问题。您必须调用中心两次的原因是,当弹出窗口“隐藏”时,弹出容器实际上已从 DOM 中删除。这是有问题的,因为您的弹出窗口现在必须“显示”弹出窗口的内容,然后您才能检查图像是否已加载。
建议实现的问题是,如果图像未缓存,则对 center() 的第一次调用将错误地完成。第二次致电中心将纠正它。在浏览器上,这会导致弹出对话框发生变化(看起来很糟糕)。
我会推荐以下内容:
1. 将等待旋转器放在同一显示器中并首先显示。
2. 调用 loadHandler 后,显示图像、隐藏微调器并重新居中。
I had this problem as well. The reason that you have to call center twice is because the popup container is actually removed from the DOM when the popup is "hidden". This is problematic because your popup has to now "show" the contents of the popup before you can check that the image is loaded.
The issue with the implementation recommended is that the first call to center() will be done incorrectly if the image is not cached. The second call to center will correct it. On the browser, this causes a shift of the popup dialog box (which looks pretty bad).
I would recommend the following:
1. Put a waiting spinner in the same display and show that initially.
2. One the loadHandler is called, display the image, hide the spinner, and recenter.
希望这有帮助。
Hope this Help.