javascript - Show footer when reaching bottom of page -
i saw similar questions, didn't give me solution. footer show (slideup) when reaching bottom of page , hide again when scrolling towards top. i'm using script shows footer after amount of scrolling.
here fiddle
does know how?
$(window).scroll(function() { if ($(this).scrolltop() > 10) { $( 'footer').slidedown(300); } else { console.log('there'); $('footer').slideup(300); } });
var height; var trigger = 350; $(window).scroll(function() { height = $(document).height()-$(window).height(); console.log(height+" "+$(this).scrolltop()); if ($(this).scrolltop() > height - trigger) { $( 'footer').slidedown(300); } else { $('footer').slideup(300); } });
for better performance, put window height calculation , document height calculation outside of scroll function , run instead once after load ($(){}
) , recalculate on window resize ($(window).resize(function(){}
)
Comments
Post a Comment