I am facing a problem on my website. I have used the following line in my javascript
$('html, body').animate({scrollTop: $(".single-post-content").offset().top}, 1000);
here is my javascript function
$(document).keydown(function(e){
if (e.keyCode === 39) {
var $next, $selected = $(".current");
$next = $selected.next('li').length ? $selected.next('li') : $first;
$selected.removeClass("current");
$next.addClass("current");
$('html, body').animate({scrollTop: $(".single-post-content").offset().top}, 1000);
showPage(parseInt($next.text()))
}
});
$(document).keydown(function(e){
if (e.keyCode === 37) {
var $prev, $selected = $(".current");
$prev = $selected.prev('li').length ? $selected.prev('li') : $last;
$selected.removeClass("current");
$prev.addClass("current");
$('html, body').animate({scrollTop: $(".single-post-content").offset().top}, 1000);
showPage(parseInt($prev.text()))
}
});
So, when I press left or right arrow, it animates and scrolls up to a specified div
as its supposed to be. But when I try scrolling down, windows shakes and not letting me scroll down. I am not able to figure the problem and make it smoother.
Update
here is my webpage