Pro Single-Page nav no longer working and JS errors

I recently upgraded a site over to latest version of Pro and have lost the single page navigation functionality (the scrolling effect from ID to ID tags) on the site for desktop and mobile.

I have cleared all cache on the server and in the browser after the upgrade. I have also the same results on multiple browsers.

There are now JS errors that are popping up in console when clicking on the menu links as well.

Uncaught TypeError: n.easing[this.easing] is not a function
at init.run (jquery.js?ver=1.12.4&nocache=1:4)
at i (jquery.js?ver=1.12.4&nocache=1:4)
at Function.n.fx.timer (jquery.js?ver=1.12.4&nocache=1:4)
at qb (jquery.js?ver=1.12.4&nocache=1:4)
at HTMLHtmlElement.g (jquery.js?ver=1.12.4&nocache=1:4)
at Function.dequeue (jquery.js?ver=1.12.4&nocache=1:3)
at HTMLHtmlElement.<anonymous> (jquery.js?ver=1.12.4&nocache=1:3)
at Function.each (jquery.js?ver=1.12.4&nocache=1:2)
at a.fn.init.each (jquery.js?ver=1.12.4&nocache=1:2)
at a.fn.init.queue (jquery.js?ver=1.12.4&nocache=1:3)

Hi,

It was your js script that was causing the issue.

I removed it and scroll is working fine now.

This is the code that was removed.

jQuery(document).ready(function($) {
 $('a[href*="#"]').off('touchstart click');
  var $body                = $('body');
  var bodyHeight           = $body.outerHeight();
  var adminbarHeight       = $('#wpadminbar').outerHeight();
  var navbarFixedTopHeight = $('.x-navbar-fixed-top-active .x-navbar').outerHeight() + 112;
  var locHref              = location.href;
  var locHashIndex         = locHref.indexOf('#');
  var locHash              = locHref.substr(locHashIndex);

  //
  // Calculate the offset height for various elements and remove it from
  // the element's top offset so that fixed elements don't cover it up.
  //

  function animateOffset( element, ms, easing ) {
    $('html, body').animate({
      scrollTop: $(element).offset().top - adminbarHeight - navbarFixedTopHeight + 1
    }, ms, easing);
  }

  //
  // Page load offset (if necessary).
  //

  $(window).load(function() {
    if ( locHashIndex !== -1 && $(locHash).length ) {
      animateOffset(locHash, 1, 'linear');
    }
  });

  //
  // Scroll trigger.
  //

  $('a[href*="#"]').on('touchstart 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');
      }
    }
  });

  //
  // Initialize scrollspy.
  //

  if ( $body.hasClass('x-one-page-navigation-active') ) {

    $body.scrollspy({
      target : '.x-nav-wrap.desktop',
      offset : adminbarHeight + navbarFixedTopHeight
    });
  }
});

Kindly check in your end.

Thanks

@paul.r

Yes, I saw that code too. It must have been added somehow in the update? I didn’t add that JS in myself. I assumed it needed to be there.

I have verified and all seems to be functioning again.

Hi There,

Glad this is now functioning again. Though to clarify, an update doesn’t add custom JS. All codes are added on the theme.

Well I’m not entirely certain how it got there then, because I didn’t manually add that, and there is nobody else that could have. It is the very similar code that is in your /pro/framework/js/dist/site/x-body.js file starting at line 1827 too.

We’re not sure also why it was added to your site but Pro does not have one page navigation support yet.

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