1

I have this code to slide in a navbar once the user scrolls past where it's positioned in the DOM and it works great in most browsers. However in IE8 if you scroll with the scrollbar it slides in and immediately slides back out. I think it must be because of the the class is getting added and then immediately removed (possibly the .headsup) class. But I'm not sure how to change the code to keep this functionality

var $win = $(window),
$nav = $('header'),
$next = $('.pingpong')
navTop = $nav.length && $nav.offset().top,
isFixed = 0;
processScroll();
$win.on('scroll', processScroll);

function processScroll() {
    var i, scrollTop = $win.scrollTop();
    if (scrollTop > navTop && !isFixed) {
        isFixed = 1;
        $nav.addClass('hfixed').animate({top: 0}, 300);
        $next.addClass('headsup');
    } else if (scrollTop < navTop && isFixed) {
        isFixed = 0;
        $nav.animate({top: -75}, 300, function(){
            $(this).removeClass('hfixed');
            $next.removeClass('headsup');
        });
    }
}​

http://jsfiddle.net/cutcopypaste/pd83J/

4

0 に答える 0