From 3d3f352dddab21c7e7d8a3f574628b5c8bfcd197 Mon Sep 17 00:00:00 2001 From: Kyle Schmidt Date: Thu, 30 Mar 2017 16:45:43 -0700 Subject: [PATCH] swap load to domonload, fix #33 --- src/js/lmm.dev.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/js/lmm.dev.js b/src/js/lmm.dev.js index b36c1cf..fe9d6d3 100644 --- a/src/js/lmm.dev.js +++ b/src/js/lmm.dev.js @@ -1,15 +1,15 @@ "use strict"; -window.onload = function() { +document.addEventListener("DOMContentLoaded", function() { /* If someone includes the script twice (which has happened), the mega menu throws * open and close events simultaneously, meaning it doesn't work at all. So here * we'll make sure we don't accidentally draw it twice. */ - if(typeof mm !== 'undefined'){ + if(typeof window.mm !== 'undefined'){ console.log("megamenu script already present"); return; } else { - var mm = "loaded"; + window.mm = "loaded"; } if(!('classList' in document.body)) @@ -326,11 +326,13 @@ window.onload = function() { if(window.innerWidth >= 1440){ width = 1180; } + let leftmargin = Math.floor(window.innerWidth - width) / 2 - 14; //keeps us from sliding under the logo if(leftmargin < 0){ leftmargin = 0; } + $cats.style.marginLeft = leftmargin + "px"; if(visible($lmm.getElementsByClassName('lmm-searchops')[0])){ @@ -353,4 +355,4 @@ window.onload = function() { } onResize(); window.addEventListener('resize', onResize); -}; \ No newline at end of file +}); \ No newline at end of file