Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1397823

    Dear Kriesi-Team,
    is it possible to add more classes to the Fullwidth submenu element (https://kriesi.at/documentation/enfold/menu/#dots-menu)?

    Especially when the user scrolls through the current section?

    Thanks for your help!

    Best regards,
    Jasper

    #1398003

    Hey Jasper_1,

    Thank you for the inquiry.

    You can try the following script to add an extra class to the active menu item or once the corresponding section is visible in the viewport.

    // https://kriesi.at/support/topic/full-width-submenu-4/#post-1297063
    // https://kriesi.at/support/topic/enfold-gaming-demo-menu-functionality-on-sub-menu/#post-1284777

    Best regards,
    Ismael

    #1398037

    Hi Ismael,
    thanks for your quick response!

    I’ve tried the script from the first link above, replaced it with my id names but it’s not working.

    Could you please help me find the reason?

    Best regards,
    Jasper

    #1398168

    Hi,

    We may need to login to the site. Please provide an admin account in the private field.

    Best regards,
    Ismael

    #1398200
    This reply has been marked as private.
    #1398288

    Hi,

    Thank you for the inquiry.

    We modified the code a bit. All you need to do is add the anchors in this line.

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

    Best regards,
    Ismael

    #1398320

    Hi and thanks, but it’s not working.

    Maybe it’s in this line:
    let parent = list.parent(“#menu-sub-menu”);

    I have no element with that id. So i tried the id of the ul of the submenu (it’s the parent, right?).
    But it’s still not working.

    Do you have any ideas?

    Best regards!

    #1398481

    Hi,
    Thanks for the link to your site but I don’t see a Fullwidth submenu element on your homepage, is it on a different page?
    I see that you linked to the Dots Menu documentation I checked a few of your pages and didn’t find this?

    Best regards,
    Mike

    #1398611
    This reply has been marked as private.
    #1398725

    Hi,

    Thank you for the update.

    It was not working because the selector for the “social media” section is incorrect. We modified the code in the functions.php file a bit.

    
    // 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) => {     
    					$("#top .av-subnav-menu a").parent("li").removeClass("current-menu-item");
    					let item = $("#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 = ["#home", "#klassiker", "#ice", "#spritz", "#free", "#social-media"];
    
    				anchors.map(anchor => {
    					createObserver(anchor);
    				});
    			});
    		})(jQuery);
    	');
        }
     }
     add_action( 'wp_enqueue_scripts', 'ava_custom_script_mod', 9999);
    

    We also added this css code in the child theme’s style.css file to differentiate the active item from the rest of the menu items.

    .av-subnav-menu .current-menu-item {
        color: red;
        background: red;
    }
    

    You can adjust it as needed.

    Best regards,
    Ismael

    #1398791

    Thank you very much!

    The Kriesi Support Team helped me a lot in the last couple of days.
    Awesome job!

    #1398812

    Hi,
    Glad Ismael could help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Dots Menu (Fullwidth submenu element) with current class’ is closed to new replies.