Options.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. //Re set any options with a new options hash
  21. $("#setMultiple").click(function(){
  22. $("#test").swipe({threshold:0, fingers:2});
  23. alert( "Options are now \n" + JSON.stringify( $("#test").swipe("option") ) );
  24. });
  25. //Get the options hash
  26. $("#getAll").click(function(){
  27. alert( JSON.stringify( $("#test").swipe("option") ) );
  28. });
  29. //Legacy set options with the 'option' method
  30. $("#setThreshold").change(function(){
  31. $("#test").swipe("option", "threshold", $(this).val() );
  32. });
  33. $("#getThreshold").click(function(){
  34. alert( $("#test").swipe("option", "threshold") );
  35. });
  36. $("#test").swipe( {
  37. threshold:200,
  38. swipe:function(event, direction, distance, duration, fingerCount){
  39. this.text("You swiped " + distance + "px");
  40. }
  41. });
  42. });
  43. </script>
  44. <span class='title'></span>
  45. <h4>methods: <span class='methods'><code>option</code>, <code>swipe</code></span></h4>
  46. <p>From 1.6.11 onwards you can simply re call <code>swipe</code> and pass a new options hash to update an existing instance</p>
  47. <p>You can also use the legacy <code>option</code> method to can change any of the init option properties at run time.</br>
  48. <b>see the <a href="../docs/%24.fn.swipe.defaults.html"><u>docs</u></a> for more info.
  49. </p>
  50. <button class='btn btn-small btn-info example_btn'>Jump to Example</button>
  51. <pre class="prettyprint lang-js" data-src='code_1'></pre>
  52. <span class='navigation'></span>
  53. </br>
  54. Threshold: <select class='btn' id="setThreshold" style="width:70px;">
  55. <option>20</option>
  56. <option>50</option>
  57. <option>100</option>
  58. <option>200</option>
  59. <option>500</option>
  60. <option>1000</option>
  61. </select>
  62. <button class='btn' id="getThreshold">Get Threshold</button>
  63. <button class='btn' id="getAll">Get All</button>
  64. <button class='btn' id="setMultiple">Set threshold to 0 and fingers to 3</button>
  65. <div id="test" class="box">Swipe me</div>
  66. <br/><br/>
  67. <span class='navigation'></span>
  68. </div>
  69. </body>
  70. </html>