我有一个使用全屏幻灯片的单页网站(由fullPage.js提供支持)。
我让这个脚本在页面第一次加载时为一些文本设置动画(第一页是带有动画的页面)我对 JS 相当陌生,所以我想知道如何让它在每次用户导航到幻灯片时执行动画?
JS
:
$(document).ready(function() {
$.fn.fullpage({
slidesColor: ['#161616', '#161616'],
anchors: ['', 'Bye']});
$(".test").each(function(i) {
$(this).delay(i*600).animate({ opacity: 1 }, 700)
});
});
</script>
它只是动画三个spans
。当我导航回幻灯片时,我希望它再次为它们设置动画。另外,当导航到另一张幻灯片时,如何设置opacity
= 0?(以便可以重新设置动画
HTML
:
<div class="section active" id="section0">
<h1>?</h1>
<h2><span class="test">1.</span> <span class="test">2.</span> <span class="test">3.</span></h2>
<a onclick="javascript:window.location='#CV';"><img class="downArrow" src="images/arrow.svg"/></a>
CSS
对于.test
:
.test{
opacity: 0;
}