我使用MGWT的ScrollPanel并执行以下操作:
private void scrollToBottom() {
if (getUiHandlers().isVisible()) {
final int height = scrollPanel.getOffsetHeight();
final int heightInt = cellList.getOffsetHeight();
final int y = scrollPanel.getMaxScrollY();
if (heightInt >= height) {
scrollPanel.scrollTo(0, y);
}
}
}
当涉及到这一行:
scrollPanel.scrollTo(0, y)
我收到以下错误:
UncaughtException: (TypeError) : Cannot read property 'style' of undefined
UncaughtException details: setDelay_1_g$
UncaughtException details: setTransitionsDelay_0_g$
UncaughtException details: scrollbarPos_0_g$
UncaughtException details: pos_1_g$
UncaughtException details: execute_30_g$
UncaughtException details: startAnimation_0_g$
UncaughtException details: scrollTo_7_g$
UncaughtException details: scrollTo_6_g$
UncaughtException details: scrollTo_5_g$
UncaughtException details: scrollTo_3_g$
如何防止此错误?
最佳答案
从源代码和堆栈跟踪来看,您似乎在遇到滚动条问题。调用scrollTo时,mgwt滚动面板是否始终有滚动?
另外,我强烈建议您将scrollPanel.scrollTo(0, y);
调用包装到Scheduler.get().scheduleDeffered(..your scrollTo call here
在此处输入代码..)