2014-08-13 04:35:56 +02:00
|
|
|
/**
|
|
|
|
* cbpAnimatedHeader.js v1.0.0
|
|
|
|
* http://www.codrops.com
|
|
|
|
*
|
|
|
|
* Licensed under the MIT license.
|
|
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
|
|
*
|
|
|
|
* Copyright 2013, Codrops
|
|
|
|
* http://www.codrops.com
|
|
|
|
*/
|
|
|
|
var cbpAnimatedHeader = (function() {
|
|
|
|
|
|
|
|
var docElem = document.documentElement,
|
|
|
|
header = document.querySelector( '.navbar-default' ),
|
|
|
|
didScroll = false,
|
2015-11-02 16:30:43 +01:00
|
|
|
changeHeaderOn = 220;
|
2014-08-13 04:35:56 +02:00
|
|
|
|
|
|
|
function init() {
|
2015-11-02 16:30:43 +01:00
|
|
|
scrollPage();
|
2014-08-13 04:35:56 +02:00
|
|
|
window.addEventListener( 'scroll', function( event ) {
|
|
|
|
if( !didScroll ) {
|
|
|
|
didScroll = true;
|
|
|
|
setTimeout( scrollPage, 250 );
|
|
|
|
}
|
|
|
|
}, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
function scrollPage() {
|
|
|
|
var sy = scrollY();
|
|
|
|
if ( sy >= changeHeaderOn ) {
|
|
|
|
classie.add( header, 'navbar-shrink' );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
classie.remove( header, 'navbar-shrink' );
|
|
|
|
}
|
|
|
|
didScroll = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function scrollY() {
|
|
|
|
return window.pageYOffset || docElem.scrollTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
2015-11-02 16:30:43 +01:00
|
|
|
})();
|