[Resolved] Smooth-scroll does not work

Home Forums Support [Resolved] Smooth-scroll does not work

Home Forums Support Smooth-scroll does not work

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2028376
    Jacob

    Hi, I have activated smooth-scroll in Appearance>customize>general

    However, when I add an anchor and link to parts of my page with #. The smooth-scroll does not work. I have inserted “smooth-scroll” in Additional CSS class(es) for the anchors. But it is not smooth when I try.

    Why does it not work? Thanks

    #2028392
    Elvin
    Staff
    Customer Support

    Hi Jacob,

    Can you link us to the page in question? To inspect the page to have clues as to why smooth scroll doesn’t work.

    You can use the private information text field to provide details. πŸ˜€

    A wise man once said:
    "Have you cleared your cache?"

    #2028426
    Jacob

    Hey, I just tried to purge cache but it did not work anyway. Thanks.

    #2028565
    Elvin
    Staff
    Customer Support

    Ah I see,

    You use a custom element that isn’t included on the smoothscroll script yet.

    You’ll have to filter it in to include it.

    Here’s an example PHP snippet:

    add_filter( 'generate_smooth_scroll_elements', function($elements){
    $elements = array( '.smooth-scroll', 'li.smooth-scroll a', '.smooth-scroll li a' );
    return $elements;
    },20,1);

    A wise man once said:
    "Have you cleared your cache?"

    #2030245
    Jacob

    Thanks Elvin, it worked!
    But what do you mean with “custom elements” I just installed GP on my site. No customizations or nothing has been done. Is that something that came with the theme from the Site library that I imported?

    #2030263
    Ying
    Staff
    Customer Support

    Hi Jacob,

    By default, smooth scroll only works with a.smooth-scroll which means the smooth-scroll class needs to be added to a link element.

    As you can see, eg. you added smooth-scroll to the ol element, not a element:
    https://www.screencast.com/t/DxqHRBH9d

    So it won’t work by defualt.

    The snippet Elvin provided includes this kind of situation into the smooth-scroll function.

    Hope I made it clear πŸ™‚

    #2030275
    Jacob

    Hi Ying, Thanks for great service. You should update the video on your site where the guy explains how to use smooth-scroll without mentioning that a snoippet must be added to the code. Thanks for your help!

    #2030303
    Ying
    Staff
    Customer Support

    You are welcome Jacob!

    In that tutorial video we use the buttonsblock from Generateblocks which adds the class to the a element perfectely.

    So in most cases, we don’t need to use the snippet.

    In order not to confuse our users from the beginning, we prefer having the problem sorted in the support forum πŸ™‚

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