@matteoveglia Hi, sorry I took a while to respond.
So just to be clear, the code does take me to the top of the page which is great, but the problem occurs if I take the following steps:
-
scroll down
-
then click a link to a different page within my site
-
then hit the back button
In that scenario, it shouldn’t take me to the top of the page. It should remember my scroll position and adjust for the unnecessary down-scrolling. But it just takes me back to the top every time as if the variables I set are always just 0,0.
You can actually just achieve this with a much shorter script:
import wixWindow from 'wix-window';
$w.onReady(async () => {
if(wixWindow.formFactor === "Mobile"){
wixWindow.scrollTo(0, 0, {"scrollAnimation": false})
}
});
Anyway, this isn’t actually a big deal for my site in particular. I’m just a perfectionist, and I also wanted to ensure that I’d be able to use anchors down the road if I wanted. I’m just gonna count my losses and stick with this shorter code, but if you manage to figure it out, please do let me know! And thanks for offering to help.