[678] | 1 | <!DOCTYPE html> |
---|
| 2 | <html lang="en"> |
---|
| 3 | <head> |
---|
| 4 | <meta charset="utf-8"> |
---|
| 5 | <title>jQuery UI Effects - Easing demo</title> |
---|
| 6 | <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> |
---|
| 7 | <script src="../../jquery-1.6.2.js"></script> |
---|
| 8 | <script src="../../ui/jquery.effects.core.js"></script> |
---|
| 9 | <link rel="stylesheet" href="../demos.css"> |
---|
| 10 | <style> |
---|
| 11 | .graph { |
---|
| 12 | float: left; |
---|
| 13 | margin-left: 10px; |
---|
| 14 | } |
---|
| 15 | </style> |
---|
| 16 | <script> |
---|
| 17 | $(function() { |
---|
| 18 | if ( !$( "<canvas/>" )[0].getContext ) { |
---|
| 19 | $( "<div/>" ).text( |
---|
| 20 | "Your browser doesn't support canvas, which is required for this demo. " + |
---|
| 21 | "Give Firefox 3 a try!" |
---|
| 22 | ).appendTo( "#graphs" ); |
---|
| 23 | return; |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | var i = 0, |
---|
| 27 | width = 100, |
---|
| 28 | height = 100; |
---|
| 29 | $.each( $.easing, function( name, impl ) { |
---|
| 30 | // skip linear/jswing and any non functioning implementation |
---|
| 31 | if ( !$.isFunction( impl ) || /jswing/.test( name ) ) { |
---|
| 32 | return; |
---|
| 33 | } |
---|
| 34 | var graph = $( "<div/>" ).addClass( "graph" ).appendTo( "#graphs" ), |
---|
| 35 | text = $( "<div/>" ).text( ++i + ". " + name ).appendTo( graph ), |
---|
| 36 | wrap = $( "<div/>" ).appendTo( graph ).css( 'overflow', 'hidden' ), |
---|
| 37 | canvas = $( "<canvas/>" ).appendTo( wrap )[ 0 ]; |
---|
| 38 | canvas.width = width; |
---|
| 39 | canvas.height = height; |
---|
| 40 | var drawHeight = height * 0.8, |
---|
| 41 | cradius = 10; |
---|
| 42 | ctx = canvas.getContext( "2d" ); |
---|
| 43 | ctx.fillStyle = "black"; |
---|
| 44 | |
---|
| 45 | ctx.beginPath(); |
---|
| 46 | ctx.moveTo( cradius, 0 ); |
---|
| 47 | ctx.quadraticCurveTo( 0, 0, 0, cradius ); |
---|
| 48 | ctx.lineTo( 0, height - cradius ); |
---|
| 49 | ctx.quadraticCurveTo( 0, height, cradius, height ); |
---|
| 50 | ctx.lineTo( width - cradius, height ); |
---|
| 51 | ctx.quadraticCurveTo( width, height, width, height - cradius ); |
---|
| 52 | ctx.lineTo( width, 0 ); |
---|
| 53 | ctx.lineTo( cradius, 0 ); |
---|
| 54 | ctx.fill(); |
---|
| 55 | |
---|
| 56 | ctx.strokeStyle = "#555"; |
---|
| 57 | ctx.beginPath(); |
---|
| 58 | ctx.moveTo( width * 0.1, drawHeight + .5 ); |
---|
| 59 | ctx.lineTo( width * 0.9, drawHeight + .5 ); |
---|
| 60 | ctx.stroke(); |
---|
| 61 | |
---|
| 62 | ctx.strokeStyle = "#555"; |
---|
| 63 | ctx.beginPath(); |
---|
| 64 | ctx.moveTo( width * 0.1, drawHeight * .3 - .5 ); |
---|
| 65 | ctx.lineTo( width * 0.9, drawHeight * .3 - .5 ); |
---|
| 66 | ctx.stroke(); |
---|
| 67 | |
---|
| 68 | ctx.strokeStyle = "white"; |
---|
| 69 | ctx.beginPath(); |
---|
| 70 | ctx.lineWidth = 2; |
---|
| 71 | ctx.moveTo( width * 0.1, drawHeight ); |
---|
| 72 | $.each( new Array( width ), function( position ) { |
---|
| 73 | var val = impl( 0, position, 0, 1, height ); |
---|
| 74 | if ( /linear|jswing/.test( name ) ) { |
---|
| 75 | val = position / width; |
---|
| 76 | } |
---|
| 77 | ctx.lineTo( position * 0.8 + width * 0.1, |
---|
| 78 | drawHeight - drawHeight * val * 0.7 ); |
---|
| 79 | }); |
---|
| 80 | ctx.stroke(); |
---|
| 81 | graph.click(function() { |
---|
| 82 | wrap |
---|
| 83 | .animate( { height: "hide" }, 2000, name ) |
---|
| 84 | .delay( 800 ) |
---|
| 85 | .animate( { height: "show" }, 2000, name ); |
---|
| 86 | }); |
---|
| 87 | |
---|
| 88 | graph.width( width ).height( height + text.height() + 10 ); |
---|
| 89 | }); |
---|
| 90 | }); |
---|
| 91 | </script> |
---|
| 92 | </head> |
---|
| 93 | <body> |
---|
| 94 | |
---|
| 95 | <div class="demo"> |
---|
| 96 | |
---|
| 97 | <div id="graphs"></div> |
---|
| 98 | |
---|
| 99 | </div><!-- End demo --> |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | <div class="demo-description"> |
---|
| 104 | <p><strong>All easings provided by jQuery UI are drawn above, using a HTML canvas element</strong>. Click a diagram to see the easing in action.</p> |
---|
| 105 | </div><!-- End demo-description --> |
---|
| 106 | |
---|
| 107 | </body> |
---|
| 108 | </html> |
---|