0

By default, Divi smooth-scrolls the page to sections from anchor links. I need the page to "jump" directly to the section instantly without any scroll animation.

Example: https://stanfordimapro.wpengine.com [Nav links at top]

I've added this code:

$('#nav-section a[href^="#"]').on('click',function (e) {
    e.preventDefault();
    var target = this.hash;
    var $trget = $(target);
    $('html, body').animate ({
        scrollTop: $trget
    }, 0, 'linear', function () {
        window.location.hash = target;
    }); 
});

That does make it instantly jump to the section but there's still a odd scroll up afterwards.

Ideally I'd like to remove the Divi scroll behavior entirely, but I can't find exactly where that is in the Divi theme files. It's likely related to "et_pb_smooth_scroll" in Divi/js/custom.js and/or Divi/js/scripts.js

Update: I found a few of these ( et_pb_smooth_scroll(i,a,800) ) in scripts.js and changed 800 to 0. That stopped the scroll animation, but I'm wondering how I can do that without editing theme files directly.

pseudojk
  • 67
  • 6
  • 2
    When you google this will be returned - If you use the DIVI theme and you want to disable the theme's smooth scrolling feature on your menu links, you can add the class et_smooth_scroll_disabled in your menu links items (“CSS Classes” optional field) – Snuffy Aug 29 '23 at 13:07
  • Thank you, I've googled a lot and didn't see that. Very helpful! Although the page still animates to anchors on page load :/ – pseudojk Aug 29 '23 at 13:32

0 Answers0