-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (38 loc) · 1.19 KB
/
script.js
File metadata and controls
40 lines (38 loc) · 1.19 KB
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
36
37
38
39
40
function bezier(t) {
return t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1
}
window.onload = function() {
var navbar = document.getElementById("navbar");
var elementTarget = document.getElementById("section-2");
var max1 = 3.0;
var max2 = 6.0;
if (window.scrollY < 400) {
max1 = 3.0 * bezier(window.scrollY / 400.0);
max2 = 6.0 * bezier(window.scrollY / 400.0);
max1 = max1.toString();
max2 = max2.toString();
navbar.style.boxShadow = "0 "+ max1 +"px "+ max2 +"px 0 #dbdbdb";
} else {
navbar.style.boxShadow = "0 3px 6px 0 #dbdbdb";
}
window.addEventListener("scroll", function() {
var navbar = document.getElementById("navbar");
var elementTarget = document.getElementById("section-2");
var max1 = 3.0;
var max2 = 6.0;
if (window.scrollY < 400) {
max1 = 3.0 * bezier(window.scrollY / 400.0);
max2 = 6.0 * bezier(window.scrollY / 400.0);
max1 = max1.toString();
max2 = max2.toString();
navbar.style.boxShadow = "0 "+ max1 +"px "+ max2 +"px 0 #dbdbdb";
} else {
navbar.style.boxShadow = "0 3px 6px 0 #dbdbdb";
}
});
}
function go_to(id) {
$('html,body').animate({
scrollTop: $(id).offset().top},
'slow');
}