jQuery 上的时间延迟添加 class
time delay on jQuery add class
我目前有一个 CSS3 动画,一旦 window 滚动到某个点,它就会通过添加 class 来触发。我想添加 1 秒的延迟,这样动画就不会突然开始。这是动画发生的页面:
http://www.lindameredith.com/wp/serum/(滚动到第二部分)
我使用的现有代码是:
jQuery(window).scroll(function playani() {
var scroll = jQuery(window).scrollTop();
//add 'ok' class when div position match or exceeds else remove the 'ok' class.
jQuery('#angle').addClass('play', scroll >= jQuery('#angle').offset().top);
});
有谁知道如何调整它以增加延迟?
谢谢你:)
延迟jQuery.addClass()
1秒:
setTimeout(function() {
jQuery('selector').addClass('className');
}, 1000);
到 delay CSS animation 1 秒:
.animated {
/* other animation properties */
animation-delay: 1s;
}
我目前有一个 CSS3 动画,一旦 window 滚动到某个点,它就会通过添加 class 来触发。我想添加 1 秒的延迟,这样动画就不会突然开始。这是动画发生的页面:
http://www.lindameredith.com/wp/serum/(滚动到第二部分)
我使用的现有代码是:
jQuery(window).scroll(function playani() {
var scroll = jQuery(window).scrollTop();
//add 'ok' class when div position match or exceeds else remove the 'ok' class.
jQuery('#angle').addClass('play', scroll >= jQuery('#angle').offset().top);
});
有谁知道如何调整它以增加延迟?
谢谢你:)
延迟jQuery.addClass()
1秒:
setTimeout(function() {
jQuery('selector').addClass('className');
}, 1000);
到 delay CSS animation 1 秒:
.animated {
/* other animation properties */
animation-delay: 1s;
}