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
|
|||
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
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. ![]() |
|||
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 | })(); |
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.