javascript - Conflict between setTimeout and clicking outside the element detection -


I have the code below it slides a mobile menu, in which only 500 MB of clicks to prevent excessive clicks There is a timeout function to allow, it also closes when the user clicks outside the menu area. These two functions are conflicting with each other at the bottom of the script. This happens only on a sensitive site in a special case - If I click outside the first page load menu area on when the mobile menu is still hidden, and then shrink the browser window, the menu appears as already declining in

  TogglerWidth = jQuery ('# Mobile-Menu Toggler') CSS ('minimum-width'). // Get width of Toggler // left slide function slideLeft = function () {var menuWidth = jQuery ('# mainmenu-mobile') width ();; // Get the width of the main menu jQuery ('# Mobile-Menu-Tuggler'). Amymate ({width: menuWidth}, // what are we animate of 500 property, // how fast are we animating 'swing', // seamlessly the type of work () {// callback }); JQuery ('#menmenu-mobile'). Chetan ({right: "0px"}, // what are we animating property 500, // how fast are we animating 'swing', // seamless function () {// Callback}); } // slide right function var slurred = function () {var menuWidth = jQuery ('# mainmenu-mobile'). Width (); // Get the width of the main menu jQuery ('# mobile-menu-toggler'). Animate ({width: togglerWidth}, // what are we animating property 500, // how fast are we swinging 'swing', // seamless work type () {// callback }); JQuery ('#menmenu-mobile'). Emamate ({right: -mainwidth}, // We're animating from 500, how fast are we 'swinging', // type of simplicity () / callback}); } Activate = function () {// 'active menu' class jQuery ('# mainmenu-mobile, # mobile-menu' Toggler ') switch to addClass (' active menu '); } Var deactivate = function () {// switch switch to 'inactive menu' class jQuery ('# mainmenu-mobile, # mobile-menu-toggler') RemoveClass ('active-menu'). AddClass ('inactive-menu'); ("# Mobile-menu-toggle"). ('Click'); JQuery (this) .toggleClass ('disable-menu' ("#may-menu-wrap"); ("disabled", true); if (jQuery (this) .hasClass ('#menmenu-mobile'). Toggleclass ('Inactive menu'); ('inactive menu')) {slide right (); disable ();} and {slide lift (); active ();} // ********** *************************************************************************************************** ************************************ one down ************ **** setTimeout (function () {setFunction ()}, 500);}}; Var setFunction = function () {jQuery ("# ​​mobile-menu-toggler"). Bind ('click', function () (jQuery ("# ​​mobile-menu-toggler"). Unbind ('click'); jQuery (this). Toggle class ('inactive menu'); jQuery ('#menmenu ("Disabled", true); If (jQuery (this) .hasClass ('disable-menu'); Toggle class ('inactive-menu'); jQuery ("# ​​mobile-menu-wrap" Menu ')) {slide right (); disable ();} and {slide lift ()); activate ();} settimeout (function () {setFunction ()}, 500);}}; } // ************************************************************************ ) {Var container = jQuery ("# ​​mobile-menu-rap"); if (container.to (e.target) and container length === 0) {slide right ( ); Disable(); } });   

CODEPEN FORK:

If I were you, I might Did it (just the example)

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -