I'm trying to scroll to a certain block on page load like this (needs to work in IE 11):
getScrollbaleContainer().scrollTop =
block.getBoundingClientRect().top +
(window.pageYOffset || document.documentElement.scrollTop);
But Chromium browsers and Firefox scroll to that point with a duration. Is there a way to make it scroll instantly?
You can do this by setting and unsetting the scroll-behavior css property:
const container = getPageScrollContainer();
container.style.scrollBehavior = 'auto';
container.scrollTop =
block.getBoundingClientRect().top +
(window.pageYOffset || document.documentElement.scrollTop);
container.style.scrollBehavior = '';