Skip to content

Commit

Permalink
removed audio from mobile entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshvdw committed Dec 15, 2024
1 parent ac4661a commit cf9c056
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
26 changes: 13 additions & 13 deletions dist/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/app.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions js/global/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export default function audioImplementation(homePage) {
return check;
};

const isMobile = mobileCheck();

// Exit early if on mobile to prevent loading or playing UI sounds
if (isMobile) {
return;
}

// MUTE STATE
let isMuted = false;
let linkClicked = false;
Expand Down
28 changes: 19 additions & 9 deletions js/global/showreel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function showreelHome(audio) {
const fadeMusicToggle = audio.fadeToggle;
const showreelMuteState = audio.getShowreelMuteState;
const fadeMusicToggle = audio?.fadeToggle;
const showreelMuteState = audio?.getShowreelMuteState;

const homeBlock = document.querySelector("#showreel_block_home");
const showreelVideo = document.querySelector("#showreel_video");
Expand Down Expand Up @@ -38,15 +38,19 @@ export function showreelHome(audio) {
showreelVideo.currentTime = 0; //restart video
clickToUnmuteUI.style.display = "none"; //hide unmute ui
clickToMuteUI.style.opacity = 0; // set mute opacity to 0
if (!showreelMuteState()) fadeMusicToggle(); //if unmuted, toggle music fade
if (fadeMusicToggle && showreelMuteState && !showreelMuteState()) {
fadeMusicToggle(); //if unmuted, toggle music fade
}
clickLogic = "once"; //update click logic
outOfView = false; //ensure out of view logic is false
}

// SECOND CLICK LOGIC
function secondClickLogic() {
showreelVideo.muted = true; //mute video again
if (!showreelMuteState()) fadeMusicToggle(); //if unmuted, toggle music fade
if (fadeMusicToggle && showreelMuteState && !showreelMuteState()) {
fadeMusicToggle(); //if unmuted, toggle music fade
}
clickToUnmuteUI.style.opacity = "100"; // set unmute opacity to 100
clickToUnmuteUI.style.display = "flex"; // display unmute ui
clickToMuteUI.style.display = "none"; // hide mute ui
Expand All @@ -56,7 +60,9 @@ export function showreelHome(audio) {
// THIRD CLICK LOGIC
function thirdClickLogic() {
showreelVideo.muted = false; //unmute video
if (!showreelMuteState()) fadeMusicToggle(); //if unmuted, toggle music fade
if (fadeMusicToggle && showreelMuteState && !showreelMuteState()) {
fadeMusicToggle(); //if unmuted, toggle music fade
}
clickToUnmuteUI.style.display = "none"; //hide unmute ui
clickLogic = "once"; //update click logic
outOfView = false; //ensure out of view logic is false
Expand Down Expand Up @@ -128,8 +134,8 @@ export function showreelHome(audio) {

// NAV SHOWREEL
export function showreelNav(audio) {
const fadeMusicToggle = audio.fadeToggle;
const showreelMuteState = audio.getShowreelMuteState;
const fadeMusicToggle = audio?.fadeToggle;
const showreelMuteState = audio?.getShowreelMuteState;

const navPlayReel = document.querySelector(".navbar_playreel-wrapper");
const wave = document.querySelectorAll(".wave");
Expand All @@ -141,7 +147,9 @@ export function showreelNav(audio) {
navPlayReel.addEventListener("click", () => {
showreelVideo.muted = false; //unmute video
showreelVideo.currentTime = 0; //restart video
if (!showreelMuteState()) fadeMusicToggle(); //if unmuted, toggle music fade
if (fadeMusicToggle && showreelMuteState && !showreelMuteState()) {
fadeMusicToggle(); //if unmuted, toggle music fade
}
wave.forEach((stroke) => {
stroke.style.fill = "#F5F4F2"; //set mute svg fill back to white
});
Expand All @@ -155,7 +163,9 @@ export function showreelNav(audio) {
showreelVideo.muted == false &&
document.visibilityState == "visible"
) {
if (!showreelMuteState()) fadeMusicToggle(); //if unmuted, toggle music fade
if (fadeMusicToggle && showreelMuteState && !showreelMuteState()) {
fadeMusicToggle(); //if unmuted, toggle music fade
}
}
},
false
Expand Down

0 comments on commit cf9c056

Please sign in to comment.