Is this what you are looking for?
var value = $(window).height() + $(window).scrollTop(); var elementTop = $('#pagefooter').offset().top; if( value >= elementTop ) { $('.hanger').removeClass('sidebar'); $('.xoxo').addClass('xoxo xoxo2') $('.xoxo').css("position","absolute"); } else if( value < elementTop ) { $('.hanger').addClass(' hanger sidebar'); $('.xoxo').removeClass('xoxo2 ') $('.xoxo').css("position","fixed"); }
I tested it locally and seemed to work regardless of the size of your window. It basically adds the size of the window to scrolltop to see if the footer has moved to the viewport yet.
2 notes
When scrolling on a mobile device (for example, with iOS), the scroll event is triggered when all pulses end. Thus, you will not see the smooth movement that you see on the desktop.
And the identifier of your footer is not footer , but pagefooter . :)
source share