[removed] and scrolling on iOS 5

后端 未结 5 520
说谎
说谎 2020-11-28 02:37

iOS 5 has brought a number of nice things to JavaScript/Web Apps. One of them is improved scrolling. If you add

-webkit-overflow-scroll:touch;
5条回答
  •  一生所求
    2020-11-28 02:59

    Update Per Alvaro's comment, this solution may no longer work as of iOS 11.3.

    You should be able to allow scrolling by selecting whether or not preventDefault is called. E.g.,

    document.ontouchmove = function(e) {
        var target = e.currentTarget;
        while(target) {
            if(checkIfElementShouldScroll(target))
                return;
            target = target.parentNode;
        }
    
        e.preventDefault();
    };
    

    Alternatively, this may work by preventing the event from reaching the document level.

    elementYouWantToScroll.ontouchmove = function(e) {
        e.stopPropagation();
    };
    

    Edit For anyone reading later, the alternate answer does work and is way easier.

提交回复
热议问题