我正在使用Osvaldas Valutis的Auto-Hide Sticky Header。我的JS文件如下所示:
$window.on( 'scroll', throttle( throttleTimeout, function()
{
dHeight = $document.height();
wHeight = $window.height();
wScrollCurrent = $window.scrollTop();
wScrollDiff = wScrollBefore - wScrollCurrent;
$element.toggleClass( elClassSlide, wScrollCurrent > elSlideOffset ); // toggles "slide" classname
if( wScrollCurrent <= 0 ) // scrolled to the very top; element sticks to the top
$element.removeClass( elClassHidden );
else if( wScrollDiff > 0 && $element.hasClass( elClassHidden ) ) // scrolled up; element slides in
$element.removeClass( elClassHidden );
else if( wScrollDiff < 0 ) // scrolled down
{
if( wScrollCurrent + wHeight >= dHeight && $element.hasClass( elClassHidden ) ) // scrolled to the very bottom; element slides in
$element.removeClass( elClassHidden );
else // scrolled down; element slides out
$element.addClass( elClassHidden );
}
wScrollBefore = wScrollCurrent;
}));
基本上它添加并删除了类header-hidden
。当页面滚动到最底层时,我想更改脚本并显示无导航(即添加类header-hidden
)。我试着做以下事情,但它没有用。
else if( wScrollDiff < 0 ) // scrolled down
$element.addClass( elClassHidden );
知道如何更改脚本吗?
答案 0 :(得分:1)
我为我的侧边栏做了类似的事情。
$(document).ready(function(){
$(window).scroll(function(){
if(($(window).scrollTop() > 150) && ($(window).scrollTop() + $(window).height() < $(document).height() - 400))
{
$(".collpage").addClass('withfixed');
$(".sidebar.three.columns").addClass('fixedfilters');
}
else
{
$(".collpage").removeClass('withfixed');
$(".sidebar.three.columns").removeClass('fixedfilters');
}
})