My code doing slow to fast movements when i call scroll to top action any better solution to fix the smoothness?
my code:
(function () {
var top_link = '';
top_link = $(".top");
var pos = top_link.offset();
$(window).scroll(function () {
if ($(this).scrollTop() > 150) {
top_link.fadeIn();
} else if ($(this).scrollTop() <= 150) {
top_link.fadeOut();
}
});
})();
$(".top").click(function () {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
});