Jquery mobile 输入范围的jquery移动滑动事件禁用

Jquery mobile 输入范围的jquery移动滑动事件禁用,jquery-mobile,swipe,Jquery Mobile,Swipe,我正在使用jquery mobile关闭和打开应用程序中的菜单,如下所示: $('body').on('swipeleft', function(event){ if(menuOpen == true){ home.showMenu(); } }); $('body').on('swiperight', function(event){ if(menuOpen == false){ home.showMenu(); } });

我正在使用jquery mobile关闭和打开应用程序中的菜单,如下所示:

$('body').on('swipeleft', function(event){
    if(menuOpen == true){
        home.showMenu();
    }
});

$('body').on('swiperight', function(event){
    if(menuOpen == false){
        home.showMenu();
    }
});
<input id="changeRadiusRange" type="range" min="5" max="100" step="5" oninput="handleInputVal(value)" onchange="handleChangeVal(this.value)">
$('body').on('swipeleft', function(event){
    if(event.target.id != "changeRadiusRange"){
        if(menuOpen == true){
            home.showMenu();
        }
    }
});
我的菜单中有一个输入范围(滑块),如下所示:

$('body').on('swipeleft', function(event){
    if(menuOpen == true){
        home.showMenu();
    }
});

$('body').on('swiperight', function(event){
    if(menuOpen == false){
        home.showMenu();
    }
});
<input id="changeRadiusRange" type="range" min="5" max="100" step="5" oninput="handleInputVal(value)" onchange="handleChangeVal(this.value)">
$('body').on('swipeleft', function(event){
    if(event.target.id != "changeRadiusRange"){
        if(menuOpen == true){
            home.showMenu();
        }
    }
});

我如何强制输入行为正常,不受滑动事件的影响?

当前解决方法如下:

$('body').on('swipeleft', function(event){
    if(menuOpen == true){
        home.showMenu();
    }
});

$('body').on('swiperight', function(event){
    if(menuOpen == false){
        home.showMenu();
    }
});
<input id="changeRadiusRange" type="range" min="5" max="100" step="5" oninput="handleInputVal(value)" onchange="handleChangeVal(this.value)">
$('body').on('swipeleft', function(event){
    if(event.target.id != "changeRadiusRange"){
        if(menuOpen == true){
            home.showMenu();
        }
    }
});

但在从body调用swipeleft事件后,滑块将停止。不会向左移动更多,因此如果需要,我必须释放滑块并再次向左滑动,直到调用swipeleft等。只是解决方法希望很快将其修复当前解决方法如下:

$('body').on('swipeleft', function(event){
    if(menuOpen == true){
        home.showMenu();
    }
});

$('body').on('swiperight', function(event){
    if(menuOpen == false){
        home.showMenu();
    }
});
<input id="changeRadiusRange" type="range" min="5" max="100" step="5" oninput="handleInputVal(value)" onchange="handleChangeVal(this.value)">
$('body').on('swipeleft', function(event){
    if(event.target.id != "changeRadiusRange"){
        if(menuOpen == true){
            home.showMenu();
        }
    }
});

但在从body调用swipeleft事件后,滑块将停止。不会向左移动更多,因此如果需要,我必须释放滑块并再次向左滑动,直到调用swipeleft等。只是解决方法希望很快将其修复当前解决方法如下:

$('body').on('swipeleft', function(event){
    if(menuOpen == true){
        home.showMenu();
    }
});

$('body').on('swiperight', function(event){
    if(menuOpen == false){
        home.showMenu();
    }
});
<input id="changeRadiusRange" type="range" min="5" max="100" step="5" oninput="handleInputVal(value)" onchange="handleChangeVal(this.value)">
$('body').on('swipeleft', function(event){
    if(event.target.id != "changeRadiusRange"){
        if(menuOpen == true){
            home.showMenu();
        }
    }
});

但在从body调用swipeleft事件后,滑块将停止。不会向左移动更多,因此如果需要,我必须释放滑块并再次向左滑动,直到调用swipeleft等。只是解决方法希望很快将其修复当前解决方法如下:

$('body').on('swipeleft', function(event){
    if(menuOpen == true){
        home.showMenu();
    }
});

$('body').on('swiperight', function(event){
    if(menuOpen == false){
        home.showMenu();
    }
});
<input id="changeRadiusRange" type="range" min="5" max="100" step="5" oninput="handleInputVal(value)" onchange="handleChangeVal(this.value)">
$('body').on('swipeleft', function(event){
    if(event.target.id != "changeRadiusRange"){
        if(menuOpen == true){
            home.showMenu();
        }
    }
});

但在从body调用swipeleft事件后,滑块将停止。不会向左移动更多,因此如果需要,我必须释放滑块并再次向左滑动,直到调用swipeleft等。只是解决方法希望很快将其修复

我今天遇到了相同的问题,并找到了一个不太棘手的解决方案

var handleSwipe = function (event) {
    // my swipe stuff
}

// regular event listening
$(document).on("swipeleft swiperight", handleSwipe);

// additional workaround
$(".slider").on("mousedown touchstart", function (event) {
    // when starting to interact with a .slider, stop listening the event
    $(document).off("swipeleft swiperight");
}).on("mouseup touchend", function (event) {
    // when interaction stops, re-listen to swipe events
    $(document).on("swipeleft swiperight", handleSwipe);
});
似乎滑块永远不会正常工作,只要滑动事件在文档中的任何位置使用。甚至在事件处理程序中没有任何操作的情况下也是如此。而且
preventDefault()
和/或
stopPropagation()
不会改变任何东西


使用此解决方案,我可以在用户与滑块交互时终止以前启用的滑动事件。交互完成后,我会重新启用刷卡事件。对我来说效果很好。

我今天也遇到了同样的问题,找到了一个不那么麻烦的解决方案

var handleSwipe = function (event) {
    // my swipe stuff
}

// regular event listening
$(document).on("swipeleft swiperight", handleSwipe);

// additional workaround
$(".slider").on("mousedown touchstart", function (event) {
    // when starting to interact with a .slider, stop listening the event
    $(document).off("swipeleft swiperight");
}).on("mouseup touchend", function (event) {
    // when interaction stops, re-listen to swipe events
    $(document).on("swipeleft swiperight", handleSwipe);
});
似乎滑块永远不会正常工作,只要滑动事件在文档中的任何位置使用。甚至在事件处理程序中没有任何操作的情况下也是如此。而且
preventDefault()
和/或
stopPropagation()
不会改变任何东西


使用此解决方案,我可以在用户与滑块交互时终止以前启用的滑动事件。交互完成后,我会重新启用刷卡事件。对我来说效果很好。

我今天也遇到了同样的问题,找到了一个不那么麻烦的解决方案

var handleSwipe = function (event) {
    // my swipe stuff
}

// regular event listening
$(document).on("swipeleft swiperight", handleSwipe);

// additional workaround
$(".slider").on("mousedown touchstart", function (event) {
    // when starting to interact with a .slider, stop listening the event
    $(document).off("swipeleft swiperight");
}).on("mouseup touchend", function (event) {
    // when interaction stops, re-listen to swipe events
    $(document).on("swipeleft swiperight", handleSwipe);
});
似乎滑块永远不会正常工作,只要滑动事件在文档中的任何位置使用。甚至在事件处理程序中没有任何操作的情况下也是如此。而且
preventDefault()
和/或
stopPropagation()
不会改变任何东西


使用此解决方案,我可以在用户与滑块交互时终止以前启用的滑动事件。交互完成后,我会重新启用刷卡事件。对我来说效果很好。

我今天也遇到了同样的问题,找到了一个不那么麻烦的解决方案

var handleSwipe = function (event) {
    // my swipe stuff
}

// regular event listening
$(document).on("swipeleft swiperight", handleSwipe);

// additional workaround
$(".slider").on("mousedown touchstart", function (event) {
    // when starting to interact with a .slider, stop listening the event
    $(document).off("swipeleft swiperight");
}).on("mouseup touchend", function (event) {
    // when interaction stops, re-listen to swipe events
    $(document).on("swipeleft swiperight", handleSwipe);
});
似乎滑块永远不会正常工作,只要滑动事件在文档中的任何位置使用。甚至在事件处理程序中没有任何操作的情况下也是如此。而且
preventDefault()
和/或
stopPropagation()
不会改变任何东西


使用此解决方案,我可以在用户与滑块交互时终止以前启用的滑动事件。交互完成后,我会重新启用刷卡事件。非常适合我。

这在jqm 1.4.5中非常适合我:

$(document).on('mousedown touchstart', 'input[type=range]',
function(e){
e.stopPropagation();
});

这对我来说适用于jqm 1.4.5:

$(document).on('mousedown touchstart', 'input[type=range]',
function(e){
e.stopPropagation();
});

这对我来说适用于jqm 1.4.5:

$(document).on('mousedown touchstart', 'input[type=range]',
function(e){
e.stopPropagation();
});

这对我来说适用于jqm 1.4.5:

$(document).on('mousedown touchstart', 'input[type=range]',
function(e){
e.stopPropagation();
});

我的经历:当我做某事时,比如:$('changeRadiusRange').on('swipleft-swiperight',function(e){crash});它确实有效。当然,每次滑块改变值时,我都会得到一个“ReferenceError:找不到变量:崩溃”,但菜单保持打开状态,只要我选择了我的值,我就可以四处滑动。答案不可能是对的吗?我必须调用什么方法,因为preventDefault、stopPropagation或stopImmediatePropagation不起作用我所经历的:当我执行以下操作时:$('changeRadiusRange')。on('swipeleft swiperight',function(e){crash});它确实有效。当然,每次滑块改变值时,我都会得到一个“ReferenceError:找不到变量:崩溃”,但菜单保持打开状态,只要我选择了我的值,我就可以四处滑动。答案不可能是对的吗?我必须调用什么方法,因为preventDefault、stopPropagation或stopImmediatePropagation不起作用我所经历的:当我执行以下操作时:$('changeRadiusRange')。on('swipeleft swiperight',function(e){crash});它确实有效。当然,每次滑块改变值时,我都会得到一个“ReferenceError:找不到变量:崩溃”,但菜单保持打开状态,只要我选择了我的值,我就可以四处滑动。答案不可能是对的吗?我必须调用什么方法,因为preventDefault、stopPropagation或stopImmediatePropagation不起作用我所经历的:当我执行以下操作时:$('changeRadiusRange')。on('swipeleft swiperight',function(e){crash});它确实有效。当然,每次滑块改变值时,我都会得到一个“ReferenceError:找不到变量:崩溃”,但菜单保持打开状态,只要我选择了我的值,我就可以四处滑动。答案不可能是对的吗?我必须调用什么方法,因为preventDefault、StopRopagation或stopImmediatePropagation不起作用没有比('swipleft swiperight',function(e){crash})上的$('changeRadiusRange')更好的方法了吗;?因为要修复此问题并且不获取任何引用错误,没有比$(“#changeRadiusRange”).on('swipleft swiperight',function(e){crash})更好的方法吗;?因为要修复此问题并且不获取任何引用错误,没有比$(“#changeRadiusRange”).on('swipleft swiperight',function(e){crash})更好的方法吗;?贝卡