Page_scrolling.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. $("#test1").swipe( { fingers:'all', swipeLeft:swipe1, swipeRight:swipe1, allowPageScroll:"auto"} );
  21. $("#test2").swipe( { swipeLeft:swipe1, allowPageScroll:"none"} );
  22. $("#test3").swipe( { swipeLeft:swipe2, swipeRight:swipe2} );
  23. $("#test4").swipe( { swipeStatus:swipe2, allowPageScroll:"vertical"} );
  24. $("#test5").swipe( { swipeStatus:swipe2, allowPageScroll:"horizontal" } );
  25. $("#test6").swipe( { pinchStatus:pinch, allowPageScroll:"vertical" } );
  26. //Swipe handlers.
  27. function swipe1(event, direction, distance, duration, fingerCount) {
  28. $(this).text( "You have swiped " + direction +' with ' + fingerCount +' fingers' );
  29. }
  30. function swipe2(event, phase, direction, distance) {
  31. $(this).text( phase +" you have swiped " + distance + "px in direction:" + direction );
  32. }
  33. function pinch(event, phase, direction, distance) {
  34. $(this).text( phase +" you have pinched " + distance + "px in direction:" + direction );
  35. }
  36. });
  37. </script>
  38. <span class='title'></span>
  39. <h4>property: <span class='properties'><code>allowPageScroll</code></span></h4>
  40. <p>You can set how page scrolling is handled by the browser when the user is interacting with a touchSwipe object.
  41. <br/>There are 4 possible settings for the <code>allowPageScroll</code> option. These can be strings, or use the plugin constants in </code>$.fn.swipe.pageScroll</code>
  42. <ul>
  43. <li><code>auto</code> or <code>$.fn.swipe.pageScroll.AUTO</code> <br/>scrolling will only occur if a user swipes in a direction for which you have NOT defined a swipe handler. E.g If only <i>swipeLeft</i> is defined, then a RIGHT, UP or DOWN swipe would cause the page to scroll.</li>
  44. <li><code>none</code> or <code>$.fn.swipe.pageScroll.NONE</code> <br/>scrolling will never occur.</li>
  45. <li><code>horizontal</code> or <code>$.fn.swipe.pageScroll.HORIZONTAL</code> <br/>horizontal swipes will cause the page to scroll.</li>
  46. <li><code>vertical</code> or <code>$.fn.swipe.pageScroll.VERTICAL</code> <br/>vertical swipes will cause the page to scroll.</li>
  47. </ul>
  48. <br>
  49. NOTE: if the general <code>swipe</code> or <code>swipeStatus</code> handlers are specificed, then <code>allowPageScroll</code> will be dissabled by default, as they detect swipes in all directions.
  50. To use scrolling AND the <code>swipe</code> handler, set <code>allowPageScroll</code> to the direction you want the user to be able to scroll.
  51. </p>
  52. <button class='btn btn-small btn-info example_btn'>Jump to Example</button>
  53. <pre class="prettyprint lang-js" data-src="code_1"></pre>
  54. <span class='navigation'></span>
  55. <br><br>
  56. <b>allowPageScroll = "auto" or $.fn.swipe.pageScroll.AUTO</b>
  57. <br><b>Swipe Left or Right </b>The swipe will trigger but the page will NOT scroll.
  58. <br><b>Swipe Up or Down </b>The page will scroll as there is no up or down swipe handler.<br>
  59. <div class="box" id="test1">Swipe me</div>
  60. <br><br>
  61. <b>allowPageScroll = "none" or $.fn.swipe.pageScroll.NONE</b>
  62. <br><b>Swipe Left </b>The swipe will trigger but the page will NOT scroll.
  63. <br><b>Swipe right, Up or Down </b>No swipe handler is defined, so nothihng happens and the page will NOT scroll.<br>
  64. <div class="box" id="test2">Swipe me</div>
  65. <br><br>
  66. <b>allowPageScroll = "horizontal" or $.fn.swipe.pageScroll.HORIZONTAL</b>
  67. <br>Swipe left and right are triggered<br>
  68. <div class="box" id="test3">Swipe me</div>
  69. <br><br>
  70. <b>allowPageScroll = "vertical" or $.fn.swipe.pageScroll.VERTICAL</b>
  71. <br/>
  72. <b>With the general <code>swipe</code> or <code>swipeStatus</code> handlers</b>
  73. <br>These enable all 4 directions, but here we have set <code>allowPageScroll</code> to "vertical" so the user can scroll up and down, and swipe left and right with the general <code>swipe</code> handler.<br>
  74. <br>Note how the vertical swipe is hit and miss. As soon as the page starts scrolling, the user is no longer swiping across the object.
  75. <div class="box" id="test4" >Swipe me</div>
  76. <br><br>
  77. <b>allowPageScroll = "horizontal" or $.fn.swipe.pageScroll.HORIZONTAL</b>
  78. <br/>
  79. <b>Horizontal, but WITH the general <code>swipe</code> or <code>swipeStatus</code> handlers</b>
  80. <br>These enable all 4 directions, but here we have set <code>allowPageScroll</code> to "horizontal" so the user can scroll up and down, and swipe left and right with the general <code>swipe</code> handler.<br>
  81. <div class="box" id="test5" >Swipe me</div>
  82. <br><br>
  83. <b>Pinch and allowPageScroll = "vertical" or $.fn.swipe.pageScroll.VERTICAL</b>
  84. <br/>
  85. <b>Vertical, but WITH <code>pinch</code> handlers</b>
  86. <div class="box" id="test6" >Pinch me</div>
  87. <span class='navigation'></span>
  88. </div>
  89. </body>
  90. </html>