移动滚动不适用于嵌套Div

时间:2014-03-19 01:02:24

标签: css mobile scroll

我的正文上有一个滚动条。 但是当我尝试从 div 包含到另一个 div

时,我无法滚动身体
    <body> //scrollable
      <div> //can scroll the body
        <div> //can not scroll the body
        </div>
      </div>
   </body>

有人知道为什么吗?

1 个答案:

答案 0 :(得分:0)

我使用此库修复它:http://labs.rampinteractive.co.uk/touchSwipe

    //scrolling issue
    $("#myDiv").swipe( {
        //Generic swipe handler for all directions
        swipeStatus:function(event, phase, direction, distance, duration, fingers) {
            var curY = window.scrollY;
            if(direction == "up") window.scrollTo(0, curY + 10);
            if(direction == "down") window.scrollTo(0, curY - 10)
        },
        swipeUp:function(event, direction, distance, duration, fingerCount) {
            window.scrollTo(0, distance);
        },
        swipeDown: function(event, direction, distance, duration, fingerCount) {
            window.scrollTo(0, window.scrollY - distance);
        },
        threshold: 10,
        cancelThreshold: 10
    });