手軽なアニメーションの導入方法として、みんな大好き wow.js。
こういう使い方がシンプルなスクリプトは便利ですが、もし弱点をあげるとすれば、一度表示してしまったアイテムは二度とアニメーションしないこと。
何度表示してもアニメーションしてくれないかなと思う場面もあります。
探してみたら、海外の方がGOODなコードを考えてくれていました。
https://github.com/matthieua/WOW/issues/46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('scroll', function(e) { | |
if( $(window).scrollTop() <= 50) { | |
$('.wow').removeClass('animated'); | |
$('.wow').removeAttr('style'); | |
new WOW().init(); | |
} | |
}); |