Effect - Click the button above to show the effect.


SUBMITTED BY: jlolk3r

DATE: Jan. 18, 2016, 5:02 a.m.

FORMAT: HTML

SIZE: 3.0 kB

HITS: 1193

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery UI Effects - Effect demo</title>
  6. <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  7. <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  8. <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  9. <link rel="stylesheet" href="/resources/demos/style.css">
  10. <style>
  11. .toggler { width: 500px; height: 200px; position: relative; }
  12. #button { padding: .5em 1em; text-decoration: none; }
  13. #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; }
  14. #effect h3 { margin: 0; padding: 0.4em; text-align: center; }
  15. .ui-effects-transfer { border: 2px dotted gray; }
  16. </style>
  17. <script>
  18. $(function() {
  19. // run the currently selected effect
  20. function runEffect() {
  21. // get effect type from
  22. var selectedEffect = $( "#effectTypes" ).val();
  23. // most effect types need no options passed by default
  24. var options = {};
  25. // some effects have required parameters
  26. if ( selectedEffect === "scale" ) {
  27. options = { percent: 0 };
  28. } else if ( selectedEffect === "transfer" ) {
  29. options = { to: "#button", className: "ui-effects-transfer" };
  30. } else if ( selectedEffect === "size" ) {
  31. options = { to: { width: 200, height: 60 } };
  32. }
  33. // run the effect
  34. $( "#effect" ).effect( selectedEffect, options, 500, callback );
  35. };
  36. // callback function to bring a hidden box back
  37. function callback() {
  38. setTimeout(function() {
  39. $( "#effect" ).removeAttr( "style" ).hide().fadeIn();
  40. }, 1000 );
  41. };
  42. // set effect from select menu value
  43. $( "#button" ).click(function() {
  44. runEffect();
  45. return false;
  46. });
  47. });
  48. </script>
  49. </head>
  50. <body>
  51. <div class="toggler">
  52. <div id="effect" class="ui-widget-content ui-corner-all">
  53. <h3 class="ui-widget-header ui-corner-all">Effect</h3>
  54. <p>
  55. Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi.
  56. </p>
  57. </div>
  58. </div>
  59. <select name="effects" id="effectTypes">
  60. <option value="blind">Blind</option>
  61. <option value="bounce">Bounce</option>
  62. <option value="clip">Clip</option>
  63. <option value="drop">Drop</option>
  64. <option value="explode">Explode</option>
  65. <option value="fade">Fade</option>
  66. <option value="fold">Fold</option>
  67. <option value="highlight">Highlight</option>
  68. <option value="puff">Puff</option>
  69. <option value="pulsate">Pulsate</option>
  70. <option value="scale">Scale</option>
  71. <option value="shake">Shake</option>
  72. <option value="size">Size</option>
  73. <option value="slide">Slide</option>
  74. <option value="transfer">Transfer</option>
  75. </select>
  76. <button id="button" class="ui-state-default ui-corner-all">Run Effect</button>
  77. </body>
  78. </html>

comments powered by Disqus