I have an on-hover menu which has to have display:none
while it's not in use, so you can click things under it.
When it time to open it up, I turn the display to inline-block; and then fade in the opacity using css transition - with this code:
elm.onmouseover = function(){
menu.style.display = "inline-block";
menu.style.opacity = 1;
};
When this code does run, the element pops straight in without any fade.
My theory was that the javascript runs so fast that the element hasn't changed display type by the time the opacity change kicks in, so I did this:
elm.onmouseover = function(){
menu.style.display = "inline-block";
for (var i=1000...; i--; );
menu.style.opacity = 1;
};
It now visibly waits; however, still pops in without a fade.
I went into my console and ran:
menu.style.display = "inline-block";
menu.style.opacity = 1; // run
> return message
and it didnt work; however, when I split the statements into two like this
menu.style.display = "inline-block"; // run
> return message
menu.style.opacity = 1; // run
> return message
It works fine, and the delay between the two is much less than the one caused by the for loop.
What is the root of this behaviour? I'm baffled.