Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1122489

    i often set the Menu in this way that on ipad landscape the normal Menu is seen (not the hamburger)

    I have already found a solution for the normal first-level menu items with anchor sublevel items.

    function add_touch_fix(){
    ?>
    <script>
    (function($){	
    	const iPadMenuFix = function() {
            $(this).closest('.sub-menu').delay(1000).animate({opacity: 0,},300, function() {
                $(this).css('visibility', 'hidden');
            })
        };
    	$('#avia-menu').find('.menu-item-has-children:not(.menu-item-mega-parent).menu-item-top-level.current-menu-item .sub-menu a').on('touchend', iPadMenuFix); 
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_touch_fix');

    Now I have to find a solution how to make the Mega Menu close when you are on that parent-page and choose one of the anchor items.
    The Mega Menu included three different links to pages, with individual links to anchors on those pages. When I navigate there, the menu remains open.

    by the way : the hamburger did the trick. Hamburger closes when tapping on a different anchor on the opened parent page.

    you can simulate the behavior good on chrome on toggling device toolbar to see what i mean

    #1122975

    Hey Guenter,

    Maybe you can utilize or copy the megaDivHide function found in the js > avia-snippet-megamenu.js file to hide the mega menu container after tapping on an anchor.

    function megaDivHide (i)
    			{
    				if(delayCheck[i] == false)
    				{
    					megaItems.filter(':eq('+i+')').find(">a").removeClass('open-mega-a');
    
    					var listItem = megaItems.filter(':eq('+i+')'),
    						item = listItem.find("div:first");
    
    					item.stop().css('display','block').animate({opacity:0},300, function()
    					{
    						$(this).css('display','none');
    						listItem.css({overflow:'hidden'});
    						mega_open["check"+i] = false;
    					});
    				}
    			}
    

    Best regards,
    Ismael

    #1123133

    I can’t see the benefit of a copy in the child’s theme.
    This was my approach, unfortunately it doesn’t work that way.

    function add_megamenu_touch_fix(){
    ?>
    <script>
    (function($){	
    	$('#avia-menu .menu-item-mega-parent .avia_mega_div a').on('touchstart', function () {
    		setTimeout(function(){ 
    
    			$(this).closest('.menu-item-mega-parent').find('>a').removeClass('open-mega-a');
    			$(this).closest('.menu-item-mega-parent').css('overflow' , 'hidden');
    			$(this).closest('.avia_mega_div').css({
    				'opacity' : '0',
    				'display': 'none',
    			});
    		}, 500);	
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_megamenu_touch_fix');

    It can’t be the first time that a touch-friendly Mega Div solution has been demanded.
    A Mega Div with Anchor submenu items is not unusual, is it? So please find a solution on that issue

    #1124624

    Hi,

    Thank you for the update.

    This script might work.

    function add_megamenu_touch_fix(){
    ?>
    <script>
    (function($){	
    	$('#avia-menu .menu-item-mega-parent .avia_mega_div a').on('touchstart', function () {
    		setTimeout(function(){ 
    			$(this).closest('.menu-item-mega-parent').find('> a').trigger('mouseleave');
    		}, 500);	
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_megamenu_touch_fix');

    That should simulate a mouseleave event in the parent menu item, which triggers the megaDivHide function, and thus close the mega menu container.

    Best regards,
    Ismael

    #1124706

    Thanks Ismael – does not work in this way.

    this is my solution for now – but i thought it was a bit oversized.
    But that works on my test page – see private Content:

    function add_megamenu_touch_fix(){
    ?>
    <script>
    (function($){	
    	var megaParent = $('.menu-item-mega-parent');
    	megaParent.on('click touch', function() {
            megaParent.trigger('mouseenter');
    		megaParent.find('>a').addClass('open-mega-a');
        });	
    	$('.avia_mega_div a').on('click touch', function() {
    		setTimeout(function(){  
    			megaParent.trigger('mouseleave');
    			megaParent.removeClass('current-menu-item');
    			megaParent.find('>a').removeClass('open-mega-a');
    		}, 900);
        });	
        $('.avia_mega_div').on('click touch', function(e) {
            e.stopPropagation();
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_megamenu_touch_fix');
    #1124755

    Hi,

    Danke fur das Update, und fur die Lösung teilen.

    Funktioniert das Skript ohne diese Zeile?

    megaParent.trigger('mouseleave');
    

    Best regards,
    Ismael

    #1124815

    no – this line has to be present. ( tested on a real device – not on simulated ipad )
    The chrome simulation is good for a quick check – but in the end you still have to test it on the real device.

    if you have the call of new pages, everything is not necessary anyway, it is just only needed if you want to navigate to a sublevel anchor link.

    #1124932

    Hey!

    Thank you for the info.

    It seems to be working properly on Edge. The mega menu container disappears on click after half a second. If it works on IE or Edge, then it will also work on older iOS devices, based on experience.

    Regards,
    Ismael

    #1124978

    Thanks – yes i changed the timing to 500ms.
    but i think this should be an implemented default behavior – like on hamburger the content must be accessible after click.
    A closing button could be an alternative but from usability point of view the touchend is more intuitive to use.

    Can be closed – if you like

    #1125343

    Hi,

    Thanks. We’ll forward the thread to @Guenter for consideration. Closing.

    Best regards,
    Ismael

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Ipad behaviour at Mega Menu’ is closed to new replies.