this may seem like a simple error but I've been stuck on it.
I am running a WordPress installation with a script that I found which hides the header based on scroll. They script worked perfectly while on the page itself enclosed in tags until I started loading it into the WordPress theme with a separate file.
wp_enqueue_script( 'greycanary-effects', get_template_directory_uri() . '/js/effects.js', array(), '20120206', true );
And the script...
( function() {
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('.main-navigation').outerHeight();
jQuery(window).scroll(function(event){
didScroll = true;
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
function hasScrolled() {
var st = $(this).scrollTop();
// Make sure they scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta)
return;
// If they scrolled down and are past the navbar, add class .nav-up.
// This is necessary so you never see what is "behind" the navbar.
if (st > lastScrollTop && st > navbarHeight){
// Scroll Down
$('.main-navigation').removeClass('nav-down').addClass('nav-up');
} else {
// Scroll Up
if(st + $(window).height() < $(document).height()) {
$('.main-navigation').removeClass('nav-up').addClass('nav-down');
}
}
lastScrollTop = st;
};
});