我正在处理一个带有固定菜单的页面,该菜单在用户从顶部滚动一定距离后拾取,当它们向下滚动页面时,菜单中的不同链接将被赋予一个更改颜色的类.所有这一切似乎都适用于Chrome和Safari,但在Firefox中,页面冻结在顶部.我想知道它是否在不断地循环一些代码......基本上冻结了窗口.
这是我的代码.
$.localScroll({
onBefore: function() {
$('body').data('scroll-executing', true);
},
onAfter: function() {
$('body').data('scroll-executing', false);
$(window).trigger("scroll");
}
});
$(window).scroll(function () {
if ($(this).scrollTop() > 259) {
$('.nav').addClass("f-nav");
} else {
$('.nav').removeClass("f-nav");
}
});
$(window).scroll(function() {
if ($('body').data('scroll-executing')) {
return;
}
// find the a with class 'active' and remove it
$("a").removeClass('active');
// get the amount the window has scrolled
var scroll = $(window).scrollTop();
// add the 'active' class to the correct #nav based on the scroll amount
if (scroll > 2150) …Run Code Online (Sandbox Code Playgroud)