-
AuthorPosts
-
April 20, 2021 at 3:15 pm #1295572
hi all,
active submenu highlight for button style didn´t work for me. Could you please have a look.April 22, 2021 at 2:17 pm #1296059Hello team is anyone from support available for my query? I have purchased this theme. If you need my token details, please let me know.
April 23, 2021 at 5:25 am #1296177Hi,
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,
RikardApril 23, 2021 at 8:08 am #1296229Hello 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
April 27, 2021 at 6:46 pm #1297063Hi,
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,
YigitJanuary 18, 2023 at 2:08 pm #1393909and 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 )
-
AuthorPosts
- You must be logged in to reply to this topic.