so heres an Update on my Code: My Code now is not bad, the effect on Container works but the other ones don't do you have some Ideas? :) I want to select all Elements which have these classes.
//Movement Animation to happen
const card = document.querySelectorAll(".card");
const container = document.querySelectorAll(".container");
//Items
const title = document.querySelector(".title");
const cap = document.querySelector(".cap img");
const sizes = document.querySelector (".sizes");
const description = document.querySelector(".info h3");
const purchase = document.querySelector(".purchase button");
//Moving Animation Event
for (let i = 0; i < container.length; i++){
container[i].addEventListener("mousemove", (e) => {
let xAxis = (window.innerWidth / 3 - e.pageX) / 100;
let yAxis = (window.innerHeight / 2 - e.pageY) / 100;
card[i].style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
});
}
//Animate In
for (let i = 0; i < container.length; i++) {
container[i].addEventListener("mouseenter", (e) => {
card[i].style.transition = "none";
//PopOut
title[i].style.transform = "translateZ(150px)";
cap[i].style.transform = "translateZ(150px) rotateZ(-25deg)";
sizes[i].style.transform = "translateZ(100px)";
description[i].style.transform = "translateZ(125px)";
purchase[i].style.transform = "translateZ(75px)";
});}
//Animate Out
for (let i = 0; i < container.length; i++) {
container[i].addEventListener("mouseleave", (e) => {
card[i].style.transition = "all 0.5s ease";
card[i].style.transform = `rotateY(0deg) rotateX(0deg)`;
//PopBack
title[i].style.transform = "translateZ(0px)";
cap[i].style.transform = "translateZ(0px) rotateZ(0deg)";
sizes[i].style.transform = "translateZ(0px)";
description[i].style.transform = "translateZ(0px)";
purchase[i].style.transform = "translateZ(0px)";
});}