[Resolved] Smooth Scroll – Stop scrolling to top of page when the side menu is opened.

Home Forums Support [Resolved] Smooth Scroll – Stop scrolling to top of page when the side menu is opened.

Home Forums Support Smooth Scroll – Stop scrolling to top of page when the side menu is opened.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1283673
    Scott

    Hello,

    I use GP’s sticky, slide out menu.

    I recently enabled smooth scroll. And targeted it on my anchor links using the code in your documentation:

    add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
      $elements[] = 'a[href*="#"]';
      
      return $elements;
    } );

    The scroll works great on the anchor links!

    But, now every time I open the slideout menu it scrolls me to the top of the page. I’d rather just the default behaviour applied, so opening the slide out menu does not bring you back to the top of the page.

    Is there a fix?

    Thank you!

    #1283861
    David
    Staff
    Customer Support

    Hi there,

    depending on where the smooth-scroll links are you can be more specific e.g this only affects links inside the entry content:

    add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
      $elements[] = '.entry-content a[href*="#"]';
      
      return $elements;
    } ); 

    Let us know.

    #1293207
    Scott

    Amazing thank you!

    #1293258
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.