i am using this script for scroll to top button:
$(document).ready(function(){
$(".upp").click(function(){
$('html, body').animate({scrollTop: '0px'}, 1200);
});
});
It is going to top while being animated, but the animation is not smooth enough.it jumps at some parts, then slides to top. I even tried increasing the value from 1200 to 5000, but it scrolls while jumping at certain points. i am using simple jquery library (latest version).Do you think that adding jquery UI will solve anything? please help.
I think your best bet is to utilize the easing option of .animate()
From the documentation:
Easing
The remaining parameter of
.animate()is a string naming an easing function to use. An easing function specifies the speed at which the animation progresses at different points within the animation. The only easing implementations in the jQuery library are the default, calledswing, and one that progresses at a constant pace, calledlinear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.
$(".upp").click(function(){
$('html, body').animate({scrollTop: '0px'}, 1200, 'linear');
});
try this:
$('html, body').animate({ scrollTop: $('.docs').offset().top}, 2000);
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