[Resolved] Enable Smooth Scroll for all anchor links

Home Forums Support [Resolved] Enable Smooth Scroll for all anchor links

Home Forums Support Enable Smooth Scroll for all anchor links

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #617185
    Junior Gong

    Is there any way to enable Smooth Scroll for all anchor links on whole site?

    #617192
    David
    Staff
    Customer Support

    The current method is by adding the smooth-scroll class to the <a> tag. How many anchor links do you have?

    #617196
    Junior Gong

    Example: I am using TOC plugin which generates anchor links automatically.
    I cannot add any classes to the anchor links generated.

    Therefore my solution is to enable smooth scroll for all links

    #617205
    David
    Staff
    Customer Support

    Can you share a link to the site, so we can see the mark-up that TOC is creating, might be a way to filter that and add the smooth-scrool class or use one of its classes instead…… maybe πŸ˜‰

    #617222
    Junior Gong

    Is there any way to share the link privately? My client does not want to have links in wordpress related public forums etc..

    #617237
    David
    Staff
    Customer Support

    Yes, Edit your your original post up the top and there is a Site URL field that only us admins can see

    #617250
    Junior Gong

    done!

    #617384
    David
    Staff
    Customer Support

    I am going to check with Tom if there is a way that the smooth-scroll script can work on all <a> tags within the content. Whilst looking for a decent content filter that could add the class as an alternative.

    #617605
    Tom
    Lead Developer
    Lead Developer

    I’ve just added a new filter to GPP 1.7-beta.2: generate_smooth_scroll_elements

    That will allow us to initiate smooth scroll on other element classes πŸ™‚

    #617609
    Junior Gong

    That is awesome!

    Is that gonna work even when an element does not have any class? E.g. just by pointing to an element like in CSS files?

    #617612
    Tom
    Lead Developer
    Lead Developer

    We should be able to target the links as long as they’re wrapped in some sort of container with a class or ID πŸ™‚

    #618497
    Junior Gong

    Thx guys, I appreciate the support

    #760969
    Mathias

    Awsome! Thank you for sharing this. Smooth-scroll works pretty nice.

    #761014
    David
    Staff
    Customer Support

    Hi Mathias, glad you found it of use. This article may be of interest:

    https://docs.generatepress.com/article/smooth-scroll/

    #826087
    YSK

    “generate_smooth_scroll_elements” is a nice filter. I often use this filter.

    However, using this filter in IE 11, turning on “Back to Top Button” turns out strange behavior.

    When you push the “Back to Top Button”, you will rattle at the beginning and the end.

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