-
Notifications
You must be signed in to change notification settings - Fork 4
/
home.js
33 lines (29 loc) · 1.08 KB
/
home.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
$('.carousel').carousel({
interval: 5000
});
// the single-page site homepage has a transparent menu bar for the
// fullscreen carousel, but this needs to change to a black background
// as you scroll down the page or else the text of the page will run
// underneath it
$(window).on("scroll", function() {
if ($(this).scrollTop() > 100) {
$("nav").css("background-color", "black");
} else {
$("nav").css("background-color", "transparent");
}
});
// when a user follows a link to a particular part of the one-page-site
// homepage they are scrolled to that location in the page and then the
// history is updated to a url without the hash fragment. arguments could
// be had about whether this is a good idea. but the behavior is consistent
// with clicking on menu links when on the home page itself.
$(function() {
var frag = window.location.hash;
if (frag) {
$('html, body').stop().animate({
scrollTop: $(frag).offset().top
}, 1500, 'easeInOutExpo');
var loc = window.location;
history.pushState("", document.title, loc.pathname + loc.search);
}
});