Tagged: Burger Menu, mobile menu
-
AuthorPosts
-
May 28, 2018 at 12:22 pm #963108
Hello kriesi team, first of all I want to thank you for this excellent theme and your top-notch support. I am using Enfold for years now and love it :-)
I recently updated a website from a very old Enfold version (I think 3.5.3) to the newest version and encountered two problems with the burger menu /mobile menu.
First problem: Close button doesn’t show up because of problems with avia.js in the child-theme
In the old version I had made changes to functions.php and avia.js in the child theme to move the featured Image below post title, date, etc.
The changes I made:child-theme/function.php:
// Replace avia.js function change_aviajs() { wp_dequeue_script( 'avia-default' ); wp_enqueue_script( 'avia-default-child', get_stylesheet_directory_uri().'/js/avia.js', array('jquery'), 2, true ); } add_action( 'wp_enqueue_scripts', 'change_aviajs', 100 );
As shown in: https://kriesi.at/support/topic/modifying-jsavia-js-for-a-child-theme/
child-theme/js/avia.js:
jQuery('article.post').each(function(){ jQuery(this).find('.entry-content-header').after(jQuery(this).find('.big-preview').detach()); })
As shown in: https://kriesi.at/support/topic/move-featured-image-below-post-title-date-etc/
In order to update the website, I now copied the new avia.js from the new Enfold version into the child-theme. After that I added again the code snippet at the end oft the document as I did in the old version. However doing this now leads to problems with the burger menu. If I click on the menu, the icon won’t get replaced with a close button. Also the secondary menu is displayed on top of the mobile menu.
Only if I delete my avia.js file from the child theme, the burger menu works fine again.
So I guess the code snippet has to be updated, too. But I am not a developer :( Could you please help me with that?Second problem: Search and close icons are displayed on top ob menu links
If I click on a menu item with a lot of subitems naturally I have to scroll the menu. But when I scroll, only the menu items scroll. The search icon and the close icon remain where they are and overlap with the menu items. How can I fix this?
May 30, 2018 at 2:30 pm #964276Hey zarlekin,
Thank you for using Enfold.
A lot has changed since that version. Please remove the avia.js file from your child theme and then use this code in the functions.php file instead.
add_action('wp_footer', 'ava_custom_script'); function ava_custom_script(){ ?> <script type="text/javascript"> (function($) { $('article.post').each(function(){ $(this).find('.entry-content-header').after($(this).find('.big-preview').detach()); }); })(jQuery); </script> <?php }
Best regards,
IsmaelJune 5, 2018 at 11:32 am #967159Hello Ismael,
thank you for your support!It wasn’t until you replied that I saw in the new Enfold demo, there isn’t even a need for the fix anymore, as the new Enfold already sets the preview image below the title. It was in some older version of the theme that it was set above.
So sorry, for the support request, which wasn’t necessary after all.Yet I still need help with the second issue regarding the mobile menu.
If I click on a menu item with a lot of subitems I have to scroll the menu. But when I scroll, only the menu items scroll. The search icon and the close icon remain where they are and overlap with the menu items. How can I make the Icons scroll with the menu items?
Best regards,
zarlekinJune 7, 2018 at 11:41 pm #969855Hi,
Thanks for the update. This script might help with the mobile menu issue.
add_action('wp_footer', 'ava_custom_script_mobile_scroll'); function ava_custom_script_mobile_scroll(){ ?> <script type="text/javascript"> (function($) { var lastY; $('body').on( 'mousewheel DOMMouseScroll touchmove', '.av-burger-overlay-scroll', function (e) { var scroll = $(this).scrollTop(); var delta = e.originalEvent.deltaY; var currentY = e.type != 'touchmove' ? 0 : e.originalEvent.touches[0].clientY; if(e.type != 'touchmove') { lastY = 0; } if(delta < 0 || currentY > lastY) { $('.responsive #top .av-main-nav .menu-item-avia-special').css('opacity', 1); } if(delta > 0 || currentY < lastY) { $('.responsive #top .av-main-nav .menu-item-avia-special').css('opacity', 0); } lastY = currentY; }); })(jQuery); </script> <?php }
Best regards,
IsmaelJune 8, 2018 at 12:41 am #969879Hello Ismael,
do I have to insert this code snippet into functions.php in the child theme?
Because I did that and nothing changed.
I also cleared the cache of WP Super Cache not knowing if this could be an issue, but still nothing changed.Best regards,
zarlekinJune 8, 2018 at 1:58 pm #970085By the way, I have this mobile-menu-overlapping-behaviour on all the websites (4) using enfold. And as I can’t believe this to be deliberately designed this way, I suppose it’s a theme bug. Therefor I would like to request this fix to be implemented into the next enfold update.
June 11, 2018 at 7:26 am #970945Hi,
Thanks for the update. We adjusted the code a bit. Please try it again and make sure that you’re not looking a cached version of the the page. The search and x button should be hidden when the user scroll down and display back on scroll up.
Best regards,
IsmaelJune 11, 2018 at 6:22 pm #971330Hi Ismael,
I inserted the new code. But nothing happens except I get an an Error in the Chrome developer console telling me Uncaught ReferenceError: jQuery is not defined linking to this line of your code})(jQuery);
This bug fix is the only thing I need to finish the project and I am a litte bit short on time here. If it is possible for you to look into this soon, I would be very greatful!
Could you also tell me if this fix will be implemented in the next release? Because depending on it I would need to insert the code into all the other websites or just wait for the next theme update.
Best regards,
)|( ZIGGYJune 12, 2018 at 2:51 am #971476Hi,
Thanks for the update. That same code works on our own installation. Please copy it directly from the forum, not from your email. I would like to access the site but the login credentials above aren’t working. Please provide another account.
Best regards,
IsmaelJune 12, 2018 at 11:58 am #971645Hi Ismael,
I didn’t copy the code from the mail, I copied the updated code showing above.
You can see exactly this code, when you visit the site and look into the developer tools and klick on the error message.I tried the sftp credentials I gave you and they worked just fine for me. (Maybe you used FTP instead of SFTP?)
Yet as requested I created a new user.Best regards,
zarlekinJune 13, 2018 at 3:44 am #972018Hi,
I see. My bad. I used the credentials to access the WP dashboard. Did you happen to enable the options in the Performance panel? Please disable those temporarily and provide the WP login details. We would like to test the script further.
Best regards,
IsmaelJune 13, 2018 at 12:43 pm #972261Hi Ismael,
previously I had deactivated
-
CSS file merging and compression
Javascript file merging and compression
Disabling of template builder elementsand emptied my cache. With no results.
Now I took another look at the performance settings and saw that I also had checked “Load jQuery in your footer”.
By deactivating the option “Load jQuery in your footer” the error message disappears and the script works.But this poses a new problem.
As this mobile-menu-overlapping-behaviour isn’t a bug caused by compatibility problems with other plugins, but is a theme bug you can even see in your own demo (https://kriesi.at/themes/enfold-2017/) I assume that you will want to fix this bug in the next theme update.
However, you can’t do it in a way that forces the user to not check the option to load jQuery in the footer.
If the theme Enfold by itself causes errors when checking the option to load jQuery in the footer, the option is void.
You will have to find a way to fix the menu bug in your theme without causing problems in this option.So I have two questions now:
-
1. Is there another way to fix the problem via child theme, that works with the theme option to load jQuery in the footer?
2. Will you have this bug fixed in the new Update? (Because as I said, I have other Websites using Enfold and if the new version has it fixed I would just wait for it to get out. Otherwise I would have to implement this script into every site and deactivate the performance option.)Best regards,
zarlekinJune 13, 2018 at 3:29 pm #972321Hi Ismael,
sorry, I thought the mobile menu worked fine now, but I had only taken a quick look by resizing the browser window and scrolling down.
Now that I took my mobile phone (Samsung Galaxy S3) and really testet it on the device it doesn’t work as expected at all.
When I touch the screen and scroll down, the icons disappear, but the moment I take my finger away and do this action again to scroll further down, the icons show up/flicker for a brief moment. And they also show up and overlap the menu item the moment I begin to scroll up.In older versions of Enfold the whole mobile menu worked great. It worked similar to the mobile menu on this website using another theme: https://elisabeth-karsten.de/ – And in terms of best usability I think that’s the behaviour you should also expect.
Best regards,
zarlekinJune 18, 2018 at 3:40 am #974065Hi,
Thanks for the update.
We created a new script. Let us know if it works better than the previous one.
functions.php file:
add_action('wp_footer', 'ava_custom_script_mobile_menu'); function ava_custom_script_mobile_menu() { ?> <script> (function($) { $('.av-burger-menu-main').on('click', function() { var overlay = $('.av-burger-overlay'); var active = $('html').hasClass('av-burger-overlay-active'); var clone = overlay.find('.av-burger-menu-main'); var wrap = $(this).parents('.av-main-nav-wrap').find('.av-burger-overlay').find('.av-burger-overlay-inner'); console.log(clone.length == 0 && active); if (clone.length == 0 && active) { setTimeout($.proxy(function() { $(this).prependTo(wrap); }, this), 500); } else { clone.insertAfter('#menu-item-search'); } }) })(jQuery); </script> <?php }
Style.css file:
#top .av-burger-overlay .av-burger-menu-main { position: absolute; right: 26px; top: 80px; z-index: 1000; } #top #wrap_all .av-burger-overlay .av-burger-menu-main a { border: 0; } .av-burger-overlay-active #top #menu-item-search { display: none; }
Best regards,
IsmaelJune 18, 2018 at 2:29 pm #974278Hello Ismael,
thank you for your support.1. I looked into funktions.php and saw that you didn’t replace the old script with this new one shown above but added this new script below the old one.
Is the old script necessary for the new one to work, or did you forget to delete it?
Because I testet the mobile menu with and without the old script in functions.php and the menu worked the same way.
Therefor I deleted the old script.
Was I right to do this? Or did I miss something?2. I compared the new script in functions.php with the script you posted here and saw a little difference.
In funktions.php your script had a line showing
}, this), 200);
In the script you posted above it shows
}, this), 500);
I don’t know what that is, but I changed this line it in functions.php to match with the script you posted here.
Was I right to do this? Or did I miss something?—-
The new script is a big improvement. It’s not perfect, as the close button jumps and there is no way to position it to match the exact position of the menu icon, but it’s something I can live with. So thank you for that.
Yet, the problem with the Performance Options “Load jQuery in your footer” remains.
If I check the option “Load jQuery in your footer” the script doesn’t work properly and I get the error message:
Uncaught ReferenceError: jQuery is not defined
at (index):481Referring to the line:
})(jQuery);
As you didn’t answer to my questions regarding this issue, I have to repeat them:
1. Is there a way to implement the script via child theme, that works with the theme performance option to load jQuery in the footer?
2. Will you have this mobile menu bug fixed in the new Update?
As I said, I can’t believe this mobile-menu-overlapping-behaviour to be deliberately designed this way, I see it as a theme bug. And I assume that you will fix this bug in the next theme update in a way compatible with the option to load jQuery in the footer.
Best regards,
zarlekinJune 19, 2018 at 2:18 am #974568Hi,
Thanks for the update.
1.) I kept the first script just in case we want to go back in that direction. It’s actually disabled because I commented it out.
2.) The burger overlay is dynamically added to the page when the mobile menu button is clicked so the timeout is necessary to delay (200ms or 500ms) the script execution. The lower, the better. I set it to 50ms.
3.) I adjusted the action priority so it enqueues the custom script after the jQuery library loads in the footer.
4.) I’m not sure if it’s going to be included in the core but I’ll forward it to the team.
Best regards,
IsmaelJune 19, 2018 at 12:39 pm #974750Hello Ismael,
thank you very much for the script and the information! I will keep an eye on the Enfold changelog.The Script now works without any errors :-)
Here the end version for other users who may need it:
add_action('wp_footer', 'ava_custom_script_mobile_menu', 9999); function ava_custom_script_mobile_menu() { ?> <script> (function($) { $('.av-burger-menu-main').on('click', function() { var overlay = $('.av-burger-overlay'); var active = $('html').hasClass('av-burger-overlay-active'); var clone = overlay.find('.av-burger-menu-main'); var wrap = $(this).parents('.av-main-nav-wrap').find('.av-burger-overlay').find('.av-burger-overlay-inner'); if (clone.length == 0 && active) { setTimeout($.proxy(function() { $(this).prependTo(wrap); }, this), 50); } else { clone.insertAfter('#menu-item-search'); } }) })(jQuery); </script> <?php }
And this is the CSS customization I needed for my website:
.noLightbox.social_bookmarks.icon_count_2 { display: none !important; } .avia-menu.av_menu_icon_beside { padding-right: 0px; border: none; } #top .av-burger-overlay .av-burger-menu-main { position: absolute; right: 7.5%; top: 77px; z-index: 1000; } #top #wrap_all .av-burger-overlay .av-burger-menu-main a { border: 0; } .av-burger-overlay-active #top #menu-item-search { display: none; }
Best regards,
zarlekinJune 20, 2018 at 5:14 am #975076 -
AuthorPosts
- The topic ‘Problems with burger menu /mobile menu’ is closed to new replies.