-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·74 lines (66 loc) · 2.79 KB
/
Copy pathapp.js
File metadata and controls
executable file
·74 lines (66 loc) · 2.79 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
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
import copyEmail from "./js/global/copyEmail";
import initCms from "./js/global/initCms";
import { loopLogoLoading, readyPreloader } from "./js/global/preloader";
import loadAnim from "./js/home/loadAnim";
import audioImplementation from "./js/global/audio";
import aboutPage from "./js/about/aboutPage";
import { showreelHome, showreelNav } from "./js/global/showreel";
import { homeVideoAudio } from "./js/global/videoAudio";
import { stopCmdClick, removeBlackCover } from "./js/global/bugFixes";
import {
setAllHomepageVideoSources,
responsiveNavShowreel,
lazyLoadHomeVideos,
contentHubDynamicVideos,
} from "./js/global/dynamicVideos";
const parceled = true; // for checking localhost vs github pages / CDN
const currentPage = window.location.pathname;
const homePage = currentPage == "/";
const contentHubOuter = currentPage === "/content-hub/";
const contentHubInner =
currentPage.startsWith("/content-hub/") && !contentHubOuter;
const isAboutPage = currentPage == "/about"; // change to just about later
const onReady = () => {
// alert("ready");
readyPreloader(); // hides preloader and add event listener for frog lottie
const audio = audioImplementation(homePage); // adds music, ui-sounds and mute-lottie functionality
responsiveNavShowreel(); // make nav showreel load video sources dynamically
if (homePage) {
homeVideoAudio(audio); // code for home video audio
setAllHomepageVideoSources(); // make homepage load video sources dynamically
lazyLoadHomeVideos(); // make homepage videos lazy load in on scroll
// showreelHome(audio); // code for homepage showreel video
}
if (contentHubInner) contentHubDynamicVideos();
showreelNav(audio); // code for nav showreel video
copyEmail(); // copies email to clipboard in footer
initCms(); // sets color hovers and cms filtering style for work page & content hub
document.querySelector(".landing-video-container") && loadAnim(); // for home page intro anim
document.querySelectorAll(".article-rich-text a").forEach((e) => {
e.target = "_blank";
});
if (isAboutPage) aboutPage(); // all custom code for about page
stopCmdClick(); // prevent command click from triggering page transition
removeBlackCover(); // remove black cover on page load
};
const onLoading = () => {
loopLogoLoading();
};
if (document.readyState !== "loading") {
onLoading();
onReady();
} else {
window.addEventListener("load", onReady);
document.addEventListener("DOMContentLoaded", onLoading);
}
// close menu on escape key press
const handleEscape = (e) => {
if (e.key === "Escape") {
const closeBtn = document.querySelector(".burger-close-icon");
const hamburgerMenu = document.querySelector(".hamburger-box");
if (hamburgerMenu.style.opacity == 0) {
closeBtn.click();
}
}
};
window.addEventListener("keydown", handleEscape);