我已经为我的网站安装了animate.css插件来动画div,然后我使用了jQuery。
唯一的问题是我加载第一个div后动画一次发生。
我想要的是在滚动到每个div时为每个div加载动画。
我正在使用此代码
/* Every time the window is scrolled ... */
$(window).scroll( function(){
/* Check the location of each desired element */
$('#shopify-section-1514231356920, #shopify-section-1514232991457').each( function(i){
$('#shopify-section-1514231356920, #shopify-section-1514232991457').addClass('animated slideInRight');
var bottom_of_object = $(this).offset().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* If the object is completely visible in the window, fade it it */
if( bottom_of_window > bottom_of_object ){
$(this).animate({'opacity':'1'},500);
}
});
});
CSS:
#shopify-section-1514231356920, #shopify-section-1514232991457 {
-webkit-animation-duration: 4s;
opacity: 0;
}