-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (38 loc) · 1.48 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Movement animation
const card = document.querySelector('.card');
const container = document.querySelector('.container');
//Items
const title = document.querySelector('.title');
const sneaker = document.querySelector('.sneaker img');
const purchase = document.querySelector('.purchase button');
const description = document.querySelector('.info h3');
const sizes = document.querySelector('.sizes');
// Moving animation Event
container.addEventListener('mousemove', (e) => {
let xAxis = (window.innerWidth / 2 - e.pageX) / 15
let yAxis = (window.innerHeight / 2 - e.pageY) / 15
card.style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
});
// Animate in
container.addEventListener("mouseenter", e => {
setTimeout(() => {
card.style.transition = 'none';
}, 500);
//Popout
title.style.transform = 'translateZ(150px)'
sneaker.style.transform = 'translateZ(200px) rotateZ(-45deg)'
description.style.transform = 'translateZ(125px)'
sizes.style.transform = 'translateZ(100px)'
purchase.style.transform = 'translateZ(75px)'
})
// Animate out
container.addEventListener("mouseleave", _ => {
card.style.transition = 'all 0.5s ease';
card.style.transform = `rotateY(0deg) rotateX(0deg)`
//Popin
title.style.transform = 'translateZ(0px)'
sneaker.style.transform = 'translateZ(0px) rotateZ(0)'
description.style.transform = 'translateZ(0px)'
sizes.style.transform = 'translateZ(0px)'
purchase.style.transform = 'translateZ(0px)'
})