Hey there, I have a page where users can click on a home and it will bring up a pop up with that persons profile. Only problem I’m having is that when a user closes that pop up and clicks on another one it will stay at the position of where the user left the last one i.e middle of the pop up.
Does anyone know how I can make it so every time that pop up is clicked it will scroll to the top of of the pop up?
Thanks mate! All sorted now, the issue was coming from the run javascript code, it was not resetting the scrolling position when the pop up was opened and closed. To solve it:
Amended code for when pop up is opened:
savedScrollY = window.scrollY;
let x = document.getElementById(“TA”);
x.style.position = “fixed”;
x.style.top = -savedScrollY + “px”;
// Reset the scroll position to the top
document.getElementById(“TC”).scrollTop = 0;
Amended code for when pop up is closed:
let x = document.getElementById(“TA”);
x.style.position = “absolute”;
x.style.top = “”;
window.scrollBy(0, savedScrollY);
document.getElementById(“TC”).scrollTop = 0; // This ensures the scroll position is reset when the pop-up is closed