0

I would like a sticky bar to stay at the bottom of the window at all times. As the user scrolls down to the bottom of the page the same bar will stay fixed until the footer shows, then removes its fixed position, temporarily, to stay above the footer until the user scrolls back up and it remains fixed again.

I've achieved a similar effect with a navigation bar (calculated from the top of the window) on another project, but can't figure out reverse it as scrollBottom doesn't seem to exist.

This is the working header code:

var nav = $('.nav');
    fixed = 'nav-fixed';
    hh = $('header').height();

$(window).scroll(function() {
    if( $(this).scrollTop() > hh ) {
        nav.addClass(fixed);
    } else {
        nav.removeClass(fixed);
    }
});

When the trigger class is called:

.fixed {
    position: absolute;
    z-index: 10
    bottom: 0;
}

How would I reverse it for the footer?

Many thanks, Jack.

Jack Barham
  • 3,197
  • 10
  • 41
  • 62

0 Answers0