0
我在我的页面上有几个部分,上面有Waypoints css3动画。您可以通过单击菜单链接或向下滚动来访问这些部分,并且我希望Waypoint在这两种情况下都能触发。如何让页面滚动更顺畅Waypoint动画?
事情是有部分:关于,服务,价格,图库,团队等等,让我们说点击图库,我不希望以前的部分触发,因为页面不滚动光滑。
到目前为止,我设法写这个(等其他部分):
var prices = new Waypoint({
element: document.getElementById('prices'),
handler: function(direction) {
// animations in the section
},
offset: 410
});
等其他部分。然后我禁用前面的章节航点,如果点击菜单项进一步下跌的道路:
$('.link').click(function(){
var nameOfLink = $(this).attr('href').replace('#', '');
if(nameOfLink == 'prices') {
Waypoint.disableAll();
navbar.enable();
prices.enable();
}
if(nameOfLink == 'gallery') {
Waypoint.disableAll();
navbar.enable();
gallery.enable();
}
if(nameOfLink == 'team') {
Waypoint.disableAll();
navbar.enable();
team.enable();
}
而这里的平滑滚动代码:
$('html, body').animate({
scrollTop: $($(this).attr('href')).offset().top -104
}, 1000);
return false;
});
它的工作原理肯定比以前更流畅,但仍然不像我希望的那样流畅(正如我在其他网站上看到的那样)。
如何让它更有效?