Jump to content

How to smooth scroll in Squarespace 7.1

Recommended Posts

  • 2 weeks later...

Did you ever find a solution? I found the following. It works to smooth scroll in Safari and Chrome, but the problem is that it has bugs when on mobile. When you are vertical and you click a link in the dropdown hamburger menu, the menu gets stuck at the top of the site and the website seems to be frozen. 

SMOOTH SCOLL (works in both Chrome and Safari but gives bugs to safari mobile)

 

CSS injection

html {

scroll-behavior: smooth;

}

 

Header Injection 

<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>

 

Footer Injection

<!-- smooth scrolling -->

     <script type="text/javascript">

      $(function() {

        $('a[href*=#]:not([href=#])').click(function() {

          if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {

            var target = $(this.hash);

            target = target.length ? target : $('[name=' + this.hash.slice(1) +']');

            if (target.length) {

              $('html,body').animate({

                scrollTop: target.offset().top

              }, 1000);

              return false;

            }

          }

        });

      });

    </script>

Edited by misterdega
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.