Debian Codegraph @

demos/effect/easing.html

raw symbols SCIP
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>jQuery UI Effects - Easing demo</title>
7 <link rel="stylesheet" href="../../themes/base/all.css">
8 <link rel="stylesheet" href="../demos.css">
9 <style>
10 .graph {
11 float: left;
12 margin-left: 10px;
13 }
14 </style>
15 <script src="../../external/requirejs/require.js"></script>
16 <script src="../bootstrap.js">
17 if ( !$( "<canvas>" )[0].getContext ) {
18 $( "<div>" ).text(
19 "Your browser doesn't support canvas, which is required for this demo."
20 ).appendTo( "#graphs" );
21 return;
22 }
23
24 var i = 0,
25 width = 100,
26 height = 100;
27
28 $.each( $.easing, function( name, impl ) {
29 // Skip _default property
30 if ( typeof impl !== "function" ) {
31 return;
32 }
33 var graph = $( "<div>" ).addClass( "graph" ).appendTo( "#graphs" ),
34 text = $( "<div>" ).text( name ).css({ fontSize: "13px", textAlign: "center", whiteSpace: "nowrap" }).appendTo( graph ),
35 wrap = $( "<div>" ).appendTo( graph ).css( 'overflow', 'hidden' ),
36 canvas = $( "<canvas>" ).appendTo( wrap )[ 0 ];
37
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 // Draw background
46 ctx.beginPath();
47 ctx.moveTo( cradius, 0 );
48 ctx.quadraticCurveTo( 0, 0, 0, cradius );
49 ctx.lineTo( 0, height - cradius );
50 ctx.quadraticCurveTo( 0, height, cradius, height );
51 ctx.lineTo( width - cradius, height );
52 ctx.quadraticCurveTo( width, height, width, height - cradius );
53 ctx.lineTo( width, 0 );
54 ctx.lineTo( cradius, 0 );
55 ctx.fill();
56
57 // Draw bottom line
58 ctx.strokeStyle = "#555";
59 ctx.beginPath();
60 ctx.moveTo( width * 0.1, drawHeight + .5 );
61 ctx.lineTo( width * 0.9, drawHeight + .5 );
62 ctx.stroke();
63
64 // Draw top line
65 ctx.strokeStyle = "#555";
66 ctx.beginPath();
67 ctx.moveTo( width * 0.1, drawHeight * .3 - .5 );
68 ctx.lineTo( width * 0.9, drawHeight * .3 - .5 );
69 ctx.stroke();
70
71 // Plot easing
72 ctx.strokeStyle = "white";
73 ctx.beginPath();
74 ctx.lineWidth = 2;
75 ctx.moveTo( width * 0.1, drawHeight );
76 $.each( new Array( width ), function( position ) {
77 var state = position / width,
78 val = impl( state, position, 0, 1, width );
79 ctx.lineTo( position * 0.8 + width * 0.1,
80 drawHeight - drawHeight * val * 0.7 );
81 });
82 ctx.stroke();
83
84 // Animate on click
85 graph.on( "click", function() {
86 wrap
87 .animate( { height: "hide" }, 2000, name )
88 .delay( 800 )
89 .animate( { height: "show" }, 2000, name );
90 });
91
92 graph.width( width ).height( height + text.height() + 10 );
93 });
94 </script>
95 </head>
96 <body>
97
98 <div id="graphs"></div>
99
100 <div class="demo-description">
101 <p><strong>All easings provided by jQuery UI are drawn above, using an HTML canvas element</strong>. Click a diagram to see the easing in action.</p>
102 </div>
103 </body>
104 </html>