Skip to content

Instantly share code, notes, and snippets.

@jaredcunha
Created July 17, 2013 13:21
Show Gist options
  • Save jaredcunha/6020509 to your computer and use it in GitHub Desktop.
Save jaredcunha/6020509 to your computer and use it in GitHub Desktop.
Simple scroll logic - just detects if page has scrolled from the top
/*
* Scroll Logic
*/
var active = false;
var lastElement, nextElement;
window.addEventListener( 'scroll', onScroll, false)
function onScroll( event ) {
top = ( doc && doc.scrollTop || body && body.scrollTop || 0 );
if ( active === false && (top.scrollY > 0 || top > 0) ) {
header.className = 'fixed-title active';
active = true;
} else if ( top.scrollY === 0 || top ===0 ) {
active = false;
header.className = 'fixed-title';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment