Jump to content

tecdwl

Member
  • Posts

    1
  • Joined

  • Last visited

Everything posted by tecdwl

  1. Not an answer per se. Would it be possible to update the script provided by SQS to incorporate an offset? Any attempt using additional js is messing with the functionality for mobile. The aim is to have a working anchor link navigation for desktop and mobile, given that the website is a one-pager with a fixed header (different height for mobile and different sizes of browser windows). the solution below works for a website without a fixed header: The following code is an attempt to enable the offset independently: <script> $(document).ready(function(){ var Anchors = document.getElementsByTagName("a"); for (var i = 0; i < Anchors.length ; i++) { Anchors[i].addEventListener("click", function (event) { event.preventDefault(); if (confirm('Are you sure?')) { //window.location = this.hash; var target_offset = $(this.hash).offset() ? $(this.hash).offset().top : 0; var custom_offset = 210; $('html, body').animate({scrollTop:target_offset - custom_offset}, 500); } }, false); } }); </script> Putting the IDs (#) in different places to counterbalance the offset is an absolute last resort. A coded solution is much preferred.
×
×
  • 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.