OK - I've reduced this to it's simplest form:
<div id="bar>47 px high bar</div>
<div id="header">
<ul>
<li>Nav1</li>
</ul>
</div>
.
//Down
$(function() {
var interval = setInterval(function() {
if ($(window).scrollTop() >= 47) {
$("#header").attr("id","header2");
clearInterval(interval);
}
}, 50);
});
//Up
$(function() {
var interval = setInterval(function() {
if ($(window).scrollTop() < 47) {
$("#header2").attr("id","header");
clearInterval(interval);
}
}, 50);
});
It works, but only in one direction - if I load at the top of the page it works scrolling down. If I load halfway down the page it works scrolling up. Go the other direction after this and nothing happens. Anyone know why?
scrollevent (with a timer)?