My goto top button dont go to anchor

Hey!

i have found out that i have conflict between codes:

i have received this code from themeco staff:

this code causing the goto top button to go to anchor of the main menu

// Custom Scroll Top Anchor
// =============================================================================

if ( ! function_exists( 'x_scroll_top_anchor' ) ) :
  function x_scroll_top_anchor() {

    if ( x_get_option( 'x_footer_scroll_top_display' ) == '1' ) : ?>

      <a class="x-scroll-top custom-scroll-to-top <?php echo x_get_option( 'x_footer_scroll_top_position' ); ?> fade" title="<?php esc_attr_e( 'Back to Top', '__x__' ); ?>">
        <i class="x-icon-angle-up" data-x-icon="&#xf106;"></i>
      </a>

      <script>

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

        var windowObj            = $(window);
        var body                 = $('body');
        var bodyOffsetBottom     = windowObj.scrollBottom();             // 1
        var bodyHeightAdjustment = body.height() - bodyOffsetBottom;     // 2
        var bodyHeightAdjusted   = body.height() - bodyHeightAdjustment; // 3
        var scrollTopAnchor      = $('.x-scroll-top');

        function sizingUpdate(){
          var bodyOffsetTop = windowObj.scrollTop();
          if ( bodyOffsetTop > ( bodyHeightAdjusted * <?php echo x_get_option( 'x_footer_scroll_top_display_unit' ) / 2000; ?> ) ) {
            scrollTopAnchor.addClass('in');
          } else {
            scrollTopAnchor.removeClass('in');
          }
        }

        windowObj.bind('scroll', sizingUpdate).resize(sizingUpdate);
        sizingUpdate();

        scrollTopAnchor.click(function(){
          var vtop = 0;
          if ( $('.x-slider-container.above').length > 0 ) {
   vtop = $('.x-slider-container.above').height();
}

          $('html, body').animate({ scrollTop: vtop }, 2000, 'xEaseInOutExpo');
          return false;
        });

      });

      </script>

    <?php endif;

  }
  add_action( 'x_after_site_end', 'x_scroll_top_anchor' );
endif;

however when i added this code:

$(document).scroll(function() {
  var y = $(this).scrollTop();
  if (y > 1200) {
    $('#sfm-mob-navbar').fadeIn();
  } else {
    $('#sfm-mob-navbar').fadeOut();
  }
});

the go to top button does not go to the same anchor it should have been.
every time i involve #sfm-mob-navbar it does it. (this is the id of the superfly)

can i set the go to top button to go to the navbar anchor please help

Hi @angelofgod,

Thanks for reaching out.

Maybe it’s how you’re adding it, and it breaks the entire javascript affecting the entire scroll functionality. How did you add it and where? Please provide the complete code (after you added the new code).

Thanks!

1 Like

i just gave up on the jq code so i deleted it so there will be no problem.

Hi Adam,

Regretfully, we cannot provide support for third-party scripts as our support policy in the sidebar states due to the fact that there is simply no way to account for all of the potential variables at play when using another developer’s script. Because of this, any questions you have regarding setup, integration, or troubleshooting any piece of functionality that is not native to X will need to be directed to the original developer.

Thank you for your understanding.

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