-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
79 lines (66 loc) · 2.07 KB
/
main.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
$(function() {
const body = document.querySelector('body');
const toggle = document.getElementById('toggle');
const input = document.getElementById('switch');
input.checked = true;
body.classList.add('night');
toggle.addEventListener('click', function() {
const isChecked = input.checked;
if (isChecked) {
body.classList.remove('night');
} else {
body.classList.add('night');
}
});
const introHeight = document.querySelector('.intro').offsetHeight;
const topButton = document.getElementById('top-button');
const $topButton = $('#top-button');
window.addEventListener(
'scroll',
function() {
if (window.scrollY > introHeight) {
$topButton.fadeIn();
} else {
$topButton.fadeOut();
}
},
false
);
topButton.addEventListener('click', function() {
$('html, body').animate({ scrollTop: 0 }, 500);
});
const hand = document.querySelector('.emoji.wave-hand');
function waveOnLoad() {
hand.classList.add('wave');
setTimeout(function() {
hand.classList.remove('wave');
}, 2000);
}
setTimeout(function() {
waveOnLoad();
}, 1000);
hand.addEventListener('mouseover', function() {
hand.classList.add('wave');
});
hand.addEventListener('mouseout', function() {
hand.classList.remove('wave');
});
window.sr = ScrollReveal({
reset: false,
duration: 600,
easing: 'cubic-bezier(.694,0,.335,1)',
scale: 1,
viewFactor: 0.3,
});
sr.reveal('.background');
sr.reveal('.skills');
sr.reveal('.experience', { viewFactor: 0.2 });
sr.reveal('.featured-projects', { viewFactor: 0.1 });
sr.reveal('.other-projects', { viewFactor: 0.05 });
});
document.addEventListener('DOMContentLoaded', function() {
var audioElement = document.getElementById('background-music');
if (audioElement) {
audioElement.volume = 0.2; // Set volume to 30% of the maximum
}
});