In iOS, when you are at the bottom of the page, use scrollTop (0) to scroll to the top, and the input in the first screen will focus automatically. How to avoid this problem?

function scrollTo(dom, dis, dir = "up") {
    if(dir == "up") { 
        var scroll = function() {
            var timer = setTimeout( function() {
                if(dom.scrollTop() > dis) {
                    dom.scrollTop(dom.scrollTop() -50);
                    // alert(dom.scrollTop());
                    scroll();
                } else { 
                    dom.scrollTop(dis);
                    clearTimeout(timer); 
                    timer = null; 
                } 
            }, 10);
        }
        scroll();
    }
}

call this function to perform scrolling. When you scroll to the top, input will focus automatically. What if you don"t want him to focus automatically?

Mar.06,2021
Menu