Search code examples
javascriptwordpressanchorsmooth-scrollingdivi-theme

slow down jump to anchor in divi theme


I'm using Divi Theme, and after a lot of testing I didn't find how can I slow down the scrolling animation when jumping to an anchor. This is a page of my website with a lot of anchors https://anekitalia.com/come-raggiungerci/ clicking on any of the blurb images, you will scroll down to the related section. There is a custom.js file that I think is related to this, inside there is a function

et_page_load_scroll_to_anchor()

I edited this

var speed    = (distance > 4000) ? 1600 : 800;

to this

var speed    = 200;

but nothing is changed. I know that this theme is using SmoothScroll for websites v1.2.1 for scrolling animations, but editing smoothscroll,js settings only changes the way I'm scrolling with the mouse, not the anchor links.. Any starting point for this? many thanks


Solution

  • This is my working solution, but just for the menu-anchor points (header). It will not work for blurbs with a href's pointing to anchor elements. Strange...

    For desktop:

    You have to set the third value of the function et_pb_smooth_scroll to 0 in the divi's Custom.js in line 1182 -> et_pb_smooth_scroll (Target, false, 0)

    For mobile:

    In line 1295 the same -> et_pb_smooth_scroll ($ target, top_section, 0)