- This topic has 9 replies, 4 voices, and was last updated 3 years, 10 months ago by David.
-
AuthorPosts
-
June 29, 2020 at 4:05 am #1345287Elia
Hi there,
We are using the gutenberg anchor links. And we want to make them smooth. What is the best way for that?
We enable smooth scroll on the options:
https://docs.generatepress.com/article/smooth-scroll/But it doesn’t work out of the box
Many thanks
June 29, 2020 at 5:53 am #1345409DavidStaffCustomer SupportHi there,
smooth scroll works when the link element has the
smooth-scroll
class – see here for reference:https://docs.generatepress.com/article/smooth-scroll/#regular-links
But you can add the PHP Snippet provided here so it applies to any
<a>
element:https://docs.generatepress.com/article/generate_smooth_scroll_elements/
June 29, 2020 at 6:11 am #1345429EliaThanks a lot, David! Top class as usual
June 29, 2020 at 6:30 am #1345451DavidStaffCustomer Supportglad to be of help
June 29, 2020 at 11:00 am #1346034JuanHi!
And sorry for adding another comment here, but I actually happen to have the same problem:I have added the “smooth-scroll” class in some anchor links that I already had, example:
<a href="#Indice">Volver al Índice</a>
Editing the message after checking that the html of the anchor text is tranform into the anchor text itself: As I read in https://docs.generatepress.com/article/smooth-scroll/#regular-links I just added ” class=”smooth-scroll” ” in between de “a” and the “href”.
But it is not working… The link works, but not the smooth scroll
Also, and I don´t know if I have done it well, I have added the following code in the “functions.php” (I´m using a child theme and I read I could do this).
add_filter( 'generate_smooth_scroll_elements', function( $elements ) { $elements[] = 'a[href*="#"]'; return $elements; } );
But it is not working either… I´m using the lazy load functionality that comes with the plugin “smush image”, I don´t know if thats related but I have seen you were talking about it in anothe thread in this forum. XD
Thanks in advance for your help!
Juan
June 29, 2020 at 2:27 pm #1346235TomLead DeveloperLead DeveloperHi there,
Any chance you can link us to your page so we can take a look?
Let me know 🙂
June 29, 2020 at 3:00 pm #1346265JuanHi Tom,
Of course!
The site is https://quever-grecia.info/ and the anchor text I mentioned is repeated a few times in the homepage.Let me know if I can provide you with more info
June 30, 2020 at 1:00 am #1346581DavidStaffCustomer SupportHi there,
is the Smooth Scroll option enabled in Customizer > General?
And can you disable your litespeed cache so we can see whats happening
June 30, 2020 at 3:50 am #1346740JuanHi David!
I´m very sorry, the smooth-scroll option was NOT enabled where you said. I didn´t even know it existed there and it looks like I missed the most basic point… Thanks a lot for your help and now it´s working as it should. 🙂
Regards
Juan
June 30, 2020 at 5:31 am #1346839DavidStaffCustomer SupportGlad to hear that 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.