-
Notifications
You must be signed in to change notification settings - Fork 0
/
about-us.js
64 lines (52 loc) · 1.74 KB
/
about-us.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
const infoSelectBtns = Array.from(document.querySelectorAll(".info-heading"));
const infoContent = Array.from(document.querySelectorAll(".about-us-content"));
const infoSelect = document.querySelector("#info-select");
infoSelect.addEventListener("change", (e) => {
infoContent.forEach((el) => (el.style.display = "none"));
let target = getElement(e.target.value);
target.style.display = "flex";
});
infoSelectBtns.forEach((el, index) => (el.style.zIndex = `${20 - index}`));
infoSelectBtns[0].disabled = true;
const getElement = (str) => {
let string = str.toLowerCase().replaceAll(" ", "-").replace("&", "and");
return document.querySelector(`.${string}-about-us-content-wrapper`);
};
infoSelectBtns.forEach((el) => {
el.addEventListener("click", (e) => {
let y = window.scrollY;
showContent(e.target);
window.scrollTo(0, y);
});
});
const showContent = (el) => {
infoContent.forEach((el) => (el.style.display = "none"));
let target = getElement(el.innerText);
target.style.display = "flex";
infoSelectBtns.forEach((el, index) => {
el.disabled = false;
el.style.zIndex = `${20 - index}`;
});
el.disabled = true;
el.style.zIndex = "50";
};
const a = document.querySelector(".header-background-img");
let mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
if (mediaQuery && !mediaQuery.matches) {
(function () {
$(window)
.unbind("scroll")
.scroll(function () {
a.style.top = `-${window.scrollY / 1.5}px`;
});
})();
}
mediaQuery.addEventListener("change", () => {
(function () {
$(window)
.unbind("scroll")
.scroll(function () {
a.style.top = window.scrollY;
});
})();
});