javascript - MGWT ScrollPanel.scrollTo(0, y) 导致无法读取未定义的属性 'style'

标签 javascript java html gwt mgwt

我使用 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在此处输入代码..)

关于javascript - MGWT ScrollPanel.scrollTo(0, y) 导致无法读取未定义的属性 'style',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35010681/

相关文章:

html - 在哪里可以找到 HTML5 标准的权威测试套件?

javascript - 从 JavaScript 使用时如何确保释放 wasm 内存

javascript - cal-heatmap onclick onday,滚动到本周的部分

Java重绘()/更新()

html 不会转到 css,因此不会改变颜色

jquery - QTip2 工具提示的提示位置不正确

javascript - 从数组中排除值后获取下一个最高日期值

javascript - 发布标记为私有(private)的包给 verdaccio

java - 在 toString 方法中返回 ArrayList 时,排列列表会重复自身

java - 继承和动态绑定(bind)