javascript – page reload on swipe down in mobile browsers

Question:

In mobile browsers, such a feature is implemented that if you swipe from top to bottom and the scroll is in the right position, then the page will reload.
Saw a similar question, but there the author used the overflow: hidden crutch on the body tag. I am interested in more correct decisions to cancel this action.

Answer:

I got this solution:

var lastY = 1;
document.addEventListener("touchmove", function (event) {
    var lastS = document.documentElement.scrollTop;
    if(lastS == 0 && (lastY-event.touches[0].clientY)<0 && event.cancelable){
        event.preventDefault(); 
        event.stopPropagation();
    }
    lastY = event.touches[0].clientY;
},{passive: false});
Scroll to Top