Stop_propegation.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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, fingerCount) {
  23. var str = "";
  24. switch (phase) {
  25. case "start" : str="Started"; break;
  26. case "move" : str="You have moved " + distance +" pixels, past 200 and the handler will fire"; break;
  27. case "end" : str="Handler fired, you swiped " + direction; break;
  28. case "cancel" : str="cancel handler fired"; break;
  29. }
  30. $(this).text(str);
  31. //This will cancel the current swipe and immediately re run this handler with a cancel event
  32. return false;
  33. }
  34. });
  35. });
  36. </script>
  37. <span class='title'></span>
  38. <h4>events: <span class='events'><code>swipeStatus</code></span></h4>
  39. <p>In your event handlers, you can return a value of false if you want to manually cancel the swipe. This will trigger the 'cancel' event.</p>
  40. <button class='btn btn-small btn-info example_btn'>Jump to Example</button>
  41. <pre class="prettyprint lang-js" data-src="code_1"></pre>
  42. <span class='navigation'></span>
  43. <div id="test" class="box">Swipe will start, but then cancel as the event handler returns false</div>
  44. <span class='navigation'></span>
  45. </div>
  46. </body>
  47. </html>