Ubermenu ScrollTo issue

Greetings,

I’ve been having continued trouble with getting submenu items to scroll to the correct destination/offset. The issue primarily happens when coming from a different page, which the auto scroll function can’t seem to match up with the specified offset. My goal is to have items scroll to the same offsets whether the page is the current item or not. Thanks in advance!

Here is our previous thread link. https://theme.co/apex/forum/t/ubermenu-3-scrolling-issues/16906?u=agency Sorry, but the reply function wasn’t displaying for me so I created a new topic for follow up.

Hi,

I would like to login and check but it looks like you have change your site login url.

I tried /wp-admin and wp-login.php but none of these works.

Can you provide us your login url in Secure Note

Thanks

Hi,
You can access thru this link: www.velocityagency.com/veladmin

Thanks.

Hello There,

Regretfully the credentials given in the other thread is no longer working for us.

Meanwhile, to resolve your issue, please add this JS code in the Theme Options > Global JS (http://prntscr.com/evswzb)

(function($){
  var tabnav = location.href.split("#").slice(-1)[0];

  if ( tabnav || tabnav != '' ) {    
    
   $( document ).ready ( function() {

    console.log(tabnav);

    var navbar = $('.x-masthead').outerHeight();

    setTimeout ( function() { //Let's trigger the scroll animation just after the content is displayed.
   
    var yloc = $('#' + tabnav + '"]').offset().top - 156;

    $('html, body').animate({
        scrollTop: yloc
    }, 850, 'easeInOutExpo');

   }, 750 );

   } );

  }
  
})(jQuery);

Hope this helps.

Hi,

Thank you for the help, but this JS didn’t work.

The username and password that we gave you it still working, please try again.

Thanks.

Hi again,

Can you please try out the following code:

jQuery(document).ready(function($) {

  var $body                = $('body');
  var bodyHeight           = $body.outerHeight();
  var adminbarHeight       = $('#wpadminbar').outerHeight();
  var navbarFixedTopHeight = $('.x-masthead').outerHeight();
  var locHref              = location.href;
  var locHashIndex         = locHref.indexOf('#');
  var locHash              = locHref.substr(locHashIndex);
  var dragging             = false;
  
  $body.on('touchmove', function() {
      dragging = true;
  } );
  
  $body.on('touchstart', function() {
      dragging = false;
  } );


  //
  // 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*="#"]').off('touchend click').bind('touchend click', function(e) {
      console.log($('.hm1.x-bar-fixed').outerHeight());
    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();
        
        if (dragging) {
            return;
        }
        
        animateOffset($el, 850, 'xEaseInOutExpo');
      }
    }
  });
});

Don’t forget to clear your browser’s cache after adding the code. Let us know how this goes!

That did the trick!! Thanks!

You’re most welcome!

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