From 00c9709fd9763542e848f6278db8ba26af5c9886 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 15 Oct 2018 23:46:42 +0200 Subject: Initial commit. --- src/js/scroll-to-top.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/js/scroll-to-top.js (limited to 'src/js/scroll-to-top.js') diff --git a/src/js/scroll-to-top.js b/src/js/scroll-to-top.js new file mode 100644 index 0000000..5f898bd --- /dev/null +++ b/src/js/scroll-to-top.js @@ -0,0 +1,27 @@ +jQuery(window).load(function () { + jQuery(window).scroll(function () { + if (jQuery(this).scrollTop() > 50) { + jQuery('#back-to-top').fadeIn(); + jQuery('#back-to-top').tooltip(); + } else { + jQuery('#back-to-top').fadeOut(); + } + }); + // scroll body to 0px on click + jQuery('#back-to-top').click(function () { + jQuery('#back-to-top').tooltip('hide'); + jQuery('body,html').animate({ + scrollTop: 0 + }, 'slow'); + return false; + }); + + if ( jQuery('#back-to-top').is(":visible") ) { + jQuery('#back-to-top').tooltip('show'); + } +}); +/* +window.onload = function(){ + +}; +*/ -- cgit v1.2.3