触摸屏滚动禁用 [英] Touchscreen scroll disable

查看:107
本文介绍了触摸屏滚动禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的工作,我必须在触摸屏应用程序上创建帮助文件。
通常页面可以通过触摸滚动,这很好,但现在他们要我创建一些可移动的弹出窗口,并且移动会干扰触摸屏的滚动。有弹出窗口在屏幕上时禁用滚动背景的方法吗?

For my work i have to create help file on a touchscreen application. Normally the page is scrollable by touch, which is fine, but now they asked me to create some movable popup, and the movement interferes with the scroll of the touchscreen. Is there a way to disable the scrolling of the background while the popup is on the screen?

我看过以下帖子:在显示弹出窗口时阻止背景滚动。

I have seen the following post: Prevent Background Scrolling When Displaying Popup.

但是 $(窗口).scroll(function(){return false;}); 不似乎对我有用。

我的应用程序在IE7的后台工作..

My application works on the background with IE7..

我使用的代码现在如下。

The code i use now is as followed.

_overlay: function (status) {
    switch (status) {
        case 'show':
            $(window).scroll(function () {
                return false;
            });
            $.alerts._overlay('hide');
            $("BODY").append('<div id="popup_overlay"></div>');
            $("#popup_overlay").css({
                position: 'absolute',
                zIndex: 99998,
                top: '0px',
                left: '0px',
                width: '100%',
                height: $(document).height(),
                background: $.alerts.overlayColor,
                opacity: $.alerts.overlayOpacity
            });
            break;
        case 'hide':
            $(window).unbind('scroll');
            $("#popup_overlay").remove();
            break;
    }
},

这会在背景和弹出窗口之间创建一个叠加层,但背景仍然可滚动。删除滚动条实际上​​不是一个解决方案,因为我使用触摸和滑动。

This creates a overlay between the background and popup, but the background is still scrollable. Removing the scrollbar isn't really a solution, cause i use touch and swipe.

推荐答案

如果你正在使用jQueryMobile使用这个每当你想要阻止页面滚动时代码:

if you're using jQueryMobile use this code whenever you want to stop the page from scrolling:

$(document).bind('touchmove', function(e) {
    e.preventDefault();
});

然后使用此代码让它再次滚动:

and then use this code to let it scroll again:

$(document).unbind('touchmove');

这篇关于触摸屏滚动禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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