Permalink
Browse files

Swipe: Keep swiperight when tearing down swipeleft and vice versa

(cherry picked from commit 0eba6e4)

Closes gh-7353
Fixes gh-7351
  • Loading branch information...
gabrielschulhof committed Apr 28, 2014
1 parent bf06f5e commit 65e81c0de380afddec870e26001c1a08d0e399fd
Showing with 80 additions and 2 deletions.
  1. +2 −2 js/events/touch.js
  2. +39 −0 tests/integration/swipe/binding-tests.html
  3. +39 −0 tests/integration/swipe/binding_tests_core.js
View
@@ -313,8 +313,8 @@ define( [ "jquery", "../jquery.mobile.vmouse", "../jquery.mobile.support.touch"
$.each({
scrollstop: "scrollstart",
taphold: "tap",
swipeleft: "swipe",
swiperight: "swipe"
swipeleft: "swipe.left",
swiperight: "swipe.right"
}, function( event, sourceEvent ) {
$.event.special[ event ] = {
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Mobile Swipe Event Test Suite</title>
<script src="../../../external/requirejs/require.js"></script>
<script src="../../../js/requirejs.config.js"></script>
<script src="../../../js/jquery.tag.inserter.js"></script>
<script src="../../jquery.setNameSpace.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
<link rel="stylesheet" href="../../jqm-tests.css"/>
<script src="../../../external/qunit/qunit.js"></script>
<script>
$.testHelper.asyncLoad([
[
"events/touch"
],
[ "init" ],
[
"binding_tests_core.js"
]
]);
</script>
<script src="../../swarminject.js"></script>
</head>
<body>
<div id="qunit"></div>
<div data-nstest-role="page" id="start-page">
<div class="ui-content" id="page-content"></div>
</div>
</body>
</html>
@@ -0,0 +1,39 @@
test( "Unbinding swipeleft leaves swiperight handler alone", function() {
var dummy = function() {},
swipeLength = function() {
var swipe = $._data( document, "events" ).swipe;
return swipe ? swipe.length : 0;
},
initialSwipeLength = swipeLength();
$( document ).on( "swipeleft swiperight", ".ui-page", dummy );
deepEqual( swipeLength(), initialSwipeLength + 2,
"Two swipe handlers are present after attaching swipeleft and swiperight" );
$( document ).off( "swipeleft", ".ui-page", dummy );
deepEqual( swipeLength(), initialSwipeLength + 1,
"One swipe handler is present after detaching swipeleft" );
$( document ).on( "swipeleft", ".ui-page", dummy );
deepEqual( swipeLength(), initialSwipeLength + 2,
"Two swipe handlers are present after reattaching swipeleft" );
$( document ).off( "swiperight", ".ui-page", dummy );
deepEqual( swipeLength(), initialSwipeLength + 1,
"One swipe handler is present after detaching swiperight" );
$( document ).on( "swiperight", ".ui-page", dummy );
deepEqual( swipeLength(), initialSwipeLength + 2,
"Two swipe handlers are present after reattaching swiperight" );
$( document ).off( "swipeleft swiperight", ".ui-page", dummy );
deepEqual( swipeLength(), initialSwipeLength,
"No swipe handlers are present after detaching both swipeleft and swiperight" );
});

0 comments on commit 65e81c0

Please sign in to comment.