-
Notifications
You must be signed in to change notification settings - Fork 10
/
elasticBar.js
35 lines (35 loc) · 1.23 KB
/
elasticBar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Note: line height is set to match navigation_height and navigation_min_height respectivly
navigation_height = 100
navigation_min_height = 40
$(window).scroll(function(){
if(($('body').scrollTop()>=-40) && ($('body').scrollTop()<=(navigation_height-navigation_min_height))){
//controls elements dimentions on scroll
var s = $('body').scrollTop();
console.log(s);
$('#navigation').stop().animate({
height:navigation_height-s,
},10);
$('#navigation li a').stop().animate({
height:navigation_height-s,
lineHeight:navigation_height-s,
},10);
//Elements under navigation bar fix
//Laggy? Remove this code. The over flow is has a pretty cool effect anyway.
$('#nextElementFix').stop().animate({
paddingTop:navigation_height-s
},10);
} else if(($('body').scrollTop()>=-40) && ($('body').scrollTop()>=(navigation_height-navigation_min_height)) ){
//hold animation on fast scroll
var s = $('body').scrollTop();
$('#navigation').stop().animate({
height:navigation_min_height
},15);
$('#navigation li a').stop().animate({
height:navigation_min_height,
lineHeight:navigation_min_height,
},15);
$('#nextElementFix').stop().animate({
paddingTop:navigation_min_height-s
},15);
}
});