[css: animate.css] CSS animation library - #css
お手軽にアニメーション実装できるライブラリ。
// in riot.js
// animate.css 読み込んでる前提
<h2>
Heading
<span if="{ this.items.length != 0 }" class="animated new badge">
<!-- new と badge は materialize.css のやつです -->
</h2>
<script>
this.items = []
// this.items にモノが入って
// this.update() したら出現→フェードアウト
this.on('updated', () => {
let badge = document.querySelector('.badge')
setTimeout(() => {
badge.classList.add('fadeIn')
}, 5000)
badge.classList.remove('fadeIn')
setTimeout(() => {
badge.classList.add('fadeOut')
}, 5000)
badge.classList.remove('fadeOut')
})
</script>
$.fn.extend({
animateCss: function (animationName) {
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
this.addClass('animated ' + animationName).one(animationEnd, function() {
$(this).removeClass('animated ' + animationName);
});
return this;
}
});
// use it like this:
$('#yourElement').animateCss('bounce');