''Scroll To Top'' Button not landing on a specific section

''Scroll To Top'' Button not landing on a specific section

jasa11
Explorer
87 0 11

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

Replies 0 (0)