-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (38 loc) · 1.15 KB
/
script.js
File metadata and controls
43 lines (38 loc) · 1.15 KB
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
// Parallax effect (JQuery)
$(window).scroll(function () {
var winScroll = $(this).scrollTop();
// console.log(winScroll);
$("#background").css({
"transform": "translate(0, " + winScroll / 14 + "%)"
});
$("#birds").css({
"transform": "translate(" + winScroll / 18 + "%)"
});
})
// Navigation hamburger menu on/off
$(".mobile-nav-toggle").click(function (event) {
const visibility = $(".nav-links").attr("data-visible")
console.log(visibility);
if (visibility == "false") {
$(".nav-links").attr("data-visible", "true");
$(".mobile-nav-toggle").attr("aria-expanded", "true");
}
else if (visibility == "true") {
$(".nav-links").attr("data-visible", "false");
$(".mobile-nav-toggle").attr("aria-expanded", "false");
}
});
// Intersection observer
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
console.log(entry);
if (entry.isIntersecting) {
entry.target.classList.add("show");
}
else {
entry.target.classList.remove("show");
}
});
});
const hiddenElements = document.querySelectorAll(".hidden");
hiddenElements.forEach((elem) => observer.observe(elem));