我想要完成的是让用户只能在页面上滚动最多5次(每个部分一次),我会设置一个计数器并在每次用户向下滚动时递增/递减它/分别确定他们当前在页面上的位置。
一个简单的例子:
var counter = 1;
$(document).scroll(function(){
if (counter == 1) {
//fire first function/animation
} else if (counter == 2) ( // if user is scrolling down ) {
//fire second function/animation
counter++;
} else if ((counter == 3) && ( // if user is scrolling down ) {
//fire third function/animation
counter++;
}
})
依旧......