-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
86 lines (79 loc) · 1.79 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
async function pageTransition(data, done) {
const tl = gsap.timeline();
const currentNamespace = data.current.namespace;
const nextNamespace = data.next.namespace;
if (nextNamespace.includes("transition")) {
const selector = nextNamespace.includes("one")
? ".section-1"
: ".section-2";
tl.set(selector + " .section__text", {
opacity: 0,
});
tl.to(selector + " .section__image--container", {
width: "100%",
duration: 1,
});
tl.to(
selector + " .section__image",
{
aspectRatio: 2.8,
duration: 1,
onComplete: done,
},
"0"
);
tl.to(selector + " .section__text", { width: "0%" }, "0");
}
if (nextNamespace == "home") {
tl.to("#transition-one", {
opacity: 0,
duration: 0.6,
onComplete: done,
});
}
}
function contentAnimation(data) {
let tl = gsap.timeline();
if (data.next.namespace == "home") {
tl.from("#home .section__text", {
opacity: 0,
y: 40,
duration: 0.6,
});
tl.to(
"#home .section__image",
{
clipPath: "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",
duration: 0.3,
},
"-=0.2"
);
}
if (data.next.namespace.includes("transition")) {
tl.from("#transition-one .banner__text", {
opacity: 0,
duration: 1,
delay: data.current.container ? 1 : 0.5,
});
}
}
barba.init({
transitions: [
{
sync: true,
// name: "default-transition",
async leave(data) {
const done = this.async();
pageTransition(data, done);
console.log("leave", data);
},
async enter(data) {
console.log("enter", data);
contentAnimation(data);
},
async once(data) {
contentAnimation(data);
},
},
],
});