Skip to content

Commit

Permalink
Added wiggle callback
Browse files Browse the repository at this point in the history
  • Loading branch information
cschram committed May 1, 2011
1 parent b10d28b commit 7c61ad1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ Make your elements wiggle and waggle!

$('#wiggler').wiggle({
waggle : 5, // amount of wiggle
duration : 2 // how long to wiggle
duration : 2, // how long to wiggle
wiggleCallback : function (elem) {
// callback whenever the element is wiggled
}
});

::wiggles::
Expand Down
4 changes: 4 additions & 0 deletions jquery-wiggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
}, 200);
moveLeft = !moveLeft;

if (options.wiggleCallback) {
options.wiggleCallback(elem);
}

duration -= 0.2;
if (duration <= 0) {
elem.css('left', left);
Expand Down
7 changes: 6 additions & 1 deletion wiggle-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
$('.wiggler').each(function(){
$(this).wiggle({
waggle : Math.random()*20,
duration : 5
duration : 5,
wiggleCallback : function (elem) {
elem.animate({
zoom : 1 + Math.random()
}, 200);
}
}, doSomeWigglin);
})
});
Expand Down

0 comments on commit 7c61ad1

Please sign in to comment.