-
Notifications
You must be signed in to change notification settings - Fork 1
/
function.js
74 lines (71 loc) · 2.38 KB
/
function.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
/** @format */
let menuToggle = document.querySelector('.menuToggle'); //This will allow my navbar to have it's items
let menu = document.querySelector('.menu');
menuToggle.onclick = function () {
menu.classList.toggle('active');
};
var viewpoints = document.getElementsByClassName('Viewpoint');
var views = document.getElementsByClassName('View');
function show(thingy) {
/* YeS... I am naming this variable thingy😀*/
for (viewpoint of viewpoints) {
viewpoint.classList.remove('Activepoint');
}
for (view of views) {
view.classList.remove('Activeview');
}
event.currentTarget.classList.add('Activepoint');
document.getElementById(thingy).classList.add('Activeview');
}
let anime = true;
const abutton = document.getElementById('Anime');
abutton.addEventListener('click', animate);
let Icons = document.querySelectorAll('.Icon');
function animate() {
if (anime) {
for (i = 0; i < Icons.length; ++i) {
Icons[i].classList.remove('animate');
}
anime = false;
window.location.assign(abutton.value);
setTimeout(backHome, 2000);
} else {
for (i = 0; i < Icons.length; ++i) {
Icons[i].classList.add('animate');
}
anime = true;
window.location.assign(abutton.value);
setTimeout(backHome, 2000);
}
}
function backHome() {
window.location.assign(document.getElementById('hide').value);
}
//This is an Intersection Observer ... Duh🤣, in plain english, a method (function) of checking if each section is currently visisble
// on the user's screen, if not the item is hidden, if so then it loads in//
var observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (anime) {
if (entry.isIntersecting) {
entry.target.classList.add('show');
} else {
entry.target.classList.remove('show');
}
} else {
entry.target.classList.add('show');
}
});
});
var hiddenElements = document.querySelectorAll(
'.Projects, .AboutMe, .Services'
);
hiddenElements.forEach((el) => observer.observe(el));
var loader = document.getElementById('preloader');
window.addEventListener('load', function (load) {
// Lazy Loading :) //
this.window.removeEventListener('load', load, false);
this.setTimeout(function () {
loader.style.display = 'none';
this.document.body.style.overflowY = 'scroll';
}, 2000);
});