Disable Pro Theme smooth scrolling on anchors

Hey,

I would like to disable Pros default smooth scrolling to #id anchors on some pages. Is that possible?

I found this request Page Scrolling When Clicking Anchor Tags but wasn’t able to locate the mentioned function anymore.

Thanks!

Hey Paul,

Thank you for reaching out to us. As already mentioned in the thread you shared that there’s no way to change or stop this behavior out of the box. The only way is to edit the theme files directly which is not recommended at all as this could break the entire theme’s functionality.

Another reason why it’s not recommended to edit the theme files directly is that your direct changes in the theme will be overwritten when the theme update is released.

Thank you for understanding!

Hey Nabeel,

Thanks for your reply! I totally understand that fiddling with core files is not a good approach here. And we certainly don’t want to disable the function in general. In most places, it gives the site a good looking, valuable feeling.
However, we are having some pretty long pages right now, and new ones will be getting even longer - as we are creating an online learning tool for medical staff. For overall clarity it has been evaluated that having most content concerning one topic on the same page, with a clickable table of contents on top / sticky, is the best way to use, read and learn it. Being able to disable the smooth scrolling just on those extra-long pages, would be awesome. Because scrolling is taking multiple seconds on some pages - and users are getting frustrated waiting and watching the page scroll. In studying, every minute that you can squeeze, counts - in medical use cases even more!
We really love Pro otherwise, and don’t want to leave the battlefield here, just because of that scrolling behaviour.

So I’m thinking, wouldn’t it be possible that we just overwrite/empty the JS-Function that is handling the smooth scroll with i.e. Post-JS on just those pages/posts? That would be such a great courtesy!

Hi Paul,

Like my colleague says, there is no such option to disable the Smooth Scroll for specific pages. Still, you can try the following code into your child theme functions.php.

function wpdocs_dequeue_script() 
{  
    $page_id=17;// you can add any page id where you want this to be disabled
    if(get_the_ID()==$page_id)
    {
        wp_dequeue_script( 'tco-smooth-scroll-site-js' );
    }
}
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );

Please remember that the above code will work if copied as it is and don’t conflict with any existing style.
Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle.
We really do not provide support for custom codes that means we can’t fix it in case it conflicts with something on your site nor will we enhance it.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.