Liquid, JavaScript, themes, sales channels
Hey,
Lately I've been having problems with my scroll to top button not stopping at a specific section.
I've added the button through a section app which works just fine, but I cant seem to figure out how to make it land in the proper area. It keeps going straight back to the top.
I've done some edits in the actual section folder of this button and this is the current code that I'm using:
<script> (function () { window.addEventListener('DOMContentLoaded', () => { const scrollBtn01 = document.querySelector('.btn-scroll-01'); const targetSection = document.querySelector('#shopify-section-15d62b59-d08d-4ba2-823b-06fe5c10472f'); const btnVisibility = () => { if (window.scrollY > 400) { scrollBtn01.classList.add('scroll-01--show'); } else { scrollBtn01.classList.remove('scroll-01--show'); } }; document.addEventListener('scroll', () => { btnVisibility(); }); scrollBtn01.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth', }); }); }); })(); </script>
If anyone can help me finally solve this, i'd greatly appreciate it. Thanks!
URL : jasaoslaj.com
User | RANK |
---|---|
38 | |
28 | |
13 | |
13 | |
9 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023