I’ve got this JavaScript
$(window).load(function(){
var $menu = $("header");
var opacity = $menu.css("opacity");
var scrollStopped;
var fadeInCallback = function () {
if (typeof scrollStopped != 'undefined') {
clearInterval(scrollStopped);
}
scrollStopped = setTimeout(function () {
$menu.animate({ opacity: 1 }, "slow");
}, 1400);
}
$(window).scroll(function () {
if (!$menu.is(":animated") && opacity == 1) {
$menu.animate({ opacity: 0 }, "200", fadeInCallback);
} else {
fadeInCallback.call(this);
}
});
});
It worked fine in hiding the header on scroll, but adding some height: 100%; to the html, body and a ‘content div’ with overflow hidden on html and body and auto on the ‘content div’ this javascript no longer works.
Any idea why this javascript doesn’t work? And is there a fix or other way to do it so the header fades out when scrolling?
Thanks in advance
EDIT —-
A JsFiddle – http://jsfiddle.net/sturobson/AMJFG/
A newer Fiddle with less CSS – http://jsfiddle.net/sturobson/AMJFG/1/
your script works for me.
however if you want to try another method try the below, based on yours but a little simplified: