【问题标题】:how to add an event that fires after scrolling the scrollbar to the end如何添加在滚动条滚动到末尾后触发的事件
【发布时间】:2021-12-19 18:44:02
【问题描述】:

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

【问题讨论】:

    标签: qooxdoo


    【解决方案1】:

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

    试试下面的代码(例如复制并粘贴到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);
    

    【讨论】:

      猜你喜欢
      • 2020-10-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-08
      • 1970-01-01
      相关资源
      最近更新 更多