Last active
October 18, 2017 09:56
-
-
Save zearadoua/0361dbe082bbeffaeba9a1df6112b25c to your computer and use it in GitHub Desktop.
button go-top always stay o top of footer
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
// 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