JS anchors on mobile view

Hello! Previously your team had helped me with an issue regarding scrolling anchor menus on my page. The below code was added to my global JS.

However, for some reason now this code is crashing with some icon/image menus I have on the page in mobile view, link to page here. The 3 rows of icons you see below the main banner on the page now no longer work properly when I try to use them on mobile, I need to hold down and open the link in a new tab which was not the case before. Desktop view is fine, issue only on mobile.

Could you please take a look and advise if I need to make some adjustments, or what may have happened to affect the change? If I remove the below code, the mobile icon menu works fine (but of course the topbar menu no longer scrolls nicely.)

Thanks in advance!

 jQuery(document).ready(function ($){
$('a[href*="#"]:not(.x-portfolio-filter)').off( "click touchstart");
             $('a[href*="#"]:not(.x-portfolio-filter)').on('touchend click', function(e) {
                href        = $(this).attr('href');
                notComments = href.indexOf('#comments') === -1;
                if ( href !== '#' && notComments ) {
                  var theId = href.split('#').pop();
                  var $el   = $('#' + theId);
                  if ( $el.length > 0 ) {
                    e.preventDefault();

                    $('html, body').animate({
                                scrollTop:   $($el).offset().top -38
                            }, 450);
                      return false;
                  }
                }
              });

        });

(function($){
  $('a[href*="#"]').on('touchstart', function(e) {
    e.preventDefault();
  });

  $('a[href*="#"]').on('touchend click', function(e) {
    href        = $(this).attr('href');
    notComments = href.indexOf('#comments') === -1;
    if ( href !== '#' && notComments ) {
      var theId = href.split('#').pop();
      var $el   = $('#' + theId);
      if ( $el.length > 0 ) {
        e.preventDefault();
        animateOffset($el, 850, 'easeInOutExpo');
      }
    }
  });
})(jQuery);

Hello Cynth,

Thanks for writing in!

The JS code is a temporary fix for a previous bug. We highly recommend that you update to the latest version of Pro theme which is version 3.2.3 and then remove the JS code.

And by the way, please go to Pro > Theme Options > Header > Navbar and set the Navbar Top Height to 45 pixels because this is the actual height of your navbar.

To learn more how you can update your Pro theme, please check out this documentation:

We would love to know if this has worked for you. Thank you.

Hi @ruenel - yes, it worked. Thank you as always for your quick help.

You’re welcome. Glad we’re able to help.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.