简体   繁体   English

iScroll4上下滑动事件

[英]iScroll4 swipe down and up events

I've written my code as below but when I scroll always onScrollEnd gets fired. 我已经编写了如下代码,但是当我始终滚动时, onScrollEnd被触发。 How to detect whether user is scrolling down or scrolling up ?? 如何检测用户是向下滚动还是向上滚动?

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

Thanks for your time and help in advance. 感谢您的宝贵时间和提前的帮助。 Thanks alot. 非常感谢。

Use dirY attribute, which is 1 if the user scrolls down or -1 if the user scrolls up: 使用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