Swipe_status.html 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  5. <meta http-equiv="x-ua-compatible" content="IE=9">
  6. <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
  7. <link href="http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css" rel="stylesheet" />
  8. <link href="css/main.css" type="text/css" rel="stylesheet" />
  9. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  10. <script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
  11. <script type="text/javascript" src="../jquery.touchSwipe.js"></script>
  12. <script type="text/javascript" src="js/main.js"></script>
  13. <title>touchSwipe</title>
  14. </head>
  15. <body>
  16. <a href="https://github.com/mattbryson"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="Fork me on GitHub"></a>
  17. <div class="container">
  18. <script id='code_1'>
  19. $(function() {
  20. //Enable swiping...
  21. $("#test").swipe( {
  22. swipeStatus:function(event, phase, direction, distance, duration, fingers, fingerData, currentDirection)
  23. {
  24. var str = "<h4>Swipe Phase : " + phase + "<br/>";
  25. str += "Current direction: " + currentDirection + "<br/>";
  26. str += "Direction from inital touch: " + direction + "<br/>";
  27. str += "Distance from inital touch: " + distance + "<br/>";
  28. str += "Duration of swipe: " + duration + "<br/>";
  29. str += "Fingers used: " + fingers + "<br/></h4>";
  30. //Here we can check the:
  31. //phase : 'start', 'move', 'end', 'cancel'
  32. //direction : 'left', 'right', 'up', 'down'
  33. //distance : Distance finger is from initial touch point in px
  34. //duration : Length of swipe in MS
  35. //fingerCount : the number of fingers used
  36. if (phase!="cancel" && phase!="end") {
  37. if (duration<5000)
  38. str +="Under maxTimeThreshold.<h3>Swipe handler will be triggered if you release at this point.</h3>"
  39. else
  40. str +="Over maxTimeThreshold. <h3>Swipe handler will be canceled if you release at this point.</h3>"
  41. if (distance<200)
  42. str +="Not yet reached threshold. <h3>Swipe will be canceled if you release at this point.</h3>"
  43. else
  44. str +="Threshold reached <h3>Swipe handler will be triggered if you release at this point.</h3>"
  45. }
  46. if (phase=="cancel")
  47. str +="<br/>Handler not triggered. <br/> One or both of the thresholds was not met "
  48. if (phase=="end")
  49. str +="<br/>Handler was triggered."
  50. $("#test").html(str);
  51. },
  52. threshold:200,
  53. maxTimeThreshold:5000,
  54. fingers:'all'
  55. });
  56. });
  57. </script>
  58. <span class='title'></span>
  59. <h4>event: <span class='events'><code>swipeStatus</code></span></h4>
  60. <p>You can also get the current status of the swipe, which can be used in place of all other methods. The status reports <code>phase</code>, <code>direction</code>, <code>distance</code>, <code>duration</code>, <code>fingerCount</code>, <code>fingerData</code> and <code>currentDirection</code>
  61. Below has a 200px threshold and a 5 second time limit
  62. </p>
  63. <button class='btn btn-small btn-info example_btn'>Jump to Example</button>
  64. <pre class="prettyprint lang-js" data-src="code_1"></pre>
  65. <span class='navigation'></span>
  66. <div id="test" class="box">Swipe me</div>
  67. <span class='navigation'></span>
  68. </div>
  69. </body>
  70. </html>