簡體   English   中英

iScroll4上下滑動事件

[英]iScroll4 swipe down and up events

我已經編寫了如下代碼,但是當我始終滾動時, onScrollEnd被觸發。 如何檢測用戶是向下滾動還是向上滾動?

myScroll = new iScroll('SaleListingContainer', { desktopCompatibility: true, useTransition: true,
                        // topOffset: pullDownOffset,
                        onRefresh: function() {
                            alert("refresh");
                        },
                        onScrollMove: function() {
                            alert("move");
                        },
                        onScrollEnd: function() {
                            alert("end");
                        } 
                    });

感謝您的寶貴時間和提前的幫助。 非常感謝。

使用dirY屬性,如果用戶向下滾動,則為1;如果用戶向上滾動,則為-1:

onScrollEnd: function() {
            if (this.dirY == 1) { alert('scrolling down'); }
            else if (this.dirY == -1) { alert('scrolling up'); }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM