How can Slow down scroll to top event by jQuery animate?
$('#go-to-top').click(function() {
$(window.opera ? 'html' : 'html, body').animate({
scrollTop: 0
}, 80);
});
To slow down the scroll you can increase the time it takes to complete the animation. Currently, it's taking 80ms. If you change that number to 1 second, you can see the difference:
$('#go-to-top').click(function () {
$(window.opera ? 'html' : 'html, body').animate({
scrollTop: 0
}, 1000); // scroll takes 1 second
});
Example fiddle
You can also add easing effects if you have included the jQueryUI easing library in your page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With