Created
July 17, 2013 13:21
-
-
Save jaredcunha/6020509 to your computer and use it in GitHub Desktop.
Simple scroll logic - just detects if page has scrolled from the top
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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