Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
bbd933cb
Commit
bbd933cb
authored
Dec 04, 2009
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added in the .delay() method for delaying the execution of queued functions and animations.
parent
d42afd0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
data.js
src/data.js
+15
-0
data.js
test/unit/data.js
+15
-0
No files found.
src/data.js
View file @
bbd933cb
...
...
@@ -166,6 +166,21 @@ jQuery.fn.extend({
jQuery
.
dequeue
(
this
,
type
);
});
},
// Based off of the plugin by Clint Helfers, with permission.
// http://blindsignals.com/index.php/2009/07/jquery-delay/
delay
:
function
(
time
,
type
)
{
time
=
jQuery
.
fx
?
jQuery
.
fx
.
speeds
[
time
]
||
time
:
time
;
type
=
type
||
"fx"
;
return
this
.
queue
(
type
,
function
()
{
var
elem
=
this
;
setTimeout
(
function
()
{
jQuery
.
dequeue
(
elem
,
type
);
},
time
);
});
},
clearQueue
:
function
(
type
){
return
this
.
queue
(
type
||
"fx"
,
[]
);
}
...
...
test/unit/data.js
View file @
bbd933cb
...
...
@@ -257,6 +257,21 @@ test("queue() passes in the next item in the queue as a parameter to fx queues",
});
test
(
"delay()"
,
function
()
{
expect
(
2
);
stop
();
var
foo
=
jQuery
({}),
run
=
0
;
foo
.
delay
(
100
).
queue
(
function
(){
run
=
1
;
ok
(
true
,
"The function was dequeued."
);
start
();
});
equals
(
run
,
0
,
"The delay delayed the next function from running."
);
});
test
(
"clearQueue(name) clears the queue"
,
function
()
{
expect
(
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment