Pinch_and_Swipe.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <!--
  5. NOTE viewport is set so user can scale
  6. -->
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"/>
  8. <meta http-equiv="x-ua-compatible" content="IE=9">
  9. <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
  10. <link href="http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css" rel="stylesheet" />
  11. <link href="css/main.css" type="text/css" rel="stylesheet" />
  12. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  13. <script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
  14. <script type="text/javascript" src="../jquery.touchSwipe.js"></script>
  15. <script type="text/javascript" src="js/main.js"></script>
  16. <title>touchSwipe</title>
  17. </head>
  18. <body>
  19. <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>
  20. <div class="container">
  21. <script id='code_1'>
  22. $(function() {
  23. $("#test").swipe( {
  24. swipeStatus:function(event, phase, direction, distance , duration , fingerCount) {
  25. $(this).find('#swipe_text').text("swiped " + distance + ' px');
  26. if(phase === $.fn.swipe.phases.PHASE_END || phase === $.fn.swipe.phases.PHASE_CANCEL) {
  27. //The handlers below fire after the status,
  28. // so we can change the text here, and it will be replaced if the handlers below fire
  29. $(this).find('#swipe_text').text("No swipe was made");
  30. }
  31. },
  32. pinchStatus:function(event, phase, direction, distance , duration , fingerCount, pinchZoom) {
  33. $(this).find('#pinch_text').text("pinched " + distance + " px ");
  34. if(phase === $.fn.swipe.phases.PHASE_END || phase === $.fn.swipe.phases.PHASE_CANCEL) {
  35. //The handlers below fire after the status,
  36. // so we can change the text here, and it will be replaced if the handlers below fire
  37. $(this).find('#pinch_text').text("No pinch was made");
  38. }
  39. },
  40. swipe:function(event, direction, distance, duration, fingerCount) {
  41. $(this).find('#swipe_text').text("You swiped " + direction + " with " + fingerCount + " fingers");
  42. },
  43. pinchIn:function(event, direction, distance, duration, fingerCount, pinchZoom) {
  44. $(this).find('#pinch_text').text("You pinched " +direction + " by " + distance +"px, zoom scale is "+pinchZoom);
  45. },
  46. pinchOut:function(event, direction, distance, duration, fingerCount, pinchZoom) {
  47. $(this).find('#pinch_text').text("You pinched " +direction + " by " + distance +"px, zoom scale is "+pinchZoom);
  48. },
  49. fingers:$.fn.swipe.fingers.ALL
  50. });
  51. });
  52. </script>
  53. <span class='title'></span>
  54. <h4>events: <span class='events'><code>pinchStatus</code>, <code>swipeStatus</code></span><h4>
  55. <h4>properties: <span class='properties'><code>pinchThreshold</code></span></h4>
  56. <p>You can combine both <code>pinch</code> and <code>swipe</code> events. As the user can simultaneously pinch and swipe, both events are tirggered at the same time.<br/>
  57. The <code>pinchThreshold</code> property sets how far the user must pinch before it is considered a pinch. The default is 20px. This is useful when trying to elimate slight pinch movement when the user is actually swiping.
  58. </p>
  59. <button class='btn btn-small btn-info example_btn'>Jump to Example</button>
  60. <pre class="prettyprint lang-js" data-src='code_1'></pre>
  61. <span class='navigation'></span>
  62. <div id="test" class="box">
  63. <div id='swipe_text'>Pinch me</div>
  64. <div id='pinch_text'></div>
  65. </div>
  66. <span class='navigation'></span>
  67. </div>
  68. </body>
  69. </html>