为iPhone设备打开覆盖时禁用背景滚动 [英] Disable background scroll when overlay gets opened for iphone devices
问题描述
当我尝试打开叠加层并滚动叠加层时,即使背景也会滚动。
我尝试了什么:
我尝试使用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屋!