forked from jquery/api.jquery.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjQuery.queue.xml
192 lines (190 loc) · 5.77 KB
/
jQuery.queue.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?xml version="1.0"?>
<entries>
<desc>Show or manipulate the queue of functions to be executed on the matched element.</desc>
<entry type="method" name="jQuery.queue" return="Array">
<title>jQuery.queue()</title>
<signature>
<added>1.3</added>
<argument name="element" type="Element">
<desc>A DOM element to inspect for an attached queue.</desc>
</argument>
<argument name="queueName" optional="true" type="String">
<desc>A string containing the name of the queue. Defaults to <code>fx</code>, the standard effects queue.</desc>
</argument>
</signature>
<desc>Show the queue of functions to be executed on the matched element.</desc>
<longdesc>
<p><strong>Note:</strong> This is a low-level method, you should probably use <code><a href="/queue/">.queue()</a></code> instead.</p>
</longdesc>
<example>
<desc>Show the length of the queue.</desc>
<code><![CDATA[
$( "#show" ).click(function() {
var n = jQuery.queue( $( "div" )[ 0 ], "fx" );
$( "span" ).text( "Queue length is: " + n.length );
});
function runIt() {
$( "div" )
.show( "slow" )
.animate({
left: "+=200"
}, 2000 )
.slideToggle( 1000 )
.slideToggle( "fast" )
.animate({
left: "-=200"
}, 1500 )
.hide( "slow" )
.show( 1200 )
.slideUp( "normal", runIt );
}
runIt();
]]></code>
<css><![CDATA[
div {
margin: 3px;
width: 40px;
height: 40px;
position: absolute;
left: 0px;
top: 30px;
background: green;
display: none;
}
div.newcolor {
background: blue;
}
span {
color: red;
}
]]></css>
<html><![CDATA[
<button id="show">Show Length of Queue</button>
<span></span>
<div></div>
]]></html>
</example>
<category slug="data"/>
<category slug="utilities"/>
<category slug="version/1.3"/>
</entry>
<entry type="method" name="jQuery.queue" return="jQuery">
<signature>
<added>1.3</added>
<argument name="element" type="Element">
<desc>A DOM element where the array of queued functions is attached.</desc>
</argument>
<argument name="queueName" type="String">
<desc>A string containing the name of the queue. Defaults to <code>fx</code>, the standard effects queue.</desc>
</argument>
<argument name="newQueue" type="Array">
<desc>An array of functions to replace the current queue contents.</desc>
</argument>
</signature>
<signature>
<added>1.3</added>
<argument name="element" type="Element">
<desc>A DOM element on which to add a queued function.</desc>
</argument>
<argument name="queueName" type="String">
<desc>A string containing the name of the queue. Defaults to <code>fx</code>, the standard effects queue.</desc>
</argument>
<argument name="callback" type="Function">
<desc>The new function to add to the queue.</desc>
</argument>
</signature>
<desc>Manipulate the queue of functions to be executed on the matched element.</desc>
<longdesc>
<p><strong>Note:</strong> This is a low-level method, you should probably use <code><a href="/queue/">.queue()</a></code> instead.</p>
<p>Every element can have one or more queues of functions attached to it by jQuery. In most applications, only one queue (called <code>fx</code>) is used. Queues allow a sequence of actions to be called on an element asynchronously, without halting program execution.</p>
<p>The <code>jQuery.queue()</code> method allows us to directly manipulate this queue of functions. Calling <code>jQuery.queue()</code> with a callback is particularly useful; it allows us to place a new function at the end of the queue.</p>
<p>Note that when adding a function with <code>jQuery.queue()</code>, we should ensure that <code>jQuery.dequeue()</code> is eventually called so that the next function in line executes.</p>
</longdesc>
<example>
<desc>Queue a custom function.</desc>
<code><![CDATA[
$( document.body ).click(function() {
var divs = $( "div" )
.show( "slow" )
.animate({ left: "+=200" }, 2000 );
jQuery.queue( divs[ 0 ], "fx", function() {
$( this ).addClass( "newcolor" );
jQuery.dequeue( this );
});
divs.animate({ left: "-=200" }, 500 );
jQuery.queue( divs[ 0 ], "fx", function() {
$( this ).removeClass( "newcolor" );
jQuery.dequeue( this );
});
divs.slideUp();
});
]]></code>
<css><![CDATA[
div {
margin: 3px;
width: 40px;
height: 40px;
position: absolute;
left: 0px;
top: 30px;
background: green;
display: none;
}
div.newcolor {
background: blue;
}
]]></css>
<html><![CDATA[
Click here...
<div></div>
]]></html>
</example>
<example>
<desc>Set a queue array to delete the queue.</desc>
<code><![CDATA[
$( "#start" ).click(function() {
var divs = $( "div" )
.show( "slow" )
.animate({ left: "+=200" }, 5000 );
jQuery.queue( divs[ 0 ], "fx", function() {
$( this ).addClass( "newcolor" );
jQuery.dequeue( this );
});
divs.animate({ left: "-=200" }, 1500 );
jQuery.queue( divs[ 0 ], "fx", function() {
$( this ).removeClass( "newcolor" );
jQuery.dequeue( this );
});
divs.slideUp();
});
$( "#stop" ).click(function() {
jQuery.queue( $( "div" )[ 0 ], "fx", [] );
$( "div" ).stop();
});
]]></code>
<css><![CDATA[
div {
margin: 3px;
width: 40px;
height: 40px;
position: absolute;
left: 0px;
top: 30px;
background: green;
display: none;
}
div.newcolor {
background: blue;
}
]]></css>
<html><![CDATA[
<button id="start">Start</button>
<button id="stop">Stop</button>
<div></div>
]]></html>
</example>
<category slug="data"/>
<category slug="utilities"/>
<category slug="version/1.3"/>
</entry>
</entries>