Skip to content

Commit 3cbe993

Browse files
kas-coreltonmesquita
authored andcommitted
Added callback for jQuery extension (#601)
Added to the extension for JQuery, callback function.
1 parent ff65094 commit 3cbe993

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,13 @@ You can also extend jQuery to add a function that does it all for you:
123123

124124
```javascript
125125
$.fn.extend({
126-
animateCss: function (animationName) {
126+
animateCss: function (animationName, callback) {
127127
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
128128
this.addClass('animated ' + animationName).one(animationEnd, function() {
129129
$(this).removeClass('animated ' + animationName);
130+
if (callback) {
131+
callback();
132+
}
130133
});
131134
return this;
132135
}
@@ -137,6 +140,10 @@ And use it like this:
137140

138141
```javascript
139142
$('#yourElement').animateCss('bounce');
143+
or
144+
$('#yourElement').animateCss('bounce', function () {
145+
// Do somthing after animation
146+
});
140147
```
141148

142149
You can change the duration of your animations, add a delay or change the number of times that it plays:

0 commit comments

Comments
 (0)