Plugin Elementor: How to adjust the offset during automatic scrolling?

If a necessary offset value is missing when automatically scrolling to the anchor point, it can be added with the following code in the functions.php file.

add_action( 'wp_footer', function() {
  if ( ! defined( 'ELEMENTOR_VERSION' ) ) {
    return;
  }
  ?>
  <script>
    jQuery( function( $ ) {
      // Add space for Elementor Menu Anchor link
      $( window ).on( 'elementor/frontend/init', function() {
        elementorFrontend.hooks.addFilter( 'frontend/handlers/menu_anchor/scroll_top_distance', function( scrollTop ) {
          return scrollTop - 30;
        } );
      } );
    } );
  </script>
  <?php
} );
Without cookies
This website does not use cookies or tracking. More information can be found in the privacy policy.