I am converting my code to use the DOM API directly instead of using jQuery, there is a scenario which has the functionality of scrolling. I am unable to convert to a version directly using the DOM API:
jQuery code:
function scrollToResult() {
var $height1 = $('.class1').outerHeight();
$('body, html').stop().animate({
scrollTop : $('.class2').offset().top - $height1;
}, 200);
}
Plain JavaScript code:
function scrollToResult() {
var $height1 =document.querySelector('.class1').offsetHeight;
//error
document.querySelector('body, html').stop
}
I know stop
is not any method of JavaScript. How to proceed here?