[Resolved] General Smooth-Scroll Questions (I read the other posts, still lost!)

Home Forums Support General Smooth-Scroll Questions (I read the other posts, still lost!)

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1517952
    Martin

    Hello,

    I checked the forum but I still have problems with the smooth scroll function. I don’t have much coding skills.

    I use the generateblocks button on main page and want to add smooth-scroll. However when I add class=”smooth-scroll” before the href it breaks the button.

    Here is the buttom code. How do I make it scroll smoothly?

    <a class="gb-button gb-button-2c7497e5" href="#how-we-trade"><span class="button-text">How we actually trade</span><span class="gb-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="1em" height="1em" aria-hidden="true"><path d="M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z" fill="currentColor"></path></svg></span></a>

    First follow up question:
    All the scrolling on mobile seems smooth to me anyway? Is that a browser functionality? I actually unloaded the smooth-scroll js or css from the front page but nothing changed.

    Second follow up question:
    How exactly do I change the smooth scroll duration for the “back to top” button or in general for the whole domain? Where exactly in wordpress do I have to put that snippet here?

    add_filter( 'generate_smooth_scroll_duration', 'tu_smooth_scroll_duration' );
    function tu_smooth_scroll_duration() {
        return 800; // milliseconds
    }

    Third follow up question:
    I actually want the scroll from the “back to top” button to be very fast. However the scroll down to anchor on front page should be smooth and slow so that user can see where they are going to on front page.

    I really need some assistance here I suppose.

    #1518089
    Leo
    Staff
    Customer Support

    Hi there,

    Let’s tackle one thing at a time.

    How are you adding the class? Can you try adding it here?
    https://www.screencast.com/t/COcgVpRvxE

    #1518537
    Martin

    This works perfectly! Thank you very much.

    Now how do I apply this to the “back to top” button and where can I put that snippet for changing the scroll speed. I want a different scroll speed for “back to top button” and the “scroll down to anchor buttons”.

    #1518638
    David
    Staff
    Customer Support

    Hi there,

    Back to scroll speed uses this function:
    https://docs.generatepress.com/article/generate_back_to_top_scroll_speed/

    Heres the code you would use – just adjust the 400 to whatever you need.

    add_filter( 'generate_back_to_top_scroll_speed', 'tu_back_to_top_scroll_speed' );
    function tu_back_to_top_scroll_speed() {
        return 400; // milliseconds
    }

    And for Smooth Scroll – this article provide the code:

    https://docs.generatepress.com/article/smooth-scroll/#modifying-duration

    This document explains adding those two codes:

    https://docs.generatepress.com/article/adding-php/

    TLDR: If you have a child theme enabled, they would go in your Child Themes functions.php, if you do not have a child theme then install the Code Snippets plugin and add them to a new snippet.

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