-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
70 lines (54 loc) · 1.95 KB
/
index.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
let back = document.querySelector(".wrapper");
// Soda can and Main background
let can = document.querySelector('.can');
let arr = ["100%","0.4%","50%"];
document.querySelector('.wrapper').addEventListener("click", myFunc);
// Fruit Backgrounds
let car1 = document.querySelector(".car-1");
let car2 = document.querySelector(".car-2");
let car3 = document.querySelector(".car-3");
let arr1 = ["125%","-150%","-150%"];
let arr2 = ["150%","-150%","0%"];
let arr3 = ["0%","-75%","0%"];
// Texts in background
let text1 = document.querySelector(".text1");
let text2 = document.querySelector(".text2");
let text3 = document.querySelector(".text3");
let txt1 = ["-100%","100%","-100%"];
let txt2 = ["-100%","100%","0%"];
let txt3 = ["-100%","100%","100%"];
// Mint leaves
let mint1 = document.querySelector("#minty1");
let mint2 = document.querySelector("#minty2");
let mintyArr1 = [
[270,60,"130deg"],
[30,50,"0deg"],
[270,450,"180deg"]
]
let mintyArr2 = [
[-120,470,"160deg"],
[150,440,"50deg"],
[-100,60,"-120deg"]
]
let i = 0;
function myFunc(event) {
back.style.backgroundPosition = `${arr[i]}`;
can.style.backgroundPosition = `center, ${arr[i]}`;
if(arr2[i] == '-150%'){
car2.style.transition = `all 0.3s step-end`;
} else{
car2.style.transition = `all 1s`;
}
//fruits transformation
car1.style.transform = `translate(0%,${arr1[i]})`;
car2.style.transform = `translate(0%,${arr2[i]})`;
car3.style.transform = `translate(0%,${arr3[i]})`;
//text transformation
text1.style.transform = `translateX(${txt1[i]})`;
text2.style.transform = `translateX(${txt2[i]})`;
text3.style.transform = `translateX(${txt3[i]})`;
//mint leaves transformation
mint1.style.transform = `translate(${mintyArr1[i][0]}px,${mintyArr1[i][1]}px) rotate(${mintyArr1[i][2]})`;
mint2.style.transform = `translate(${mintyArr2[i][0]}px,${mintyArr2[i][1]}px) rotate(${mintyArr2[i][2]})`;
i = (i + 1)%3;
}