Created
May 20, 2012 10:23
-
-
Save sakamies/2757588 to your computer and use it in GitHub Desktop.
Sticky footer function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var updateFooter = function ($footer) { | |
var window_height = jQuery(window).height(); | |
var body_offset_top = jQuery('body').offset().top; | |
var body_outer_height = jQuery('body').outerHeight(); | |
var body_height = jQuery('body').height(); | |
body_bottom = (body_offset_top + body_outer_height) - ((body_outer_height - body_height)/2); | |
var footer_height = $footer.outerHeight(true); | |
if (!$footer.hasClass('sticky') && window_height > body_bottom) { | |
$footer.addClass('sticky'); | |
} | |
else if ($footer.hasClass('sticky') && window_height < body_bottom + footer_height + 1) { | |
$footer.removeClass('sticky'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment