2017-08-22 87 views
0

上午使用scrollify.js进行页面滚动。我有我的自定义导航栏,它曾用来通过使用offsetTop滚动。Scrollify.js导航问题

$(".fixed-nav a").click(function(evn) { 
    evn.preventDefault(); 
    $('html, body').animate({ 
     scrollTop: $($(this).attr('href')).offset().top 
    }, 500); 
}); 

我的页面也有滚动部分以及正常部分。那是我有6个部分,其中前三个是scrollfy部分,其余三个是正常部分。

一切工作正常。但是问题在于,从第1节点击第6号(即非滚动部分)部分,在第3号(这是最后滚动部分)部分登陆,而不是在第6部分登陆。

这里是fiddler作为参考。任何帮助赞赏。提前致谢。

回答

0

无法找到任何解决方案或建议。所以我写了自己的定义来解决我的问题。这帮助了我。

当我点击没有滚动效果的导航时,我用$.scrollify.instantMove()移动到上一个滚动部分,然后使用正常的scrollTop jquery导航到期望部分。

$(".fixed-nav a").click(function(evn) { 
    evn.preventDefault(); 
    if ($(this).hasClass('no-scroll') && (!$(this).closest('li').siblings('.active').find('a').hasClass('no-scroll'))) { 
     $.scrollify.instantMove('#3'); 
     $('html, body').animate({ 
     scrollTop: $($(this).attr('href')).offset().top 
     }, 500); 
    } else { 
     $('html, body').animate({ 
     scrollTop: $($(this).attr('href')).offset().top 
     }, 500); 
    } 
    }); 
}); 

找到这个fiddler作为参考。