Difference between revisions of "Template:Technion/Javascript"

Line 2: Line 2:
 
 
 
var scroll_flag;
 
var scroll_flag;
var hover_flag;
+
var hover_flag = false;
 
 
 
if (window.scrollY >= 450)
 
if (window.scrollY >= 450)
Line 22: Line 22:
 
}
 
}
 
 
+
$(".dropdown").hover(function()
+
{
+
hover_flag = true;
+
$(".dropdown nav").css("max-height", "999px");
+
},
+
+
function()
+
{
+
hover_flag = false;
+
if(scroll_flag == 1)
+
{
+
$(".dropdown nav").css("max-height", "0px");
+
}
+
});
+
+
 
window.onscroll=function() {
 
window.onscroll=function() {
 
if (window.scrollY >= 450)
 
if (window.scrollY >= 450)
Line 56: Line 41:
 
}
 
}
 
}
 
}
 +
 +
$(".dropdown").hover(function()
 +
{
 +
hover_flag = true;
 +
$(".dropdown nav").css("max-height", "999px");
 +
},
 +
 +
function()
 +
{
 +
hover_flag = false;
 +
if(scroll_flag == 1)
 +
{
 +
$(".dropdown nav").css("max-height", "0px");
 +
}
 +
});
 
 
 
});
 
});

Revision as of 15:07, 21 August 2015

$(document).ready(function() {

var scroll_flag; var hover_flag = false;

if (window.scrollY >= 450) { scroll_flag = 1; } else { scroll_flag = 0; }

if (scroll_flag == 1) { $(".dropdown nav").css("max-height", "0px"); } else { $(".dropdown nav").css("max-height", "999px"); }


window.onscroll=function() { if (window.scrollY >= 450) { scroll_flag = 1; } else { scroll_flag = 0; } if ((hover_flag == false) && (scroll_flag == 1)) { $(".dropdown nav").css("max-height", "0px"); } else { $(".dropdown nav").css("max-height", "999px"); } }

$(".dropdown").hover(function() { hover_flag = true; $(".dropdown nav").css("max-height", "999px"); },

function() { hover_flag = false; if(scroll_flag == 1) { $(".dropdown nav").css("max-height", "0px"); } });

});