I have a problem when I scroll up (else
part of code).
Scroll first goes to the top of the page and then returns to the element. It should only go to the element .showPoints
.
Where am I wrong in code?
if (value == "Show more") {
showPoints.show("slow");
showText.text("Show less");
setTimeout(() => {
$('html,body').animate({scrollTop: showText.offset().top - $(window).height() + showText.parent().height()}, 'fast');
}, 1000)
} else {
let count = 0
$("html, body").animate({ scrollTop: 0 }, "slow");
showPoints.slice(3).hide("slow");
$('html,body').animate({scrollTop: showText.offset().top}, 0, () => {
$('html,body').animate({scrollTop: showText.offset().top - $(window).height() + showText.parent().height()}, 0);
})
showText.text("Show more");
}