Detect scrolling after scrolling distance from current position in browser

后端 未结 3 1791
滥情空心
滥情空心 2021-01-22 13:21

I want to detect if i am scrolling but only after I\'ve scrolled a certain distance from my current location. When I stop scrolling, this distance resets to the current location

3条回答
  •  旧时难觅i
    2021-01-22 13:50

    I didn't understand why you need this, but below is the code for your pseudo code:

    var currentScrolled = 0;
    $(document).scroll(function () {
    
    currentScrolled = $(this).scrollTop();
    
    if (currentScrolled > 10) {
        console.log('it worked');
    } else {
        console.log('You have not scrolled far enough!')
    }});
    
    $(document).scrollstop(function(){
       currentScrolled = 0; 
    });
    

提交回复
热议问题