Pro, Header, Scroll to, Offset

Hello guys,

I got this JS from your support last year:

/* Scroll Offset */
(function($){
  $('#menu-header-kurse.x-menu .x-anchor-menu-item').off().on('click touchstart', function( e ){
    e.preventDefault();
    var section = $(this).attr('href').split("#").slice(-1)[0];
    console.log(section);

    if ( section || section != '' ) {

      var xbar = $('.x-bar').outerHeight();
      var yloc = $('#' + section + '').offset().top - 114;
      console.log('x bar: ' + xbar);
      console.log($('#' + section + '').offset().top);
      
      setTimeout( function() {
      $('html, body').stop().animate({
          scrollTop: yloc
        }, 850, 'linear');
      }, 250 );

    }
  });
})(jQuery);

Now, with Pro 2, this code does not work anymore. I think its because we have no ID. How to get this code work again? Can you help me with this?

Thanks and Best,

Robert

Hi Robert,

Hey There,

Would you mind providing us with login credentials so we can take a closer look? Please provide following information:

Set it as Secure Note

  • Link to your site
  • WordPress Admin username / password
    -Specific Page
  • How to replicate the problem.

All the best!

Hello Joao,

sure, secure note is coming…

Best,

Robert

Hi there,

Please change your code to this

/* Scroll Offset */
(function($){
  $('.e251-7 .e251-9 .x-anchor-menu-item').off().on('click touchstart', function( e ){
    e.preventDefault();
    var section = $(this).attr('href').split("#").slice(-1)[0];
    console.log(section);

    if ( section || section != '' ) {

      var xbar = $('.x-bar').outerHeight();
      var yloc = $('#' + section + '').offset().top - 63;
      console.log('x bar: ' + xbar);
      console.log($('#' + section + '').offset().top);
      
      setTimeout( function() {
      $('html, body').stop().animate({
          scrollTop: yloc
        }, 850, 'linear');
      }, 250 );

    }
  });
})(jQuery);

Thanks!

Hello Rad,

thanks but this does not work :frowning:

Best,

Robert

Hi Robert,

It seem to work when I checked.

See Video - https://www.screencast.com/t/20yiHxOeV

Try to clear browser cache and check again.

Thanks

Oh yes, thank you. I had to clear my caching plugin manually… my bad, sorry :frowning:

You’re most welcome!

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