Skip to content

Commit db98c25

Browse files
committed
Add .finish() entry for jQuery 1.9
1 parent 23df8d8 commit db98c25

1 file changed

Lines changed: 119 additions & 0 deletions

File tree

entries/finish.xml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?xml version="1.0"?>
2+
<entry type="method" name="stop" return="jQuery">
3+
<title>.finish()</title>
4+
<desc>Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements.</desc>
5+
<signature>
6+
<added>1.9</added>
7+
<argument name="queue" type="String" optional="true">
8+
<desc>The name of the queue in which to stop animations.</desc>
9+
</argument>
10+
</signature>
11+
<longdesc>
12+
<p>When <code>.finish()</code> is called on an element, the currently-running animation and all queued animations (if any) immediately stop and their CSS properties set to their target values. All queued animations are removed.</p>
13+
<p>If the first argument is provided, only the animations in the queue represented by that string will be stopped.</p>
14+
<p>The <code>.finish()</code> method is similar to <code>.stop(true, true)</code> in that it clears the queue and the current animation jumps to its end value. It differs, however, in that <code>.finish()</code> also causes the CSS property of all <em>queued</em> animations to jump to their end values, as well.</p>
15+
<blockquote>
16+
<p>Animations may be stopped globally by setting the property <code>$.fx.off</code> to <code>true</code>. When this is done, all animation methods will immediately set elements to their final state when called, rather than displaying an effect.</p>
17+
</blockquote>
18+
</longdesc>
19+
<example>
20+
<desc>Click the Go button once to start the animation, and then click the other buttons to see how they affect the current and queued animations.</desc>
21+
<code><![CDATA[
22+
var horiz = $("#path").width() - 20,
23+
vert = $("#path").height() - 20;
24+
25+
var btns = {
26+
bstt: function () {
27+
$("div.box").stop(true, true);
28+
},
29+
bs: function () {
30+
$("div.box").stop();
31+
},
32+
bsft: function () {
33+
$("div.box").stop(false, true);
34+
},
35+
bf: function () {
36+
$("div.box").finish();
37+
},
38+
bcf: function () {
39+
$("div.box").clearQueue().finish();
40+
},
41+
bsff: function () {
42+
$("div.box").stop(false, false);
43+
},
44+
bstf: function () {
45+
$("div.box").stop(true, false);
46+
},
47+
bcs: function () {
48+
$("div.box").clearQueue().stop();
49+
}
50+
};
51+
52+
53+
$("button.b").on("click", function () {
54+
btns[this.id]();
55+
});
56+
57+
$("#go").on("click", function () {
58+
$(".box")
59+
.clearQueue()
60+
.stop()
61+
.css({
62+
left: 10,
63+
top: 10
64+
})
65+
.animate({
66+
top: vert
67+
}, 3000)
68+
.animate({
69+
left: horiz
70+
}, 3000)
71+
.animate({
72+
top: 10
73+
}, 3000);
74+
});
75+
]]></code>
76+
<html><![CDATA[<div class="box"></div>
77+
<div id="path">
78+
<button id="go">Go</button>
79+
<br>
80+
<button id="bstt" class="b">.stop(true,true)</button>
81+
<button id="bcf" class="b">.clearQueue().finish()</button>
82+
<br>
83+
<button id="bstf" class="b">.stop(true, false)</button>
84+
<button id="bcs" class="b">.clearQueue().stop()</button>
85+
<br>
86+
<button id="bsff" class="b">.stop(false, false)</button>
87+
<button id="bs" class="b">.stop()</button>
88+
<br>
89+
<button id="bsft" class="b">.stop(false, true)</button>
90+
<br>
91+
<button id="bf" class="b">.finish()</button>
92+
</div>
93+
]]></html>
94+
<css><![CDATA[.box {
95+
position: absolute;
96+
top: 10px;
97+
left: 10px;
98+
width: 15px;
99+
height: 15px;
100+
background: black;
101+
}
102+
#path {
103+
height: 244px;
104+
font-size: 70%;
105+
border-left: 2px dashed red;
106+
border-bottom: 2px dashed green;
107+
border-right: 2px dashed blue;
108+
}
109+
button {
110+
width: 12em;
111+
display: block;
112+
text-align: left;
113+
margin: 0 auto;
114+
}
115+
]]></css>
116+
</example>
117+
<category slug="effects/custom-effects"/>
118+
<category slug="version/1.9"/>
119+
</entry>

0 commit comments

Comments
 (0)