关于 GWT ScrollPanel 的问题。
有没有办法确定 ScrollPanel 中正在显示哪个子元素?
(当然,ScrollPanel包含具有HTML对象的DecoratorPanel)
下面是执行该作业的 GWT 方法(它是从上面建议的 JQuery 解决方案翻译而来的)。
/**
* @param widget the widget to check
* @return true if the widget is in the visible part of the page
*/
private boolean isScrolledIntoView(Widget widget) {
if (widget != null) {
int docViewTop = Window.getScrollTop();
int docViewBottom = docViewTop + Window.getClientHeight();
int elemTop = widget.getAbsoluteTop();
int elemBottom = elemTop + widget.getOffsetHeight();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
return false;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)