Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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
We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024