When I scroll some list during heavy render (for example 50 Highchart items) I have scroll freeze (and that is fine). The problem is after all charts are loaded there is a "jump" of a scroll (that was frozen) to the end of the list (up or bottom, depends on scroll direction). Is there a way to continue scrolling from the scroll position, say 30%, after all of the heavy renderings is completed?
I have tried to add styling for a list element that removes scrolling like "overflow: hidden" before the start of heavy render, then add "overflow: scroll" back to the element after all rendering is over. But that doesn't help, still experience "jumps".
What I have tried looks like this:
// inner-container is a class name of all scrollable elements on the page that I need to control
// content-wrapper is a list inside of the container, position for that I want to be consistent after a render (without "jumps")
const elements = document.getElementsByClassName("inner-container");
window.elCoords = [];
for (let el of elements) {
el.style.overflowY = 'hidden';
el.style.pointerEvents = 'none';
const coords = el.getElementsByClassName('content-wrapper')[0].getBoundingClientRect();
window.elCoords.push(coords.y)
}
After render is over, I remove "overflow: hidden" styling so that elements are able to be scrollable again and set scroll position as it was before heavy render start:
const elements = document.getElementsByClassName("inner-container");
let index = 0;
for (let el of elements) {
const inner = el.getElementsByClassName('content-wrapper')[0];
inner.scrollTo({
top: window.elCoords[index],
behavior: 'smooth'
});
index += 1;
el.style.overflowY = 'scroll';
el.style.pointerEvents = 'all';
}
Actual: after the heavy render is over, scroll position jumps to the end/start of the scrollable container
Expected: after the heavy render is over, scroll should continue from the position it was before heavy render start