I want to do a sharp upward scrolling.
window.scrollTo(0, 0)
scrolls smoothly, how do I scroll up without animation?
You can use document.documentElement.scrollTop = 0; for Chrome, Firefox, IE, Opera and Edge Browsers and
document.body.scrollTop = 0 for Safari Browser
You pass an object instead of position, like this:
element.scrollTo({
top: 0,
left: 0,
behavior: 'instant'
});
behavior is default selected by browser, in chrome it uses smooth, where en webkit browser, default is instant.
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo
scroll-behavior: smooth;
You can use this for smoothly.
if you don't want to be smoothly, use this:
scroll-behavior: auto;