This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swipe: Keep swiperight when tearing down swipeleft and vice versa
- Loading branch information
Gabriel Schulhof
committed
May 23, 2014
1 parent
bf06f5e
commit 65e81c0
Showing
3 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" ); | ||
}); |