Home Forums WoodMart support forum header overlaps anker link section Reply To: header overlaps anker link section

#572473

Artem Temos
Keymaster

Try to add the following PHP code snippet to the child theme functions.php file to fix this


if ( ! function_exists( 'woodmart_enqueue_custom_scripts' ) ) {
	/**
	 * Add a script that calculates the height of the Sticked Header and subtracts it from the "scrollTop" value in the Elementor widget "Menu_anchor".
	 */
	function woodmart_enqueue_custom_scripts() {
		ob_start();
		?>
		jQuery(document).ready(function() {
			if (window.elementorFrontend) {
			elementorFrontend.hooks.addFilter( 'frontend/handlers/menu_anchor/scroll_top_distance', function(scrollTop) {
				var stickyElementsHeight = 0;
				var stickyRows           = jQuery('.whb-sticky-row');
				
				if (0 === stickyRows.length || ! stickyRows.parents('.whb-header').hasClass('whb-sticked')) {
					return scrollTop;
				}

				stickyRows.each(function() {
					stickyElementsHeight += jQuery(this).height();
				});

				return scrollTop - stickyElementsHeight;
			});
		}
		});
		<?php
		$script = ob_get_clean();

		wp_add_inline_script( 'woodmart-theme', $script );
	}
	add_action( 'wp_enqueue_scripts', 'woodmart_enqueue_custom_scripts', 40 );
}