Archived topic
Enable Smooth Scroll for all anchor links
23 replies · Started by Junior Gong on July 6, 2018
Is there any way to enable Smooth Scroll for all anchor links on whole site?
The current method is by adding the smooth-scroll class to the <a> tag. How many anchor links do you have?
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
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 ;)
Is there any way to share the link privately? My client does not want to have links in wordpress related public forums etc..
Yes, Edit your your original post up the top and there is a Site URL field that only us admins can see
done!
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.
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 :)
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?
We should be able to target the links as long as they're wrapped in some sort of container with a class or ID :)
Thx guys, I appreciate the support
Awsome! Thank you for sharing this. Smooth-scroll works pretty nice.
Hi Mathias, glad you found it of use. This article may be of interest:
"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.