-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
136 lines (110 loc) · 3.9 KB
/
app.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
var main = function() {
if ($(window).width() >= 1060) {
$('nav').removeClass('hidden');
}
$(window).scroll(function() {
var wScroll = $(this).scrollTop();
//navbar hiding
if (wScroll > $('#home-section').offset().top) {
$("nav").removeClass("hidden");
}
else if ($(window).width() < 1080) {
$("nav").addClass("hidden");
}
//navbar text hilighting
var servicesHeight = $('#services-section').offset().top - window.innerHeight/3;
var aboutHeight = $('#about-section').offset().top - window.innerHeight/3;
var contactHeight = $('#contact-section').offset().top - window.innerHeight/1.3;
var lastUpdated = 'home';
//services is active
if (wScroll > servicesHeight && wScroll < aboutHeight && lastUpdated != 'services') {
clearActiveNav();
$('#nav-services').addClass('active');
lastUpdated = 'services';
removeCredit();
}
//about is active
else if (wScroll > aboutHeight && wScroll < contactHeight && lastUpdated != 'about') {
clearActiveNav();
$('#nav-about').addClass('active');
lastUpdated = 'about';
removeCredit();
}
//contact is active
else if (wScroll > aboutHeight && lastUpdated != 'contact') {
clearActiveNav();
$('#nav-contact').addClass('active');
lastUpdated = 'contact';
showCredit();
}
else {
clearActiveNav();
$('#nav-home').addClass('active');
lastUpdated = 'home';
removeCredit();
}
});
//nav-bar item triggers
$(".nav-text").click(function(){
//Scrolling triggers for home, services, and about
if ($(this).attr('id') == "nav-home") {
$(window).scrollTo(0, {
duration: 1100,
over: {top:-0.01}
});
}
if ($(this).attr('id') == "nav-services") {
$(window).scrollTo($('#services-section'), {
duration: 1100,
over: {top:-0.01}
});
}
if ($(this).attr('id') == "nav-about") {
$(window).scrollTo($('#about-section'), {
duration: 1100,
over: {top:-0.01}
});
}
if ($(this).attr('id') == "nav-contact") {
$(window).scrollTo($('#contact-section'), {
duration: 1100,
over: {top:-0.01}
});
}
});
$("#pull-tab").click(function() {
toggleFooter();
});
//resize contact section
resizeContact($("#contact-section"));
$(window).resize(function() {
window.setTimeout(function() {
resizeContact($("#contact-section"));
}, 1600);
});
};
function resizeContact(contactSection) {
var contWidth = parseInt(contactSection.css('width'));
contactSection.css('height', contWidth/3.5*2);
}
function clearActiveNav() {
$('#nav-home').removeClass('active');
$('#nav-services').removeClass('active');
$('#nav-about').removeClass('active');
$('#nav-contact').removeClass('active');
}
function showCredit() {
$('#pull-tab').removeClass('fadeOutLeft');
$('#pull-tab').addClass('fadeInLeft');
}
function removeCredit() {
$('#pull-tab').removeClass('fadeInLeft');
$('#pull-tab').addClass('fadeOutLeft');
$('footer').removeClass('shift-up');
$('#body-container').removeClass('shift-up');
}
function toggleFooter() {
$('footer').toggleClass('shift-up');
$('#body-container').toggleClass('shift-up');
}
$(document).ready(main);