public/js/cbpAnimatedHeader.js   A
last analyzed

Complexity

Total Complexity 7
Complexity/F 1.4

Size

Lines of Code 34
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 34
rs 10
wmc 7
mnd 1
bc 8
fnc 5
bpm 1.6
cpm 1.4
noi 2

3 Functions

Rating   Name   Duplication   Size   Complexity  
A cbpAnimatedHeader.js ➔ scrollPage 0 10 2
A cbpAnimatedHeader.js ➔ scrollY 0 3 1
A cbpAnimatedHeader.js ➔ init 0 8 1
1
/**
2
 * cbpAnimatedHeader.js v1.0.0
3
 * http://www.codrops.com
4
 *
5
 * Licensed under the MIT license.
6
 * http://www.opensource.org/licenses/mit-license.php
7
 * 
8
 * Copyright 2013, Codrops
9
 * http://www.codrops.com
10
 */
11
var cbpAnimatedHeader = (function() {
12
13
	var docElem = document.documentElement,
14
		header = document.querySelector( '.navbar-default' ),
15
		didScroll = false,
16
		changeHeaderOn = 300;
17
18
	function init() {
19
		window.addEventListener( 'scroll', function( event ) {
0 ignored issues
show
Unused Code introduced by
The parameter event is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
20
			if( !didScroll ) {
21
				didScroll = true;
22
				setTimeout( scrollPage, 250 );
23
			}
24
		}, false );
25
	}
26
27
	function scrollPage() {
28
		var sy = scrollY();
29
		if ( sy >= changeHeaderOn ) {
30
			classie.add( header, 'navbar-shrink' );
0 ignored issues
show
Bug introduced by
The variable classie seems to be never declared. If this is a global, consider adding a /** global: classie */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
31
		}
32
		else {
33
			classie.remove( header, 'navbar-shrink' );
34
		}
35
		didScroll = false;
36
	}
37
38
	function scrollY() {
39
		return window.pageYOffset || docElem.scrollTop;
40
	}
41
42
	init();
43
44
})();