Archived topic
Smooth Scroll not getting applied
12 replies · Started by Drew on July 25, 2018
I have the smooth scroll option activated but it doesn't appear to be applying to links with the smooth-scroll class assigned.
Example page in website URL field below.
All four of the buttons inside the top section have the class assigned: <p style="text-align: center;"><a href="#whoWeAre">Who We Are</a> <a href="#historicBuilding">Our Historic Building</a> <a href="#staffBoard">Staff & Board</a> <a href="#financials">Financials</a></p>
But selecting the buttons still humps down without smooth scroll effect.
However, the back to top button smooth scroll works fine.
Suggestions?
Hi there,
You need to add the smooth-scroll class to your links:
<a href="#whoWeAre" class="smooth-scroll">Who We Are</a>
Hey Tom, they do have the class (I think it got stripped out when I pasted previously). Here is is again:
<p style="text-align: center;"><a class="button smooth-scroll" href="#whoWeAre">Who We Are</a>
Is there a second step to get it to work with the button class?
Hmm, there's a javascript error happening.
Can you try deactivating your other plugins just to rule out some sort of conflict?
Blerg, I didn't get the email notice for the follow up on this one (do you guys use a transactional provider or the default WP mail function?). Let me see about that and circle back.
Drew
Okay, this is fun; it wasn't a specific plugin, rather a specific custom functions snippet.
Do you recall the exchange we had several months back about inserting SevernSpark's ubermenu into the theme via custom snippet, that's the culprit.
if ( ! function_exists( 'generate_navigation_position' ) ) {
function generate_navigation_position() {
if( function_exists( 'ubermenu' ) ){
ubermenu( 'main' , array( 'theme_location' => 'primary' ) );
}
}
}
Any thoughts on how to sidestep that?
FYI, I did the deactivate process at a staging site: http://townhall.staging.wpengine.com/about - that snippet is deactivated at the moment and you can see the smooth scroll is working as expected.
Drew
I'm still seeing the javascript error. Did you re-add the function? I'm not seeing a menu anywhere?
It makes sense the menu wouldn't appear since the snippet is deactivated on that staging install.
I'm not sure what else the js error would be related to since I deactivated the other plugs but deactivating that snippet resolved the smooth scroll functionality. The only js error I see is realted to the smooth scroll function, is that the one you're seeing: https://www.screencast.com/t/S6GhoVhWzP
Otherwise, all other plugins (except GP Premium, Lightweight Grid Columns, and simple CSS) are disabled.
CORRECTION: I did clear out object caching and I that seems to have made a difference. That js error is gone so the issue still seems to have something to do with that ubermenu insert snippet. Any idea as to why it would conflict with the smoothscroll?
Any chance you can try out GPP 1.7?: https://generatepress.com/gp-premium-1-7/
For you, anything :)
That's done on the staging site, I reactivated the insert ubermenu snippet, and the smooth scroll appears to be working on the /about page again. Yay!
I checked it across a few different browsers and all seems to be working as expected too. What changed in the RC release?
We re-worked things within the smooth scroll script in 1.7.
It looks like the function you were using was breaking the document.body variable in javascript, which is really strange.
Glad it's working now :)
Cool, is that RC version of 1.7b stable enough for me to push out on the client's live site without worry about any ancillary issues?
Yes, it's very stable. The official version will be coming out this week :)