I put together a little javascript that will hide a header and footer while scrolling. The problem is the nested elements in the header and footer are delayed in being hidden and shown. Even if I set every element to be hidden, they are still delayed from the parent div element (<div1>). Any thoughts on how I can get everything to disappear at the same time?
Let's say the header/footer layout is something like the following and the code is set to hide <div1>:
<div1> will hide instantly, then the nested elements hide about 300ms later.
ACTUAL CODE
Thanks
Let's say the header/footer layout is something like the following and the code is set to hide <div1>:
Code:
<div1>
<img>
<div2></div2>
<div3>
<div4>
</div4>
</div3>
</div1>
ACTUAL CODE
Code:
<script>
// HIDE MOBILE TOP AND BOTTOM MENU ELEMENT ON SCROLLING
var timer2;
function hideme() {
// Clear the timer
if(timer2 != "undefined"){
clearTimeout(timer2);
}
// Hide the header and footer menu in mobile mode
document.getElementById("mobile_top_menu").style.visibility = "hidden";
document.getElementById("mobile_bottom_menu").style.visibility = "hidden";
// Set the timer to show the header and footer menu in mobile mode
timer2 = setTimeout(function(){
document.getElementById("mobile_top_menu").style.visibility = "visible";
document.getElementById("mobile_bottom_menu").style.visibility = "visible";
},400)//Threshold is 400ms
};
// Call the function when scrolling
window.onscroll = hideme;
</script>
Thanks