-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
85 lines (71 loc) · 3.21 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
console.log("script running");
// global variables
var desktopWidth = 1100;
// Parallax effect for banner
var parallax = document.getElementsByClassName('banner')[0];
window.addEventListener("scroll", function(){
var pageOffset = window.pageYOffset * 0.7;
if(window.innerWidth > desktopWidth){
parallax.style.backgroundPositionY = pageOffset + 'px';
}
})
// Show or hide the dropdown menu when pressed
// This is only used for the mobile nav
function toggleNav(){
if($('#dropdown').hasClass('hide-dropdown')){
$('#dropdown').removeClass('hide-dropdown');
$('#dropdown').addClass('show-dropdown');
}
else{
$('#dropdown').removeClass('show-dropdown');
$('#dropdown').addClass('hide-dropdown');
}
}
// For opening urls
function openURL(url) {
window.open(url, "_blank");
}
// Jump the window view to a specific section
// sectionName is a string that represents the section id to jump to
function jumpto(sectionName){
//window.location.hash = sectionName;
document.getElementById(sectionName).scrollIntoView({behavior: 'smooth'});
$('#dropdown').removeClass('show-dropdown');
$('#dropdown').addClass('hide-dropdown');
}
// Change bg color of floating nav li based on scroll height
// Probably a cleaner way to do this xxx
$(document).scroll(function(){
var y = $(this).scrollTop();
// Finding all the heights for each section
bannerHeight = document.getElementsByClassName('banner')[0].scrollHeight;
aboutHeight = document.getElementById('about-section').scrollHeight;
expHeight = document.getElementById('experience-section').scrollHeight;
skillsHeight = document.getElementById('abilities-section').scrollHeight;
contactHeight = document.getElementById('contact-section').scrollHeight;
console.log(contactHeight);
if(y > bannerHeight + aboutHeight + skillsHeight + expHeight - 2*contactHeight){
$('.floating-nav li:eq(3)').css('background-color', 'red');
$('.floating-nav li:eq(2)').css('background-color', '#222222');
$('.floating-nav li:eq(1)').css('background-color', '#222222');
$('.floating-nav li:eq(0)').css('background-color', '#222222');
}
else if(y > bannerHeight + aboutHeight + skillsHeight - 10){
$('.floating-nav li:eq(3)').css('background-color', '#222222');
$('.floating-nav li:eq(2)').css('background-color', 'red');
$('.floating-nav li:eq(1)').css('background-color', '#222222');
$('.floating-nav li:eq(0)').css('background-color', '#222222');
}
else if(y > bannerHeight + aboutHeight - 10){
$('.floating-nav li:eq(3)').css('background-color', '#222222');
$('.floating-nav li:eq(2)').css('background-color', '#222222');
$('.floating-nav li:eq(1)').css('background-color', 'red');
$('.floating-nav li:eq(0)').css('background-color', '#222222');
} else{
$('.floating-nav li:eq(3)').css('background-color', '#222222');
$('.floating-nav li:eq(2)').css('background-color', '#222222');
$('.floating-nav li:eq(1)').css('background-color', '#222222');
$('.floating-nav li:eq(0)').css('background-color', 'red');
}
console.log('window width: ' + window.innerWidth);
})