Skip to content

Instantly share code, notes, and snippets.

@zearadoua
Last active October 18, 2017 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zearadoua/0361dbe082bbeffaeba9a1df6112b25c to your computer and use it in GitHub Desktop.
Save zearadoua/0361dbe082bbeffaeba9a1df6112b25c to your computer and use it in GitHub Desktop.
button go-top always stay o top of footer
// Button go Top
$(window).on('scroll' ,function (event) {
var el = $(".region-footer");
var elTop = el.offset().top;
var windowTop = $(window).scrollTop();
var windowHeight = $(window).height();
var windowBottom = windowTop + windowHeight;
var elVisible = windowBottom - elTop;
if (windowBottom >= elTop) {
$(".go-top").css({
'position': 'absolute',
'bottom': el.height()+ 10 +'px'
});
} else {
$(".go-top").css({
'bottom': '20px',
'position': 'fixed',
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment