Site logo

Archived topic

Mobile Header + jonsuh.com/hamburgers code isnt working

11 replies · Started by liorsade8 on October 26, 2018

Viewing posts 1–12 of 12

hello,
I'm using a Mobile Header in this site, and also the hamburger code of: https://jonsuh.com/hamburgers/
this hamburger code is working great with non Mobile header on all of my sites.
but i need it to work also in the mobile header option.
please help,
thanks.

i'm using this code in the child theme editor:

add_action( 'generate_inside_mobile_menu', 'tu_hamburger_icon' );
function tu_hamburger_icon() {
?>

<span class="hamburger-label">תפריט</span>

<?php
}

and using this code in the wp_head in elements:
<link href="http://t-talk.s178.upress.link/wp-content/themes/generatepress_child/dist/hamburgers.css" rel="stylesheet">

and using this script code in the wp_footer in elements:
<script>
var hamburger = document.querySelector(".hamburger"),
menuToggle = document.querySelector( '.menu-toggle' ),
menuItems = document.querySelectorAll( 'nav ul a' );

menuToggle.addEventListener("click", function() {
hamburger.classList.toggle("is-active");
} );

for ( var i = 0; i < menuItems.length; i++ ) {
menuItems[i].addEventListener( 'click', function( e ) {
var closest_nav = this.closest( 'nav' );
if ( closest_nav.classList.contains( 'toggled' ) || htmlEl.classList.contains( 'slide-opened' ) ) {
var url = this.getAttribute( 'href' );
var hash = url.split('#')[1];

// Open the sub-menu if the link has no destination
if ( hash ) {
e.preventDefault();
hamburger.classList.toggle("is-active");
}
}
}, false );
}
</script>

hi
i changed the code in the editor to this:
generate_inside_mobile_header_menu
and it's working partly...

but i still have some issues while downsizing - from desktop to tablet to mobile...
please help,

and also the theme's hamburger is showing...
if i put the regular code i have:

.menu-toggle .mobile-menu,
.menu-toggle:before {
display: none;
}

it's destroying the entire navigation...

hi dave,
no.
try to put the page breakpoint more than 768px till 1180px
and you will see that it's not appearing.
please help
thanks

great man!
it's working!
once again GP guys, u are awesome!

hi... no... sorry...
the menu is disappearing once clicked...
check it please

hi
it's because of this code:

.main-navigation:not(.slideout-navigation) .main-nav > ul {
display: none;
}

i removed it and it's working.
is it ok?

Looks good to me :)

great

This archived topic is closed to new replies.