Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NevroHelios committed Oct 27, 2023
2 parents d4fa5c4 + 8301eaf commit 507ebda
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 197 deletions.
8 changes: 6 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from flask import Flask, render_template, request, redirect, url_for, session
""" This is the app.py """

from flask import Flask, render_template

# Command to start the server
# flask run --debug --port 9420
Expand All @@ -9,9 +11,11 @@
# Create a route for the home page
@app.route('/')
def home():
""" This is the home function """

return render_template('index.html')


# run the app
if __name__ == "__main__":
app.run(debug=True)
app.run(debug=True)
25 changes: 24 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -31,4 +32,26 @@ <h1>Project<span style="color: rgb(175, 0, 250);">X</span></h1>
</section>
<script src="index.js"></script>
</body>
</html>
</html>
=======
<div id="image-track" data-mouse-down-at="0" data-prev-percentage="0">
<img class="image" src="https://images.unsplash.com/photo-1524781289445-ddf8f5695861?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80" draggable="false" />
<img class="image" src="https://images.unsplash.com/photo-1610194352361-4c81a6a8967e?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1674&q=80" draggable="false" />
<img class="image" src="https://images.unsplash.com/photo-1618202133208-2907bebba9e1?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80" draggable="false" />
<img class="image" src="https://images.unsplash.com/photo-1495805442109-bf1cf975750b?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80" draggable="false" />
<img class="image" src="https://images.unsplash.com/photo-1548021682-1720ed403a5b?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80" draggable="false" />
<img class="image" src="https://images.unsplash.com/photo-1496753480864-3e588e0269b3?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2134&q=80" draggable="false" />
<img class="image" src="https://images.unsplash.com/photo-1613346945084-35cccc812dd5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1759&q=80" draggable="false" />
<img class="image" src="https://images.unsplash.com/photo-1516681100942-77d8e7f9dd97?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80" draggable="false" />
</div>

<a id="source-link" class="meta-link" href="https://camillemormal.com" target="_blank">
<i class="fa-solid fa-link"></i>
<span>Source</span>
</a>

<a id="yt-link" class="meta-link" href="https://youtu.be/PkADl0HubMY" target="_blank">
<i class="fa-brands fa-youtube"></i>
<span>7 min tutorial</span>
</a>
>>>>>>> 8301eafceb2ea8af6fd756f6e4b03ebe01e5e46a
149 changes: 32 additions & 117 deletions index.js
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]);
131 changes: 54 additions & 77 deletions style.css
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;
}

0 comments on commit 507ebda

Please sign in to comment.