boilerplate.js
Version:
Development Tools
33 lines (22 loc) • 751 B
JavaScript
/* https://daneden.github.io/animate.css/
<button>Demo</button>
document.querySelector('button').animateCss('bounce slow delay-2s', () => {
console.log('optional callback after animation ends');
});
*/
Element.prototype.animateCSS = function(animation, cb) {
let element = this;
if (animation.indexOf(' ') < 0) return components.animate.css(element, animation, () => {
cb && cb(element);
});
animation.split(' ').forEach(item => {
components.animate.css(element, item, () => {
buffer(() => {
finished();
}, 100, 'animate.css buffer');
});
});
function finished() {
cb && cb(element);
}
};