我想让一个网站标题变得粘稠,使标志img变小,并且一旦用户在页面上滚动100px就重新定位导航链接。如何在页面滚动100px后运行一组动画?
这是我目前有:
$(document).ready(function() {
$(window).scroll(function() {
if ($(document).scrollTop() > 100) {
$('#header').addClass('sticky');
$('#logo img').animate({'width':'200px','top':'-10px'});
$('#header').animate({'height':'70px'});
$('#menu_btns ul li').animate({'top':'-24px','left':'-90px'});
$('#store_links').animate({'top':'-20px','left':'0px'});
}
else {
$('#header').removeClass('sticky');
$('#logo img').animate({'width':'287px','top':'0px'});
$('#header').animate({'height':'116px'});
$('#menu_btns ul li').animate({'top':'0px','left':'0px'});
$('#store_links').animate({'top':'0px','left':'0px'});
}
});
});
我遇到的问题是向下滚动之后,一切动画,回到了没有“其他”的动画执行后。
你有没有尝试过使用waypoints? – otherDewi
@otherDewi是否有可能通过航点运行多个动画?用我目前的代码,我可以让粘性导航功能,但只要我添加动画,一切都打破。 –
看到我更新的答案 – otherDewi