-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
112 lines (89 loc) · 3.19 KB
/
script.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const bars = document.querySelector(".bar"),
close = document.querySelector(".close"),
menu = document.querySelector(".menu");
bars.addEventListener("click", () => {
menu.classList.add("active");
gsap.from(".menu", {
opacity: 0,
duration: .3
})
gsap.from(".menu ul", {
opacity: 0,
x: -300
})
});
close.addEventListener("click", () => {
menu.classList.remove("active")
});
function animateContent(selector) {
selector.forEach((selector) => {
gsap.to(selector, {
y: 30,
duration: 0.1,
opacity: 1,
delay: 0.2,
stagger: 0.2,
ease: "power2.out",
});
});
}
function scrollTirggerAnimation(triggerSelector, boxSelectors) {
const timeline = gsap.timeline({
scrollTrigger: {
trigger: triggerSelector,
start: "top 50%",
end: "top 80%",
scrub: 1,
},
});
boxSelectors.forEach((boxSelector) => {
timeline.to(boxSelector, {
y: 0,
duration: 1,
opacity: 1,
});
})
}
function swipeAnimation(triggerSelector, boxSelectors) {
const timeline = gsap.timeline({
scrollTrigger: {
trigger: triggerSelector,
start: "top 50%",
end: "top 100%",
scrub: 3,
},
});
boxSelectors.forEach((boxSelector) => {
timeline.to(boxSelector, {
x: 0,
duration: 1,
opacity:1,
});
});
}
function galleryAnimation(triggerSelector, boxSelectors) {
const timeline = gsap.timeline({
scrollTrigger: {
trigger: triggerSelector,
start: "top 100%",
end: "bottom 100%",
scrub: 1,
},
});
boxSelectors.forEach((boxSelector) => {
timeline.to(boxSelector, {
y: 0,
opacity: 1,
duration: 1,
});
});
}
animateContent([".home .content h5, .home .content h1, .home .content p, .home .content .search"]);
scrollTirggerAnimation(".travel", [".travel .box1", ".travel .box2", ".travel .box3"]);
scrollTirggerAnimation(".feedback .container", [".feedback .label", ".feedback .heading", ".feedback .paragraph"]);
scrollTirggerAnimation(".article", [".article .label", ".article .heading"]);
swipeAnimation(".destinations", [".destinations .heading", ".destinations .content"])
swipeAnimation(".article", [".article .latest-article", ".article .box1", ".article .box2", ".article .box3", ".article .box4"])
galleryAnimation(".destinations .gallery", [".destinations .gallery .box1",".destinations .gallery .box2",".destinations .gallery .box3",".destinations .gallery .box4",".destinations .gallery .box5"])
galleryAnimation(".featured .gallery", [".featured .gallery .box1",".featured .gallery .box2",".featured .gallery .box3",".featured .gallery .box4"])
galleryAnimation(".feedback .voices", [".feedback .voices .box1",".feedback .voices .box2",".feedback .voices .box3",".feedback .voices .box4",".feedback .voices .box5",".feedback .voices .box6"])