(function($) { var $window = $(window), $body = $('body'), $header = $('#header'); // Breakpoints. breakpoints({ xlarge: [ '1281px', '1680px' ], large: [ '981px', '1280px' ], medium: [ '737px', '980px' ], small: [ '481px', '736px' ], xsmall: [ null, '480px' ] }); // Play initial animations on page load. $window.on('load', function() { window.setTimeout(function() { $body.removeClass('is-preload'); }, 100); }); // Scrolly. $('.scrolly').scrolly({ offset: function() { return $header.outerHeight() } }); // Menu. $('#menu') .append('') .appendTo($body) .panel({ delay: 500, hideOnClick: true, hideOnSwipe: true, resetScroll: true, resetForms: true, side: 'right' }); // Header. $window.on('resize', function() { $window.trigger('scroll'); }); $body.scrollex({ top: '25vh', mode: 'top', enter: function() { $header.addClass('alt'); }, leave: function() { $header.removeClass('alt'); } }); })(jQuery); // Get the button let mybutton = document.getElementById("myBtn"); // When the user scrolls down 20px from the top of the document, show the button window.onscroll = function() {scrollFunction()}; function scrollFunction() { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { mybutton.style.display = "block"; } else { mybutton.style.display = "none"; } } // When the user clicks on the button, scroll to the top of the document function topFunction() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; }