Skip to content

Commit cd0ab13

Browse files
committed
Add a comparision demo to the easing page, showing easings happen side by side.
1 parent 9eeea1c commit cd0ab13

File tree

4 files changed

+123
-2
lines changed

4 files changed

+123
-2
lines changed

grunt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ grunt.initConfig({
1414
grunt: "grunt.js"
1515
},
1616
watch: {
17-
files: entryFiles,
17+
files: entryFiles.concat( grunt.file.expandFiles( "resources/**") ),
1818
tasks: "deploy"
1919
},
2020
xmllint: {

pages/easings.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88

99
<p>The best way to understand how an easing will affect an animation is to see the equation graphed over time. See below for a graph of all animations available in jQuery UI.</p>
1010

11-
<iframe src="/resources/easing-graph.html" width="100%" height="700"></iframe>
11+
<iframe src="/resources/easing-graph.html" width="100%" height="600"></iframe>
12+
<iframe src="/resources/easing-comparison.html" width="100%" height="500"></iframe>
1213
<category slug="utilities"/>

resources/easing-comparison.html

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>jQuery UI Effects - Easing Comparison demo</title>
6+
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css">
7+
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
8+
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
9+
<style>
10+
body {
11+
font-size: 62.5%;
12+
font-family: "Trebuchet MS", "Arial", "Helvetica", "Verdana", "sans-serif";
13+
}
14+
#tracks {
15+
margin: 0 150px;
16+
}
17+
#tracks div {
18+
border: 2px solid #eee;
19+
padding: 8px;
20+
height: 20px;
21+
margin: 14px;
22+
position: relative;
23+
font-size: 1.1em;
24+
}
25+
#tracks .box {
26+
padding: 5px;
27+
left: 5px;
28+
width: 10px;
29+
height: 10px;
30+
position: absolute;
31+
background: red;
32+
border-radius: 50%;
33+
}
34+
#tracks .label {
35+
padding-left: 24px;
36+
font-size: 1.1em;
37+
line-height: 20px;
38+
}
39+
</style>
40+
<script>
41+
$(function() {
42+
function addEasing( easing ) {
43+
var box = $( "<span>" )
44+
.addClass( "box" )
45+
.data( "easing", easing );
46+
var label = $( "<span>" )
47+
.addClass( "label" )
48+
.text( easing );
49+
$( "<div>")
50+
.append( box )
51+
.append( label )
52+
.appendTo( tracks );
53+
}
54+
55+
var addForm = $( "#add-easing" ),
56+
addSelect = addForm.find( "select" ),
57+
tracks = $( "#tracks" ),
58+
startButton = $( "#start-race" );
59+
60+
$.each( $.easing, function( name ) {
61+
$( "<option>" ).text( name ).appendTo( addSelect );
62+
});
63+
addSelect.change(function() {
64+
addEasing( this.value );
65+
});
66+
67+
addForm.submit(function( event ) {
68+
event.preventDefault();
69+
addEasing( addSelect.val() );
70+
});
71+
72+
tracks.on( "click", "div", function() {
73+
$( this ).remove();
74+
});
75+
76+
startButton.click(function() {
77+
tracks.find( "span" ).each(function() {
78+
var car = $( this );
79+
car
80+
.stop( true, true )
81+
.css({
82+
left: 5
83+
})
84+
.animate({
85+
left: tracks.width() - car.width() - 50
86+
}, 2500, car.data( "easing" ) )
87+
.delay( 300 )
88+
.animate({
89+
left: 5
90+
}, 2500, car.data( "easing" ) );
91+
});
92+
});
93+
94+
addEasing( "linear" );
95+
addEasing( "swing" );
96+
addEasing( "easeOutBounce" );
97+
});
98+
</script>
99+
</head>
100+
<body>
101+
102+
<div id="add-easing">
103+
Select an easing here, click track below to remove
104+
<select ></select>
105+
</div>
106+
107+
<div id="tracks">
108+
</div>
109+
<button id="start-race">Start The Race</button>
110+
111+
<div class="demo-description">
112+
<p></p>
113+
</div>
114+
115+
</body>
116+
</html>

resources/easing-graph.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
88
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
99
<style>
10+
body {
11+
font-size: 62.5%;
12+
font-family: "Trebuchet MS", "Arial", "Helvetica", "Verdana", "sans-serif";
13+
}
1014
.graph {
1115
float: left;
1216
margin-left: 10px;

0 commit comments

Comments
 (0)