Skip to content

Commit

Permalink
swap load to domonload, fix #33
Browse files Browse the repository at this point in the history
  • Loading branch information
krschmidt committed Mar 30, 2017
1 parent 787e58a commit 3d3f352
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/js/lmm.dev.js
Original file line number Diff line number Diff line change
@@ -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))
Expand Down Expand Up @@ -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])){
Expand All @@ -353,4 +355,4 @@ window.onload = function() {
}
onResize();
window.addEventListener('resize', onResize);
};
});

0 comments on commit 3d3f352

Please sign in to comment.