如何添加将滚动条滚动到末尾后触发的事件

how to add an event that fires after scrolling the scrollbar to the end

我正在使用独立(不是移动),我认为这是 _getScroll 方法来实现它。 如何在这里实施 qooxdoo selectbox example 我发现类似的移动 implementing virtual scrolling list console.log 说 container._getScroll 不是函数。

思路是从widget获取滚动条,你需要的滚动条是widget的NativeScrollbar qx.ui.list.List。然后为“滚动”事件添加事件处理程序。在处理程序中,您必须比较滚动的当前位置和最大值。

试试下面的代码(例如复制并粘贴到 Qooxdoo playground)。

qx.Class.define("SelectBoxWithScrollEndEvent", {
  extend: qx.ui.form.SelectBox,
  
  construct: function(){
    this.base(arguments);
    this.__setupScroll();
  },
  
  events: {
    "scrollEndHappened": "qx.event.type.Event"
  },
  
  members: {
    __setupScroll: function(){
      const list = this.getChildControl("list");
      const scrollbar = list.getChildControl("scrollbar-y");
      scrollbar.addListener("scroll", function(e){
      if (scrollbar.getMaximum() === scrollbar.getPosition()){
        this.fireEvent("scrollEndHappened");
      }}, this);
    }
  }
});

const box = new SelectBoxWithScrollEndEvent();
const data = new qx.data.Array([1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]);
const controller = new qx.data.controller.List(data, box);

box.addListener("scrollEndHappened", function(){
  alert("SCROLL HAPPENED ALERT");
}, this);
this.getRoot().add(box);