Added callback for jQuery extension (#601)

Added to the extension for JQuery, callback function.
This commit is contained in:
Alexsander 2017-11-10 03:39:04 +03:00 committed by Elton Mesquita
parent ff6509420d
commit 3cbe9930c2
1 changed files with 8 additions and 1 deletions

View File

@ -123,10 +123,13 @@ You can also extend jQuery to add a function that does it all for you:
```javascript
$.fn.extend({
animateCss: function (animationName) {
animateCss: function (animationName, callback) {
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
this.addClass('animated ' + animationName).one(animationEnd, function() {
$(this).removeClass('animated ' + animationName);
if (callback) {
callback();
}
});
return this;
}
@ -137,6 +140,10 @@ And use it like this:
```javascript
$('#yourElement').animateCss('bounce');
or
$('#yourElement').animateCss('bounce', function () {
// Do somthing after animation
});
```
You can change the duration of your animations, add a delay or change the number of times that it plays: