From 16f84d5f895566845add9c2978410e177209eee9 Mon Sep 17 00:00:00 2001 From: santukhan Date: Sat, 3 Mar 2018 15:32:41 +0600 Subject: [PATCH] Tablet and medium devices menu break issue Tablet and medium devices menu break issues were vital and I fixed the issues for my personal project and also provided the fix here. Thank you for the menu library. --- jquery.meanmenu.js | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/jquery.meanmenu.js b/jquery.meanmenu.js index 70a49f1..20f7b11 100644 --- a/jquery.meanmenu.js +++ b/jquery.meanmenu.js @@ -257,26 +257,32 @@ } jQuery(window).resize(function () { - // get browser width - currentWidth = window.innerWidth || document.documentElement.clientWidth; + // get browser width + setTimeout(function(){ + /** + * make sure that the currentWidth variable assigned with perfect width value + * @author Rakibul Hasan + */ + currentWidth = window.innerWidth || document.documentElement.clientWidth; - if (!isMobile) { - meanOriginal(); - if (currentWidth <= meanScreenWidth) { - showMeanMenu(); - meanCentered(); - } - } else { - meanCentered(); - if (currentWidth <= meanScreenWidth) { - if (meanMenuExist === false) { - showMeanMenu(); - } - } else { - meanOriginal(); - } - } - }); + if (!isMobile) { + meanOriginal(); + if (currentWidth <= meanScreenWidth) { + showMeanMenu(); + meanCentered(); + } + } else { + meanCentered(); + if (currentWidth <= meanScreenWidth) { + if (meanMenuExist === false) { + showMeanMenu(); + } + } else { + meanOriginal(); + } + } + },100); + }); // run main menuMenu function on load showMeanMenu();