-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
55 lines (51 loc) · 1.64 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
45
46
47
48
49
50
51
52
53
54
55
const tl = gsap.timeline({
defaults: { duration: 0.35, ease: "Power2.easeOut" },
});
const home = document.querySelector(".home");
const notifications = document.querySelector(".notifications");
const messages = document.querySelector(".messages");
gsap.set(".feather", { scale: 0, transformOrigin: "center" });
home.addEventListener("click", () => {
gsap.fromTo(".home-svg", { scale: 1 }, { scale: 0.9, yoyo: true, repeat: 1 });
gsap.fromTo(
".feather",
{ y: -5, scale: 0 },
{ y: 20, scale: 1.5, duration: 1, stagger: 0.2 }
);
gsap.fromTo(".right-feather", { x: 0 }, { x: 5 });
});
//Notification animation
//Setting the transform origin
gsap.set(".bell", { transformOrigin: "top center" });
gsap.set(".ringer", { transformOrigin: "top center" });
gsap.set(".wave", { opacity: 0, transformOrigin: "bottom" });
notifications.addEventListener("click", () => {
gsap.fromTo(
".bell",
{ rotation: -5 },
{ rotation: 0, duration: 2, ease: "elastic.out(5, 0.2)" }
);
gsap.fromTo(
".ringer",
{ rotation: -3, x: 0.5 },
{ rotation: 0, x: 0, duration: 1, ease: "elastic.out(5, 0.2)" }
);
gsap.fromTo(
".wave",
{ scale: 0, opacity: 1 },
{ scale: 1.3, opacity: 0, duration: 1 }
);
});
//Messages
gsap.set(".flap", { transformOrigin: "top" });
messages.addEventListener("click", () => {
tl.fromTo(".messages-svg", { scale: 1 }, { scale: 0.9 });
tl.fromTo(".flap", { scale: 1 }, { scale: -1 }, "<50%");
tl.fromTo(".messages-svg", { scale: 0.9 }, { scale: 1 }, "<50%");
tl.fromTo(
".note",
{ y: 0, opacity: 1 },
{ y: -40, opacity: 0, duration: 0.75 }
);
tl.to(".flap", { scale: 1 }, "<50%");
});