javascript - Make mmenu.js open on widescreen and can also be closed -


i'm making menu made mmenu.js open when opened on widescreen , closed on medium mobile. want, on widescreen, able close toggle button.

right now, can close while on mobile.

here's fiddle

        $(function() {             var $menu = $('nav#menu'),                 $html = $('html, body');              $menu.mmenu({                 extensions: ["widescreen", "theme-dark"]             });              var $anchor = false;             $menu.find( 'li > a' ).on(                 'click',                 function( e )                 {                     $anchor = $(this);                 }             );              var api = $menu.data( 'mmenu' );             api.bind( 'closed',                 function()                 {                     if ( $anchor )                     {                         var href = $anchor.attr( 'href' );                         $anchor = false;                          //  if clicked link linked anchor, scroll page anchor                          if ( href.slice( 0, 1 ) == '#' )                         {                             $html.animate({                                 scrolltop: $( href ).offset().top                             });                          }                     }                 }             );         }); 

you create fake button mmenu button.

<a href="#fake-bttn"></a> 

then add jquery toggle class on #my-mmenu container , .mm-page container.

$("#fake-bttn").click(function(){     $("my-mmenu").toggleclass("close");     $("div.mm-page").toggleclass("close");   }); 

then add following widesceen.css mmenu.

.mm-slideout {   -webkit-transition: width 1s; /* safari */   transition: width 1s; } .mm-page.mm-slideout.close {   width: 100% !important;   margin-left: 0% !important; } .mm-menu.mm-widescreen {   -webkit-transition: width 1s; /* safari */   transition: width 1s;   min-width: 0% !important; } .mm-menu.mm-widescreen.close {   min-width: 0% !important;   width: 0% !important; } 

i had add float right .mm-page container in widescreen.css

.mm-page { float:right } 

then hide button based on same media query value have widescreen.css.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -