Disable IOS Safari Elastic Scrolling

前端 未结 4 2149
心在旅途
心在旅途 2021-02-13 12:32

I am writing a web app in HTML and JavaScript for use on an iPhone. What I would like to achieve is preventing the app from elastic scrolling (scrolling past the pages extents a

4条回答
  •  鱼传尺愫
    2021-02-13 13:18

    There is a way to achieve this without jQuery:

    document.body.addEventListener('touchmove', function(event) {
        event.preventDefault();
    });
    

    But this is not a proper solution. It's better to wrap your content in some div, and use css property on it:

     -webkit-overflow-scrolling: touch;
    

    Here is the example

    Edit:

    This will only prevent overscroll in webview, not in app. So you need to disable this feature in app config. If you use phonegap:

    
    

    More description here

    If you don't use phonegap, you can use this.

提交回复
热议问题