Total Complexity | 6 |
Complexity/F | 1.2 |
Lines of Code | 24 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | (function($) { |
||
2 | 'use strict'; |
||
3 | $(function() { |
||
4 | // The function actually applying the offset |
||
5 | function offsetAnchor() { |
||
6 | if (location.hash.length !== 0) { |
||
7 | // window.scrollTo(window.scrollX, window.scrollY - 140); |
||
8 | $("html").animate({ scrollTop: $(location.hash).offset().top - 160 }, 500); |
||
9 | } |
||
10 | } |
||
11 | |||
12 | // Captures click events of all <a> elements with href starting with # |
||
13 | $(document).on('click', 'a[href^="#"]', function(event) { |
||
|
|||
14 | // Click events are captured before hashchanges. Timeout |
||
15 | // causes offsetAnchor to be called after the page jump. |
||
16 | window.setTimeout(function() { |
||
17 | offsetAnchor(); |
||
18 | }, 0); |
||
19 | }); |
||
20 | |||
21 | // Set the offset when entering page with hash present in the url |
||
22 | window.setTimeout(offsetAnchor, 0); |
||
23 | }); |
||
24 | })(jQuery); |
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.