Jump to content

How to smooth scroll in Squarespace 7.1

Recommended Posts

Posted

Hi im trying to add an anchor link into my website and want it to smooth scroll to it. Unfortunately I cannot find a way to make it work with safari, it works with chrome

 

I have enabled smooth scroll in Design > Custom CSS

 

  • 2 weeks later...
  • Replies 2
  • Views 4.9k
  • Created
  • Last Reply
Posted

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.