[英]Firefox and IE JS scrolling issue
On this page http://eisenpar.com/chocolate/index-free.html I've tried to create an effect: if you are at the top of the page and make a scroll, page scrolls on the window height and a fixed navigation appears. 在这个页面http://eisenpar.com/chocolate/index-free.html我试图创建一个效果:如果你在页面的顶部并进行滚动,页面滚动窗口高度和固定出现导航。 It works properly in Chrome, Opera and Edge (I haven't tested in Safari yet), but in Firefox and IE11 this effect crashes: it scrolls to bottom and then - to the top without any pause.
它在Chrome,Opera和Edge中运行正常(我还没有在Safari中测试过),但在Firefox和IE11中,这种效果崩溃了:它滚动到底部然后 - 到顶部没有任何停顿。 In IE it shows navigation, in FF it doesn't, just sends me to the top of the page.
在IE中它显示导航,在FF中它没有,只是将我发送到页面的顶部。
Here is my script for this effect: 这是我的效果的脚本:
var scrollBool = false;
jQuery(window).scroll(function() {
var winHeight = window.innerHeight;
navHeight = jQuery('nav').outerHeight();
if (scrollBool == false) {
scrollBool = true;
if(jQuery('nav').hasClass('fixed')) {
if (jQuery('body').scrollTop() + 10 < winHeight) {
jQuery('nav').removeClass('fixed');
jQuery("html, body").stop().animate({
scrollTop: jQuery('header').offset().top
}, 700, function() {
scrollBool = false;
});
} else {
scrollBool = false;
}
} else {
if (jQuery('body').scrollTop() < winHeight) {
if(jQuery('nav a, .link-block a').hasClass('in-scroll')) {
} else {
jQuery("html, body").stop().animate({
scrollTop: jQuery('header').offset().top + winHeight
}, 700, function() {
scrollBool = false;
jQuery('nav').addClass('fixed');
});
}
} else {
scrollBool = false;
}
}
}
});
Finally - fixed. 最后 - 修复。 FF has issues with
jQuery('body').scrollTop()
, it doesn't understand it properly, everything is fixed if I change this to jQuery(window).scrollTop()
FF有
jQuery('body').scrollTop()
,它不能正确理解,如果我将其更改为jQuery(window).scrollTop()
,则一切jQuery(window).scrollTop()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.