Skip to content

Commit 2a5d397

Browse files
committed
Add finish() jQuery example.
1 parent d494b5a commit 2a5d397

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

demos/finish-vs-stop/index.htm

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
6+
<title>
7+
Stop() vs. Finish() In jQuery
8+
</title>
9+
10+
<style type="text/css">
11+
12+
div.box {
13+
background-color: #FAFAFA ;
14+
border: 1px solid #CCCCCC ;
15+
height: 50px ;
16+
line-height: 50px ;
17+
overflow: hidden ;
18+
width: 0px ;
19+
}
20+
21+
form {
22+
margin-bottom: 16px ;
23+
}
24+
25+
</style>
26+
</head>
27+
<body>
28+
29+
<h1>
30+
Stop() vs. Finish() In jQuery
31+
</h1>
32+
33+
<form action="#">
34+
<input type="button" value="Reset" class="reset" />
35+
<input type="button" value="Start" class="start" />
36+
<input type="button" value="Halt" class="halt" />
37+
</form>
38+
39+
<div class="box box1">
40+
Stop()
41+
</div>
42+
43+
<br />
44+
45+
<div class="box box2">
46+
Finish()
47+
</div>
48+
49+
50+
<!-- Load scripts. -->
51+
<script type="text/javascript" src="../../vendor/jquery/jquery-2.0.3.min.js"></script>
52+
<script type="text/javascript">
53+
54+
// Cache our DOM elements like good citizens.
55+
var dom = {
56+
reset: $( "input.reset" ),
57+
start: $( "input.start" ),
58+
halt: $( "input.halt" ),
59+
box1: $( "div.box1" ),
60+
box2: $( "div.box2" )
61+
};
62+
63+
// Reset the demo by quitting all animations and manually
64+
// setting the widths.
65+
dom.reset.click(
66+
function( event ) {
67+
68+
dom.box1.add( dom.box2 )
69+
.stop( true, true )
70+
.width( 0 )
71+
;
72+
73+
}
74+
);
75+
76+
// Start animations on both elements. The animations will
77+
// include a slide-out followed by a slide-in of each element.
78+
// Meaning, there are two different animations in the queue at
79+
// the start of the experiment.
80+
dom.start.click(
81+
function( event ) {
82+
83+
dom.box1.add( dom.box2 )
84+
.animate( { width: "400px" }, 3000 )
85+
.animate( { width: "0px" }, 2000 )
86+
;
87+
88+
}
89+
);
90+
91+
// Stop both animations.
92+
dom.halt.click(
93+
function( event ) {
94+
95+
// True ( clear queue, jump to end ).
96+
dom.box1.stop( true, true );
97+
98+
dom.box2.finish();
99+
100+
}
101+
);
102+
103+
</script>
104+
105+
</body>
106+
</html>

index.htm

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ <h1>
1313
</h1>
1414

1515
<ul>
16+
<li>
17+
<a href="./demos/finish-vs-stop/">Stop() vs. Finish() In jQuery</a>
18+
</li>
1619
<li>
1720
<a href="./demos/link-transclude-angularjs-1.2/">Transclude Function Passed To Link Function In AngularJS 1.2</a>
1821
</li>

0 commit comments

Comments
 (0)