/* JS-Button for Scrolling Back to the Top See detailed documentation in Dev/mediawiki deferrable:YES -- This functionality can come a little bit later in the loading process */ (function () { let setup = { visibleTimeAfterScroll: 2000, scrollToTopTime: 300, }; let button = $('' + '
' ); let windowIsScrolling = false; let intervalHandle; // Functions function hideButton() { button.animate( { opacity: 0 }, 300, function() { button.css( { display: 'none' } ); windowIsScrolling = false; }); } // Setup $(document.body).append(button); // Events button.on( 'click', function() { $("html, body").animate({ scrollTop: 0 }, setup.scrollToTopTime); }); $(window).on('scroll', function() { clearInterval( intervalHandle ); intervalHandle = setTimeout( hideButton, setup.visibleTimeAfterScroll ); if( ! windowIsScrolling ) { button.css( { display: 'block', opacity: 0 } ); button.animate( { opacity: 1 }, 300 ); } windowIsScrolling = true; }); })(); /* [[Category:MultiWiki]] */