I'm trying to scroll to element smoothly,but can't find a way to control the scroll time without jquery.
I found two ways to scroll to element smoothly:
- document.getElementById(targetElementId).scrollIntoView({behavior:'smooth'})
2.$('html, body').animate({scrollTop: $(selector).offset().top},1000)
The second way uses jquery and easy to control scroll time.
But I wonder if there a way in native javascript to control the scroll time.
Thank you