Making the Divi Header Shrink Further Down the Page
Shrink Header Further Down – Updated
Here is the jQuery code to make the header stay large, until the user has scrolled down by a certain number of pixels. In the code below this "offset" is set to 500 pixels, but you can easily change that to your desired scroll down amount.
The feature can be found on the Divi Booster settings page at "Header > Main Header > Don't shrink the header until user scrolls down by … px", and can be enabled simply by entering your scroll down amount in pixels, checking the box beside the feature, and saving the settings.
Shrink Header Further Down – The Old Way
It turns out that Divi uses the jQuery Waypoints plugin to trigger the shrinking effect. Basically the main header is registered as a "waypoint" and when the use scrolls past it a function is triggered which adds (or removes) the CSS class which defines the sticky header layout.
Normally the waypoint triggers when the top of the element is level with the top of the viewing area. However, the waypoint definition accepts an "offset" parameter which allows you to specify that the trigger happens when the top of the element is a certain number of pixels from the top of the viewport. A negative offset will cause the trigger to happen when the element has already scrolled past the top of the viewport by the specified amount.
It was possible to add a custom offset in the Divi Theme's custom.js file which achieved the desired effect. But was it possible to achieve the affect without modifying the theme files – i.e. with something we could place in a child theme?
As far as I can tell, the Waypoint API doesn't offer a way for modifying existing waypoints. The best I could do was to remove all waypoints from the header element (as far as I can tell it's the only waypoint), and create a new waypoint that works in the same way, but uses our custom waypoint.
Here's the jQuery to achieve this (just change the -500 to your required offset in pixels):
The code waits until 1 second after the dom is loaded, to give Divi time to create the waypoint in the first place.
Want get more out of Divi?
Hundreds of new features for Divi
in one easy-to-use plugin