【发布时间】:2016-01-15 13:37:56
【问题描述】:
我需要隐藏页眉并显示页脚(反之亦然)
当我向下滚动(到达底部)并向上滚动(离开底部)某个<div>:
我正在使用 jQuery,目前我的代码中有一个让我发疯的错误:
滚动后,一切都开始反复“弹跳”...
我尝试使用stop()、one()、queue: false,但没有成功...
当我设置#main的高度时,问题似乎来了,
(如果该部分被注释掉,似乎可以正常工作,如下面的代码)
但我需要调整 #main 的大小,因为页脚比页眉大。
$(window).load(function(){
xxx = '';
$main.css('height','calc(100% - 79px)');
$('.column.right').on('scroll', function(){
if( ($(this).scrollTop() + $(this).innerHeight()) == $(this)[0].scrollHeight){
xxx = 'equal';
console.log('equal');
$header.one().stop().slideUp();
$footer.one().stop().slideDown({ queue: false, duration: 100, complete: function(){ setTimeout(function(){ /*$main.css('height','calc(100% - 221px)');*/ }, 0); } });
}
else if( ($(this).scrollTop() + $(this).innerHeight()) < ($(this)[0].scrollHeight - 0) && xxx == 'equal'){
xxx = 'minor';
console.log('minor');
$header.one().stop().slideDown();
$footer.one().stop().slideUp({ queue: false, duration: 100, complete: function(){ setTimeout(function(){ /*$main.css('height','calc(100% - 79px)');*/ }, 0); } });
}
});
});
我也在 html 和 body 上使用 CSS overflow: hidden
【问题讨论】: