问题是:
$(window).on('scroll', function() {
var currentTop = $(window).scrollTop();
//check if user is scrolling up
console.log('previousTop is ', this.previous);
if (currentTop < this.previous) {
//if scrolling up...
if (currentTop > 0 && $('.navbar-custom').hasClass('is-fixed')) {
$('.navbar-custom').addClass('is-visible');
} else {
$('.navbar-custom').removeClass('is-visible is-fixed');
}
} else if (currentTop > this.previous) {
//if scrolling down...
$('.navbar-custom').removeClass('is-visible');
if (currentTop > headerHeight && !$('.navbar-custom').hasClass('is-fixed')) $('.navbar-custom').addClass('is-fixed');
}
this.previous = currentTop;
});
我想停在console.log行,而firefox会停止此行,但此行已执行多次。
网页浏览器是:https://blackrockdigital.github.io/startbootstrap-clean-blog/
更多:我是js的新人。如果这是一个简单的问题,对不起,请帮帮我。和铬很好。