-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/NevroHelios/ProjectX
- Loading branch information
Showing
4 changed files
with
116 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,45 @@ | ||
const track = document.getElementById("image-track"); | ||
const slideFriction = 1; | ||
|
||
let scrollValue = 0; | ||
let isScrolling = false; | ||
let touchStartX = 0; | ||
const handleOnDown = e => track.dataset.mouseDownAt = e.clientX; | ||
|
||
const modalContainer = document.getElementById("modal-container"); | ||
const modalContent = document.getElementById("modal-content"); | ||
const modalImage = document.getElementById("modal-image"); | ||
const closeModal = document.getElementById("close-modal"); | ||
|
||
// Function to handle hover animation | ||
function handleImageHover(image) { | ||
image.addEventListener("mouseenter", () => { | ||
image.style.transition = "transform 0.3s"; | ||
image.style.transform = "rotate(15deg)"; // Adjust the tilt angle as needed | ||
}); | ||
|
||
image.addEventListener("mouseleave", () => { | ||
image.style.transition = "transform 0.3s"; | ||
image.style.transform = "rotate(0deg)"; | ||
}); | ||
const handleOnUp = () => { | ||
track.dataset.mouseDownAt = "0"; | ||
track.dataset.prevPercentage = track.dataset.percentage; | ||
} | ||
|
||
for (const image of track.getElementsByClassName("image")) { | ||
// Call the hover animation function | ||
handleImageHover(image); | ||
|
||
image.addEventListener("click", () => { | ||
modalImage.src = image.src; | ||
modalContainer.style.display = "block"; | ||
}); | ||
const handleOnMove = e => { | ||
if(track.dataset.mouseDownAt === "0") return; | ||
|
||
const mouseDelta = parseFloat(track.dataset.mouseDownAt) - e.clientX, | ||
maxDelta = window.innerWidth / 2; | ||
|
||
const percentage = (mouseDelta / maxDelta) * -100, | ||
nextPercentageUnconstrained = parseFloat(track.dataset.prevPercentage) + percentage, | ||
nextPercentage = Math.max(Math.min(nextPercentageUnconstrained, 0), -100); | ||
|
||
track.dataset.percentage = nextPercentage; | ||
|
||
track.animate({ | ||
transform: `translate(${nextPercentage}%, -50%)` | ||
}, { duration: 1200, fill: "forwards" }); | ||
|
||
for(const image of track.getElementsByClassName("image")) { | ||
image.animate({ | ||
objectPosition: `${100 + nextPercentage}% center` | ||
}, { duration: 1200, fill: "forwards" }); | ||
} | ||
} | ||
|
||
closeModal.addEventListener("click", () => { | ||
modalContainer.style.display = "none"; | ||
}); | ||
|
||
window.addEventListener("wheel", (e) => { | ||
scrollValue += e.deltaY; | ||
const maxDelta = window.innerWidth * slideFriction; | ||
|
||
const percentage = (scrollValue / maxDelta) * 90; | ||
const nextPercentageUnconstrained = parseFloat(track.dataset.prevPercentage) + percentage; | ||
const nextPercentage = Math.max(Math.min(nextPercentageUnconstrained, 0), -90); | ||
|
||
track.dataset.percentage = nextPercentage; | ||
|
||
track.style.transform = `translate(${nextPercentage}%, -50%)`; | ||
|
||
for (const image of track.getElementsByClassName("image")) { | ||
const imagePercentage = nextPercentage + 100; | ||
image.style.objectPosition = `${imagePercentage}% 50%`; | ||
image.style.transform = `rotate(${imagePercentage * 0.03}deg)`; // Adjust rotation rate as needed | ||
} | ||
|
||
isScrolling = true; | ||
|
||
if (window.scrollTimeout) { | ||
clearTimeout(window.scrollTimeout); | ||
} | ||
|
||
window.scrollTimeout = setTimeout(() => { | ||
isScrolling = false; | ||
}, 100); | ||
}); | ||
|
||
window.addEventListener("touchstart", (e) => { | ||
touchStartX = e.touches[0].clientX; | ||
}); | ||
|
||
window.addEventListener("touchmove", (e) => { | ||
const touchDeltaX = touchStartX - e.touches[0].clientX; | ||
const maxDelta = window.innerWidth * slideFriction; | ||
|
||
const percentage = -(touchDeltaX / maxDelta) * 100; | ||
const nextPercentageUnconstrained = parseFloat(track.dataset.prevPercentage) + percentage; | ||
const nextPercentage = Math.max(Math.min(nextPercentageUnconstrained, 0), -100); | ||
|
||
track.dataset.percentage = nextPercentage; | ||
|
||
track.style.transform = `translate(${nextPercentage}%, -50%)`; | ||
|
||
for (const image of track.getElementsByClassName("image")) { | ||
const imagePercentage = nextPercentage + 100; | ||
image.style.objectPosition = `${imagePercentage}% 50%`; | ||
image.style.transform = `rotate(${imagePercentage * 0.5}deg)`; // Adjust rotation rate as needed | ||
} | ||
touchStartX = e.touches[0].clientX; | ||
}); | ||
|
||
window.onmousedown = (e) => { | ||
track.dataset.mouseDownAt = e.clientX; | ||
}; | ||
|
||
window.onmousemove = (e) => { | ||
if (track.dataset.mouseDownAt === "0") return; | ||
|
||
const mouseDelta = parseFloat(track.dataset.mouseDownAt) - e.clientX; | ||
const maxDelta = window.innerWidth * slideFriction; | ||
/* -- Had to add extra lines for touch events -- */ | ||
|
||
const percentage = -(mouseDelta / maxDelta) * 100; | ||
const nextPercentageUnconstrained = parseFloat(track.dataset.prevPercentage) + percentage; | ||
const nextPercentage = Math.max(Math.min(nextPercentageUnconstrained, 0), -100); | ||
window.onmousedown = e => handleOnDown(e); | ||
|
||
track.dataset.percentage = nextPercentage; | ||
window.ontouchstart = e => handleOnDown(e.touches[0]); | ||
|
||
track.style.transform = `translate(${nextPercentage}%, -50%)`; | ||
window.onmouseup = e => handleOnUp(e); | ||
|
||
for (const image of track.getElementsByClassName("image")) { | ||
const imagePercentage = nextPercentage + 100; | ||
image.style.objectPosition = `${imagePercentage}% 50%`; | ||
image.style.transform = `rotate(${imagePercentage * 0.5}deg)`; // Adjust rotation rate as needed | ||
} | ||
}; | ||
window.ontouchend = e => handleOnUp(e.touches[0]); | ||
|
||
window.onmouseup = () => { | ||
track.dataset.mouseDownAt = 0; | ||
track.dataset.prevPercentage = track.dataset.percentage; | ||
window.onmousemove = e => handleOnMove(e); | ||
|
||
if (!isScrolling) { | ||
setTimeout(() => { | ||
for (const image of track.getElementsByClassName("image")) { | ||
image.style.transition = "transform 0.3s"; | ||
image.style.transform = "rotate(0deg)"; | ||
} | ||
}, 100); | ||
} | ||
}; | ||
window.ontouchmove = e => handleOnMove(e.touches[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,77 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
@font-face { | ||
font-family: pixeboy; | ||
src: url('pixeboy.ttf'); | ||
} | ||
|
||
.image { | ||
transition: filter 0.3s ease-in-out; | ||
} | ||
.image.desaturated { | ||
filter: grayscale(100%); | ||
} | ||
|
||
body { | ||
min-height: 100vh; | ||
background-color: rgb(36, 33, 33); | ||
overflow: hidden; | ||
height: 100vh; | ||
width: 100vw; | ||
background-color: black; | ||
margin: 0rem; | ||
overflow: hidden; | ||
} | ||
|
||
#image-track > .image { | ||
width: 40vmin; | ||
height: 56vmin; | ||
object-fit: cover; | ||
object-position: 50% 50%; | ||
#image-track { | ||
display: flex; | ||
gap: 4vmin; | ||
position: absolute; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(0%, -50%); | ||
user-select: none; /* -- Prevent image highlighting -- */ | ||
} | ||
|
||
#image-track > .image:not(:hover) { | ||
filter: grayscale(100%); | ||
#image-track > .image { | ||
width: 40vmin; | ||
height: 56vmin; | ||
object-fit: cover; | ||
object-position: 100% center; | ||
} | ||
|
||
#image-track > .image:hover { | ||
filter: none; /* Remove the grayscale filter on hover */ | ||
} | ||
/* -- YouTube Link Styles -- */ | ||
|
||
#image-track { | ||
display: flex; | ||
gap: 4vmin; | ||
position: absolute; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(0, -50%); | ||
body.menu-toggled > .meta-link > span { | ||
color: rgb(30, 30, 30); | ||
} | ||
|
||
#header { | ||
text-align: center; | ||
padding: 5px; | ||
background-color: rgb(36, 33, 33); | ||
color: rgb(255, 255, 255); | ||
z-index: 1; | ||
position: relative; | ||
#source-link { | ||
bottom: 60px; | ||
} | ||
|
||
#header h1 { | ||
font-family: pixeboy; | ||
font-size: 4.5rem; | ||
margin-bottom: 10px; | ||
#source-link > i { | ||
color: rgb(94, 106, 210); | ||
} | ||
|
||
#header p { | ||
font-size: 4rem; | ||
#yt-link > i { | ||
color: rgb(239, 83, 80); | ||
} | ||
|
||
#modal-container { | ||
display: none; | ||
position: fixed; | ||
z-index: 999; | ||
background-color: rgba(0, 0, 0, 0.9); | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
overflow: auto; | ||
.meta-link { | ||
align-items: center; | ||
backdrop-filter: blur(3px); | ||
background-color: rgba(255, 255, 255, 0.05); | ||
border: 1px solid rgba(255, 255, 255, 0.1); | ||
border-radius: 6px; | ||
bottom: 10px; | ||
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1); | ||
cursor: pointer; | ||
display: inline-flex; | ||
gap: 5px; | ||
left: 10px; | ||
padding: 10px 20px; | ||
position: fixed; | ||
text-decoration: none; | ||
transition: background-color 400ms, border-color 400ms; | ||
z-index: 10000; | ||
} | ||
|
||
#modal-content { | ||
text-align: center; | ||
position: relative; | ||
margin: 10% auto; | ||
padding: 20px; | ||
width: 80%; | ||
.meta-link:hover { | ||
background-color: rgba(255, 255, 255, 0.1); | ||
border: 1px solid rgba(255, 255, 255, 0.2); | ||
} | ||
|
||
#modal-image { | ||
max-width: 100%; | ||
max-height: 80vh; | ||
.meta-link > i, .meta-link > span { | ||
height: 20px; | ||
line-height: 20px; | ||
} | ||
|
||
#close-modal { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
color: white; | ||
font-size: 30px; | ||
cursor: pointer; | ||
.meta-link > span { | ||
color: white; | ||
font-family: "Rubik", sans-serif; | ||
font-weight: 500; | ||
} |