svennee

 

PC上css控制滚动仅css("overflow","hidden")已足够。

但是,如果在Mobile上还是可以拖动的!所以需要监听touchmove事件。

 

页面禁止拖动、滚动:

$("html,body").css("overflow","hidden").css("height","100%");
                        document.body.addEventListener(\'touchmove\', self.welcomeShowedListener, false);

 

恢复页面拖动、滚动:

$("html,body").css("overflow","").css("height","");
                    document.body.removeEventListener(\'touchmove\', detail.welcomeShowedListener, false);

 

参考:

在移动端设置overflow:hidden为什么页面还能滚?要怎么禁止

移动端的touch事件处理

addEventListener()与removeEventListener() 用法详解

 

分类:

技术点:

相关文章: