Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1295572

    hi all,
    active submenu highlight for button style didn´t work for me. Could you please have a look.

    #1296059

    Hello team is anyone from support available for my query? I have purchased this theme. If you need my token details, please let me know.

    #1296177

    Hi,

    I’m not sure I understand what you are looking to achieve, could you try to explain the problem you are having a bit further please?

    Best regards,
    Rikard

    #1296229

    Hello Rikard,
    I would like the current status to be displayed in the submenu by changing the button colour. For this I have inserted the script as in the documentation. But it doesn’t work with a standard submenu either.

    Many greetings

    #1297063

    Hi,

    Please try adding following code to functions.php file of your child theme

    // a custom script
    // add current-menu-item class to active item
    function ava_custom_script_mod() {
        if ( wp_script_is( 'avia-default', 'registered' ) ) {
            wp_add_inline_script( 'avia-default', '
    		(function($) {
    			$(document).ready(function() {
    				const setActive = (entry) => {     
    					let item = $(<code>#top .av-subnav-menu a[href*=\'" + entry + "\']);
    		
    					if(!item.attr("href").includes(entry)) return;
    					
    					let list = item.parent("li");
    					let parent = list.parent("#menu-sub-menu");
    
    					if(list.is(".current-menu-item")) return;
    
    					parent.find("li").removeClass("current-menu-item");
    					list.addClass("current-menu-item");
    				}
    				
    				const createObserver = (entry) => {
    					let el = document.querySelector(entry);
    					
    					const observer = new IntersectionObserver(function(entries) {    
    						if(entries[0].isIntersecting === true) {
    							setActive(entry);
    						}
    						
    						}, { root: null, threshold:  [0.1] });
    
    					observer.observe(el);
    				}
    
    				const anchors = ["#top", "#barrierefrei", "#geberit", "#perma-trade"];
    
    				anchors.map(anchor => {
    					createObserver(anchor);
    				});
    			});
    		})(jQuery);
    	');
        }
     }
     add_action( 'wp_enqueue_scripts', 'ava_custom_script_mod', 9999);

    This is modified version of Ismael’s code here – https://kriesi.at/support/topic/enfold-gaming-demo-menu-functionality-on-sub-menu/

    Best regards,
    Yigit

    #1393909

    and that line:

    const anchors = ["#top", "#barrierefrei", "#geberit", "#perma-trade"];
    

    could not be generated automatically from the submenu itself?
    and the opening code tag has no closing one ?

    ______________

    i try to implement it as normal script – not via enqueue inline script.

    function observe_submenu() {
    ?>
    <script type="text/javascript">	
    window.addEventListener("DOMContentLoaded", function () { 
    (function($) {
    	const setActive = (entry) => {     
    		$("#top .av-subnav-menu a").parent("li").removeClass("current-menu-item");
    		let item = $('#top .av-subnav-menu .menu-item a[href*="' + entry + '"]');
    
    		if(!item.attr("href").includes(entry)) return;
    		
    		let list = item.parent("li");
    		let parent = list.parent("#menu-sub-menu");
    
    		if(list.is(".current-menu-item")) return;
    
    		parent.find("li").removeClass("current-menu-item");
    		list.addClass("current-menu-item");
    	}
    	
    	const createObserver = (entry) => {
    		let el = document.querySelector(entry);
    		
    		const observer = new IntersectionObserver(function(entries) {    
    			if(entries[0].isIntersecting === true) {
    				setActive(entry);
    			}
    			
    			}, { 
    				root: document, 
    				"rootMargin": "-5% 0% -15% 0%",
    				"threshold":  0.95
    			});
    
    		observer.observe(el);
    	}
    
    	const anchors = [];
    	$('#top .av-subnav-menu .menu-item a[href^="#"]').each(function(){
    	  anchors.push( $(this).attr('href') );
    	})
    
    	anchors.map(anchor => {
    		createObserver(anchor);
    	});
    })(jQuery);
    });
    </script>
    <?php
    }
    add_action( 'wp_footer', 'observe_submenu', 999 );

    ( maybe it is better for performance reasons to implement this only for the page where the submenu is located )

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.