Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add mobile responsive CSS and animations. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ const purchase = document.querySelector(".purchase");
const description = document.querySelector(".info h3");
const sizes = document.querySelector(".sizes");

// Multiple event listener function for mobile + desktop events
const addMultipleEventListeners = (element, events, handler) => {
events.forEach(e => element.addEventListener(e, handler))
}
//Moving Animation Event
container.addEventListener("mousemove", (e) => {
let xAxis = (window.innerWidth / 2 - e.pageX) / 25;
let yAxis = (window.innerHeight / 2 - e.pageY) / 25;
addMultipleEventListeners(container, ['mousemove', 'touchmove'], e => {
let touch;
if (e.changedTouches) {
touch = e.changedTouches[0];
}
let xAxis = (window.innerWidth / 2 - (e.pageX || touch.pageX)) / 25;
let yAxis = (window.innerHeight / 2 - (e.pageY || touch.pageY)) / 25;
card.style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
});
//Animate In
container.addEventListener("mouseenter", (e) => {
addMultipleEventListeners(container, ['mouseenter', 'touchstart'], () => {
card.style.transition = "none";
//Popout
title.style.transform = "translateZ(150px)";
Expand All @@ -25,7 +33,7 @@ container.addEventListener("mouseenter", (e) => {
purchase.style.transform = "translateZ(75px)";
});
//Animate Out
container.addEventListener("mouseleave", (e) => {
addMultipleEventListeners(container, ['mouseleave', 'touchend'], () => {
card.style.transition = "all 0.5s ease";
card.style.transform = `rotateY(0deg) rotateX(0deg)`;
//Popback
Expand Down
33 changes: 33 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,36 @@ button.active {
border-radius: 30px;
font-weight: bolder;
}

@media(max-width: 768px) {
.container {
width: 100%;
}
.card {
padding: 0rem 1.2rem;
width: 90%;
height: fit-content;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
.sneaker {
width: 100%;
}
.sneaker img {
width: 100%;
}
.circle {
width: 62vw;
height: 32vh;
}
.sizes {
flex-wrap: wrap;
}
.sizes button {
margin-bottom: 1.5rem;
}
.purchase {
margin-top: 0.5rem;
margin-bottom: 1.5rem;
}
}