OLD | NEW |
1 jQuery(function() | 1 jQuery(function() |
2 { | 2 { |
3 var toTop = jQuery("#to-top"); | 3 var $toTop = jQuery("#to-top"); |
4 toTop.click(function () | 4 |
| 5 $toTop.click(function () |
5 { | 6 { |
6 jQuery("body,html").animate({ | 7 jQuery("body,html").animate({ |
7 scrollTop: 0 | 8 scrollTop: 0 |
8 }, 800); | 9 }, 800); |
9 return false; | 10 return false; |
10 }); | 11 }); |
11 }); | 12 |
12 | 13 var $window = jQuery(window); |
13 jQuery(window).scroll(function() | 14 var $header = jQuery("#header"); |
14 { | 15 var headerPadding = 13; |
15 var scrollTop = jQuery(window).scrollTop(); | 16 |
16 | 17 $window.scroll(function() |
17 // Fix header | |
18 var header = jQuery("#header"); | |
19 var height = header.height(); | |
20 var fixed = (scrollTop > height); | |
21 if (fixed != header.hasClass("fixed")) | |
22 { | 18 { |
23 if (fixed) | 19 if ($window.scrollTop() > headerPadding) |
24 { | 20 { |
25 header.css("top", -height); | 21 if ($header.hasClass("top")) |
26 header.animate({top: 0},function() | |
27 { | 22 { |
28 header.css("top", ""); | 23 $header.removeClass("top"); |
29 }); | 24 $toTop.show(); |
30 header.addClass("fixed"); | 25 } |
| 26 } |
| 27 else |
| 28 { |
| 29 if (!$header.hasClass("top")) |
| 30 { |
| 31 $header.addClass("top"); |
| 32 $toTop.hide(); |
| 33 } |
| 34 } |
| 35 }); |
| 36 |
| 37 jQuery('#header-hamberger').click(function() |
| 38 { |
| 39 var $menu = jQuery("#menu"); |
| 40 |
| 41 if ($menu.hasClass("open")) { |
| 42 $menu.removeClass("open"); |
| 43 $menu.attr("aria-expanded", false); |
31 } | 44 } |
32 else | 45 else |
33 header.removeClass("fixed"); | 46 { |
34 } | 47 $menu.addClass("open"); |
35 | 48 $menu.attr("aria-expanded", true); |
36 // Display "to top" button | 49 } |
37 var toTop = jQuery("#to-top"); | 50 }) |
38 toTop.css("opacity", scrollTop > 100 ? 1 : 0) | 51 |
39 }); | 52 }); |
OLD | NEW |