Stop floating before the footer block?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
8 views
Found a script that normally scrolled to the footer, but that's back when you scroll up posicin faxed not added.
function checkOffset() {
if($('#social-float').offset().top + $('#social-float').height()
>= $('#footer').offset().top - 10)
$('#social-float').css('position', 'absolute');
if($(document).scrollTop() + window.innerHeight < $('#footer').offset().top)
$('#social-float').css('position', 'fixed'); // restore when you scroll up
$('#social-float').text($(document).scrollTop() + window.innerHeight);
}
$(document).scroll(function() {
checkOffset();
});

this script
by | 8 views

1 Answer

0 like 0 dislike
function checkOffset() { var padding = 10; var social_float_height_css_px = 120; if($('#social-float').offset().top + $('#social-float').height() >= $('#footer').offset().top - padding) { $('#social-float').css('position', 'fixed'); $('#social-float').offset({ top: $('#footer').offset().top - social_float_height_css_px - padding }); } else { $('#social-float').css('position', 'fixed'); $('#social-float').offset({ top: $(document).scrollTop() + padding }); } $('#social-float').text($(document).scrollTop() + window.innerHeight); }
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,456 users