tutorial-Page_scrolling.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Tutorial: Page scrolling - Documentation</title>
  6. <script src="scripts/prettify/prettify.js"></script>
  7. <script src="scripts/prettify/lang-css.js"></script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  12. <link type="text/css" rel="stylesheet" href="styles/prettify.css">
  13. <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
  14. </head>
  15. <body>
  16. <input type="checkbox" id="nav-trigger" class="nav-trigger" />
  17. <label for="nav-trigger" class="navicon-button x">
  18. <div class="navicon"></div>
  19. </label>
  20. <label for="nav-trigger" class="overlay"></label>
  21. <nav>
  22. <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="$.html">$</a></li><li><a href="$.fn.html">fn</a></li><li><a href="$.fn.swipe.html">swipe</a><ul class='methods'><li data-type='method'><a href="$.fn.swipe.html#destroy">destroy</a></li><li data-type='method'><a href="$.fn.swipe.html#disable">disable</a></li><li data-type='method'><a href="$.fn.swipe.html#enable">enable</a></li><li data-type='method'><a href="$.fn.swipe.html#option">option</a></li></ul></li></ul><h3>Events</h3><ul><li><a href="$.fn.swipe.html#event:click">click</a></li><li><a href="$.fn.swipe.html#event:doubleTap">doubleTap</a></li><li><a href="$.fn.swipe.html#event:hold">hold</a></li><li><a href="$.fn.swipe.html#event:longTap">longTap</a></li><li><a href="$.fn.swipe.html#event:pinchIn">pinchIn</a></li><li><a href="$.fn.swipe.html#event:pinchOut">pinchOut</a></li><li><a href="$.fn.swipe.html#event:pinchStatus">pinchStatus</a></li><li><a href="$.fn.swipe.html#event:swipe">swipe</a></li><li><a href="$.fn.swipe.html#event:swipeDown">swipeDown</a></li><li><a href="$.fn.swipe.html#event:swipeLeft">swipeLeft</a></li><li><a href="$.fn.swipe.html#event:swipeRight">swipeRight</a></li><li><a href="$.fn.swipe.html#event:swipeStatus">swipeStatus</a></li><li><a href="$.fn.swipe.html#event:swipeUp">swipeUp</a></li><li><a href="$.fn.swipe.html#event:tap">tap</a></li></ul><h3>Namespaces</h3><ul><li><a href="$.fn.swipe.defaults.html">defaults</a></li><li><a href="$.fn.swipe.directions.html">directions</a></li><li><a href="$.fn.swipe.fingers.html">fingers</a></li><li><a href="$.fn.swipe.pageScroll.html">pageScroll</a></li><li><a href="$.fn.swipe.phases.html">phases</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-Any_finger_swipe.html">Any finger swipe</a></li><li><a href="tutorial-Basic_swipe.html">Basic swipe</a></li><li><a href="tutorial-Enable_and_destroy.html">Enable and destroy</a></li><li><a href="tutorial-Excluded_children.html">Excluded children</a></li><li><a href="tutorial-Finger_swipe.html">Finger swipe</a></li><li><a href="tutorial-Handlers_and_events.html">Handlers and events</a></li><li><a href="tutorial-Hold.html">Hold</a></li><li><a href="tutorial-Image_gallery_example.html">Image gallery example</a></li><li><a href="tutorial-Options.html">Options</a></li><li><a href="tutorial-Page_scrolling.html">Page scrolling</a></li><li><a href="tutorial-Page_zoom.html">Page zoom</a></li><li><a href="tutorial-Pinch.html">Pinch</a></li><li><a href="tutorial-Pinch_and_Swipe.html">Pinch and Swipe</a></li><li><a href="tutorial-Pinch_status.html">Pinch status</a></li><li><a href="tutorial-Single_swipe.html">Single swipe</a></li><li><a href="tutorial-Stop_propegation.html">Stop_propegation</a></li><li><a href="tutorial-Swipe_status.html">Swipe status</a></li><li><a href="tutorial-Tap_vs_swipe.html">Tap vs swipe</a></li><li><a href="tutorial-Thresholds.html">Thresholds</a></li><li><a href="tutorial-Trigger_handlers.html">Trigger handlers</a></li><li><a href="tutorial-index_.html">index</a></li></ul>
  23. </nav>
  24. <div id="main">
  25. <h1 class="page-title">Tutorial: Page scrolling</h1>
  26. <section>
  27. <header>
  28. <h2>Page scrolling</h2>
  29. </header>
  30. <article>
  31. <!DOCTYPE HTML>
  32. <html>
  33. <head>
  34. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  35. <meta http-equiv="x-ua-compatible" content="IE=9">
  36. <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
  37. <link href="http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css" rel="stylesheet" />
  38. <link href="css/main.css" type="text/css" rel="stylesheet" />
  39. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  40. <script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
  41. <script type="text/javascript" src="../jquery.touchSwipe.js"></script>
  42. <script type="text/javascript" src="js/main.js"></script>
  43. <title>touchSwipe</title>
  44. </head>
  45. <body>
  46. <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>
  47. <div class="container">
  48. <script id='code_1'>
  49. $(function() {
  50. $("#test1").swipe( { fingers:'all', swipeLeft:swipe1, swipeRight:swipe1, allowPageScroll:"auto"} );
  51. $("#test2").swipe( { swipeLeft:swipe1, allowPageScroll:"none"} );
  52. $("#test3").swipe( { swipeLeft:swipe2, swipeRight:swipe2} );
  53. $("#test4").swipe( { swipeStatus:swipe2, allowPageScroll:"vertical"} );
  54. $("#test5").swipe( { swipeStatus:swipe2, allowPageScroll:"horizontal" } );
  55. $("#test6").swipe( { pinchStatus:pinch, allowPageScroll:"vertical" } );
  56. //Swipe handlers.
  57. function swipe1(event, direction, distance, duration, fingerCount) {
  58. $(this).text( "You have swiped " + direction +' with ' + fingerCount +' fingers' );
  59. }
  60. function swipe2(event, phase, direction, distance) {
  61. $(this).text( phase +" you have swiped " + distance + "px in direction:" + direction );
  62. }
  63. function pinch(event, phase, direction, distance) {
  64. $(this).text( phase +" you have pinched " + distance + "px in direction:" + direction );
  65. }
  66. });
  67. </script>
  68. <span class='title'></span>
  69. <h4>property: <span class='properties'><code>allowPageScroll</code></span></h4>
  70. <p>You can set how page scrolling is handled by the browser when the user is interacting with a touchSwipe object.
  71. <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>
  72. <ul>
  73. <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>
  74. <li><code>none</code> or <code>$.fn.swipe.pageScroll.NONE</code> <br/>scrolling will never occur.</li>
  75. <li><code>horizontal</code> or <code>$.fn.swipe.pageScroll.HORIZONTAL</code> <br/>horizontal swipes will cause the page to scroll.</li>
  76. <li><code>vertical</code> or <code>$.fn.swipe.pageScroll.VERTICAL</code> <br/>vertical swipes will cause the page to scroll.</li>
  77. </ul>
  78. <br>
  79. 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.
  80. 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.
  81. </p>
  82. <button class='btn btn-small btn-info example_btn'>Jump to Example</button>
  83. <pre class="prettyprint lang-js" data-src="code_1"></pre>
  84. <span class='navigation'></span>
  85. <br><br>
  86. <b>allowPageScroll = "auto" or $.fn.swipe.pageScroll.AUTO</b>
  87. <br><b>Swipe Left or Right </b>The swipe will trigger but the page will NOT scroll.
  88. <br><b>Swipe Up or Down </b>The page will scroll as there is no up or down swipe handler.<br>
  89. <div class="box" id="test1">Swipe me</div>
  90. <br><br>
  91. <b>allowPageScroll = "none" or $.fn.swipe.pageScroll.NONE</b>
  92. <br><b>Swipe Left </b>The swipe will trigger but the page will NOT scroll.
  93. <br><b>Swipe right, Up or Down </b>No swipe handler is defined, so nothihng happens and the page will NOT scroll.<br>
  94. <div class="box" id="test2">Swipe me</div>
  95. <br><br>
  96. <b>allowPageScroll = "horizontal" or $.fn.swipe.pageScroll.HORIZONTAL</b>
  97. <br>Swipe left and right are triggered<br>
  98. <div class="box" id="test3">Swipe me</div>
  99. <br><br>
  100. <b>allowPageScroll = "vertical" or $.fn.swipe.pageScroll.VERTICAL</b>
  101. <br/>
  102. <b>With the general <code>swipe</code> or <code>swipeStatus</code> handlers</b>
  103. <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>
  104. <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.
  105. <div class="box" id="test4" >Swipe me</div>
  106. <br><br>
  107. <b>allowPageScroll = "horizontal" or $.fn.swipe.pageScroll.HORIZONTAL</b>
  108. <br/>
  109. <b>Horizontal, but WITH the general <code>swipe</code> or <code>swipeStatus</code> handlers</b>
  110. <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>
  111. <div class="box" id="test5" >Swipe me</div>
  112. <br><br>
  113. <b>Pinch and allowPageScroll = "vertical" or $.fn.swipe.pageScroll.VERTICAL</b>
  114. <br/>
  115. <b>Vertical, but WITH <code>pinch</code> handlers</b>
  116. <div class="box" id="test6" >Pinch me</div>
  117. <span class='navigation'></span>
  118. </div>
  119. </body>
  120. </html>
  121. </article>
  122. </section>
  123. </div>
  124. <br class="clear">
  125. <footer>
  126. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Sep 17 2018 13:09:45 GMT+0100 (British Summer Time) using the docdash theme.
  127. </footer>
  128. <script>prettyPrint();</script>
  129. <script src="scripts/linenumber.js"></script>
  130. </body>
  131. </html>