Tagged: Fullwidth sub menu
-
AuthorPosts
-
September 11, 2020 at 11:21 pm #1245232
hello, unfortunately the full width menu in combination with the one-page menu highlight stoped working. it reacts very flaky and slows down the page scroll behavior a lot. it seems to be related to the jquery script in the function.php.
i am running the latest wp 5.5.1 and the latest enfold version 4.7.6.3
any help is very much appreciated!
best
chris- This topic was modified 4 years, 2 months ago by cg808.
September 13, 2020 at 5:47 am #1245471Hi Chris,
Sorry for the problem. Could you post a link to where we can see the results you are getting please? Also include admin login details in private in case we should need to access the backend of your site.
Best regards,
RikardSeptember 13, 2020 at 9:02 am #1245483good morning rikard, thank you for getting back to me.
September 15, 2020 at 9:25 am #1245957ping :-) any updates? best chris
September 17, 2020 at 1:47 pm #1246530ping :-)
September 18, 2020 at 11:58 am #1246754Hi cg808,
Can you please make a screencast of the issue? It seems to be working fine on my end.
Best regards,
VictoriaSeptember 18, 2020 at 2:14 pm #1246827Hi Victoria!
Thanks for getting back. The position indicator now works just fine on one page, but still not on the other pages.
I’ve attached the link to where you can download the screencasts.Also, there is an incredible lack of responsiveness when trying to scroll the page with the non-working menu-highlight. Upon closer inspection you can see that the class
active-menu-item
does appear to get assigned to the correct menu-element, but gets auto-removed immediately (and so on and so forth for several times per scroll; maybe causing the performance issues).Since it’s now working on the one page we made content & layout changes to, I suspect it’s an issue with one or more Avia elements – but couldn’t find any meaningful difference between these pages.
Let me know if you need any more info.Thanks in advance!
September 20, 2020 at 12:57 pm #1247096Hi cg808,
Best regards,
VictoriaSeptember 21, 2020 at 9:06 pm #1247478This reply has been marked as private.September 24, 2020 at 3:58 pm #1248211Hi Victoria,
our problem still exist :-(
We checked the code, removed code but still the same.
Could you please check again wit your developers.
Thank you!
Best ChrisSeptember 27, 2020 at 3:20 pm #1248788September 27, 2020 at 4:18 pm #1248808Hi,
Sorry for the late reply, and thanks for the login, so I copied your two pages to my localhost to test, and applied the css & javascript from the documentation and observed the menu “active-item” class being added & removed constantly.
This seems to lead to a performance issue, as you pointed out. So I researched this and found a better working script, which I adjusted to work with the sub-menu and css.
So the css is the same:/* Active menu styles */ #top .submenu-onepage .active-menu-item, #top .submenu-onepage .active-menu-item a { background: #000 !important; color: #FFF !important; } #top .submenu-onepage .av-subnav-menu > li > a { border-left-style: none !important; border-left-width: 0px !important; }
Try adding this script to the end of your functions.php file in Appearance > Editor:
function custom_sub_menu_highlighting_script(){ ?> <script> (function($){ // Cache selectors var lastId, topMenu = $("#sub_menu1"), topMenuHeight = topMenu.outerHeight()+15, // All list items menuItems = topMenu.find("a"), // Anchors corresponding to menu items scrollItems = menuItems.map(function(){ var item = $($(this).attr("href")); if (item.length) { return item; } }); // Bind click handler to menu items // so we can get a fancy scroll animation menuItems.click(function(e){ var href = $(this).attr("href"), offsetTop = href === "#" ? 0 : $(href).offset().top-topMenuHeight+1; $('html, body').stop().animate({ scrollTop: offsetTop }, 300); e.preventDefault(); }); // Bind to scroll $(window).scroll(function(){ // Get container scroll position var fromTop = $(this).scrollTop()+topMenuHeight; // Get id of current scroll item var cur = scrollItems.map(function(){ if ($(this).offset().top < fromTop) return this; }); // Get the id of the current element cur = cur[cur.length-1]; var id = cur && cur.length ? cur[0].id : ""; if (lastId !== id) { lastId = id; // Set/remove active class menuItems .parent().removeClass("active-menu-item") .end().filter("[href='#"+id+"']").parent().addClass("active-menu-item"); } }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_sub_menu_highlighting_script');
In my tests this works much better and the scroll to anchor action from clicking the menu items also is much smoother, so please give this a try and if you still find a performance issue try disabling your other scripts and plugins to check for a conflict.
In the script above it looks for the ID sub_menu1 for the sub-menu here:topMenu = $("#sub_menu1")
This is the default ID for the first sub-menu on each page, so this should be fine, but if you use a custom ID for the sub-menu in the future please ensure to change this too.
I also noticed that in your child theme it looks like the other script was added twice, once in the functions.php and in menu-highlight.js, after you remove the other script please ensure the new script is only added once. I’m sure that you would, I just wanted to point that out 😉Best regards,
MikeSeptember 27, 2020 at 10:02 pm #1248878Hi Mike,
that script works perfect! As you said a lot better that the first script.
There are no more delays or performance issues. The page is snappy and fast.Thank you very much for your support and help!
Best
Chrisp.s. you can close this topic…
September 28, 2020 at 1:56 am #1248893Hi,
Glad we were able to help, we will close this now. Thank you for using Enfold.For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads in the Enfold forum and we will gladly try to help you :)Best regards,
Mike -
AuthorPosts
- The topic ‘fullwidth-sub-menu one-page menu highlight stoped working :-(’ is closed to new replies.