Added back to top button.

This commit is contained in:
Jan Böhmer 2019-03-26 16:40:05 +01:00
parent 32a54293a5
commit 528be3c000
2 changed files with 31 additions and 0 deletions

View file

@ -128,6 +128,28 @@ $(document).on("ajaxUI:start ajaxUI:reload", function () {
});
/**
* Register the button, to jump to the top of the page.
*/
$(document).on("ajaxUI:start", function registerJumpToTop() {
$(window).scroll(function () {
if ($(this).scrollTop() > 50) {
$('#back-to-top').fadeIn();
} else {
$('#back-to-top').fadeOut();
}
});
// scroll body to 0px on click
$('#back-to-top').click(function () {
$('#back-to-top').tooltip('hide');
$('body,html').animate({
scrollTop: 0
}, 800);
return false;
}).tooltip();
});
//Need for proper body padding, with every navbar height
$(window).resize(function () {
let height : number = $('#navbar').height() + 10;