Back to top function integrated in main.js

This commit is contained in:
pmoreno.rodriguez 2024-07-16 22:31:44 +02:00
parent 79b0019c11
commit 2dd121fde0

View file

@ -91,5 +91,22 @@
breakpoints.on('>large', function() { breakpoints.on('>large', function() {
$intro.prependTo($sidebar); $intro.prependTo($sidebar);
}); });
// Backt to top
var btn = $('#back-to-top');
$(window).scroll(function() {
if ($(window).scrollTop() > 300) {
btn.addClass('show');
} else {
btn.removeClass('show');
}
});
btn.on('click', function(e) {
e.preventDefault();
$('html, body').animate({scrollTop:0}, '300');
});
})(jQuery); })(jQuery);