/
scroll.js
62 lines (41 loc) · 1.64 KB
/
scroll.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$((function() {
$(window).scroll(function() { // biography fix when scrolling up
console.log($('html').offset().top);
if ( $('html').offset().top == 0 ) {
$('#navbar').find('.current').removeClass('current');
$('#navbar ul li a[href^="#bio"]').addClass('current');
}
});
// var gOffset = 0;
$('section').waypoint(function(event, direction) {
var id = $(this).attr('id');
//console.log('id: '+$(this).attr('id')+', direction: '+direction);
$('#navbar').find('.current').removeClass('current');
$('#navbar ul li a[href="#'+id+'"]').addClass('current');
// console.log('id: '+$(this).attr('id')+', direction: '+direction);
// gOffset = direction === 'down' ? 160 : 0;
// $.waypoints('refresh');
// console.log(gOffset);
//console.log($('html').offset().top);
}, {
offset: 160
});
/*
$(document).scrollTop(0); // quick reset in case user refreshes the page
var OFFSET = 30;
var HEADER_HEIGHT = parseInt($('#header').height()) + OFFSET;
$('a[href^=#]:not([href=#])').click(function(e){
$('html, body')
.animate({
scrollTop: $($(this).attr("href"))
.offset().top - HEADER_HEIGHT }, 1200)
.animate({
scrollTop: $($(this).attr("href"))
.offset().top - HEADER_HEIGHT - 20 }, 300)
.animate({
scrollTop: $($(this).attr("href"))
.offset().top - HEADER_HEIGHT }, 600);
e.preventDefault();
});
*/
});