Shopify themes, liquid, logos, and UX
Anyone knows how to return to the same scroll position in dawn theme? I saw a fix for turbo theme which didn't apply for dawn.
Hi @oudelegance
Add this script to your theme.liquid file or base.js:
window.addEventListener("beforeunload", () => {
sessionStorage.setItem("scrollPosition", window.scrollY);
});
window.addEventListener("load", () => {
const scrollPosition = sessionStorage.getItem("scrollPosition");
if (scrollPosition) {
window.scrollTo(0, scrollPosition);
}
});
How it works:
Hi @oudelegance I was facing the same issue, and the code shared by @kirillatwally worked perfectly for me. You should give it a try.
Thank you 😊😊😊😊😊😊😊😊😊
Hi @oudelegance
I hope you are well. You can follow our instructions below:
Step 1: Shopify admin > Online store > Edit code: https://prnt.sc/M4p-gua99Uf4
Step 2: Search for "theme.liquid" file: https://prnt.sc/b6xveIKe-Rh2
Step 3: Open the file search for </body> tag and add the following code above </body> tag.
<script>
window.addEventListener("beforeunload", () => {
sessionStorage.setItem("scrollPosition", window.scrollY);
});
window.addEventListener("load", () => {
const scrollPosition = sessionStorage.getItem("scrollPosition");
if (scrollPosition) {
window.scrollTo(0, scrollPosition);
}
});
</script>
Here is the code for Step 3:
Please let me know if it works. Thank you!
Best,
Daisy - Avada Support Team.
Hi, thank you for your response.
I couldn't search for </body> it doesn't exist like that in theme.liquid.
So I pasted it here (see screenshot). Now does it need to be indented. This did not work for me. By the way, I am having this issue on mobile phone. When you click on a product from one of the collections, then click back, it takes you to the top of the homepage, not where you clicked on the product in the first place.
Hi @oudelegance
From the screenshot you shared, could you please scroll down to the bottom to find </body tag?
Best,
Daisy - Avada Support Team.
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024