为iPhone设备打开覆盖时禁用背景滚动 [英] Disable background scroll when overlay gets opened for iphone devices

查看:88
本文介绍了为iPhone设备打开覆盖时禁用背景滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试打开叠加层并滚动叠加层时,即使背景也会滚动。



我尝试了什么:



我尝试使用touchmove事件来禁用背景滚动但是在尝试滚动覆盖时,即使背景被滚动,但它的动作仍被禁用。



$('body')。on('touchmove',function(event){

event.preventDefault();

});

$('。category-list')。on('touchmove',function(event){

event.stopPropagation();

});

When i try to open a overlay and scroll the overlay, even the background gets scrolled.

What I have tried:

I have tried with touchmove event for disable the background scroll but while tried to scroll the overlay even the background gets scrolled though its action is disabled.

$('body').on('touchmove', function(event) {
event.preventDefault();
});
$('.category-list').on('touchmove', function(event) {
event.stopPropagation();
});

推荐答案

('body')。on('touchmove',function(event){

event .preventDefault();

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


('。category-list')。on('touchmove',function(event) {

event.stopPropagation();

});
('.category-list').on('touchmove', function(event) {
event.stopPropagation();
});


这篇关于为iPhone设备打开覆盖时禁用背景滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆