Article From:https://segmentfault.com/q/1010000011702509
Question:
function srcoll(index,timer,speed) {
    var number=document.body.scrollTop-(lin_setFullHeight()*(index-1))
    console.log('number',number)
    if(number>0){
        document.body.scrollTop-=speed
        window.requestAnimationFrame(function () {
            srcoll(index,timer,speed)
        });
    }
    if(number==0){
        console.log("stop scrollling")
        window.cancelAnimationFrame(timer)
    }
    if(number<0){
        document.body.scrollTop+=speed
        window.requestAnimationFrame(function () {
            srcoll(index,timer,speed)
        });
    }
}

Because 950-7-7 will not be equal to 0 if it goes down like this. Why did it stop?The lin_setFullHeight () is 950.

Answer 0:

scrollTop It’s not negative, the minimum is 0.

Let y be max(0, min(y, viewport scrolling area height – viewport height)).

https://www.w3.org/TR/cssom-v…

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *