-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript-about.js
146 lines (124 loc) · 4.68 KB
/
script-about.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/**
Thanks again, CodePen!
*/
var ITEManimate = ({
start: 0,
bezier: function(p0, p1, p2, p3) {
return ITEManimate.polyBez([p0, p1], [p2, p3]);
},
polyBez: function(p1, p2) {
var A = [null, null],
B = [null, null],
C = [null, null],
bezCoOrd = function(t, ax) {
C[ax] = 3 * p1[ax], B[ax] = 3 * (p2[ax] - p1[ax]) - C[ax], A[ax] = 1 - C[ax] - B[ax];
return t * (C[ax] + t * (B[ax] + t * A[ax]));
},
xDeriv = function(t) {
return C[0] + t * (2 * B[0] + 3 * A[0] * t);
},
xForT = function(t) {
var x = t,
i = 0,
z;
while (++i < 14) {
z = bezCoOrd(x, 0) - t;
if (Math.abs(z) < 1e-3) break;
x -= z / xDeriv(x);
}
return x;
};
return function(t) {
return bezCoOrd(xForT(t), 1);
}
}
});
//CUSTOM JS CODE
(function($) {
'use strict';
//VIEWPORT
var w = $(window);
//ANIMATION
var animationTrigger = $('.trigger');
var sceneContainer = $('.slide-wrapper');
var smallCircles = $('.small-circle');
var portfolioContainer = $('.portfolio-wrapper');
var main = {
init: function() {
var self = this;
//GSAP ANIMATE
main.animate();
},
//GSAP ANIMATION
animate: function() {
//OPEN
function openAnimation() {
TweenMax.to(sceneContainer, 0.8, {
height: "100%",
ease: ITEManimate.bezier(0.930, 0.035, 0.350, 0.815),
top: "0%",
ease: ITEManimate.bezier(0.930, 0.035, 0.350, 0.815),
width: "100%",
ease: ITEManimate.bezier(0.930, 0.035, 0.350, 0.815),
left: "0%",
ease: ITEManimate.bezier(0.930, 0.035, 0.350, 0.815),
onComplete: function() {
console.log(sceneContainer);
TweenMax.to(portfolioContainer, 1.8, {
width: "100%",
ease: ITEManimate.bezier(0.930, 0.035, 0.350, 0.815),
top: "30%",
ease: ITEManimate.bezier(0.930, 0.035, 0.350, 0.815)
})
TweenMax.to(sceneContainer, 0.8, {
top: "-70%",
ease: ITEManimate.bezier(0.930, 0.035, 0.350, 0.815),
})
}
});
TweenMax.to(smallCircles, 0.4, {
scale: "0",
ease: ITEManimate.bezier(0.930, 0.035, 0.350, 0.815),
});
}
//CLOSE
function closeAnimation() {
TweenMax.to(portfolioContainer, 1.2, {
top: "100%",
ease: ITEManimate.bezier(0.815, 0.035, 0.350, 0.930),
width: "100%",
ease: ITEManimate.bezier(0.815, 0.035, 0.350, 0.930),
onComplete: function() {
TweenMax.to(sceneContainer, 0.8, {
height: "90%",
ease: ITEManimate.bezier(0.815, 0.035, 0.350, 0.930),
top: "5%",
ease: ITEManimate.bezier(0.815, 0.035, 0.350, 0.930),
width: "90%",
ease: ITEManimate.bezier(0.815, 0.035, 0.350, 0.930),
left: "5%",
ease: ITEManimate.bezier(0.815, 0.035, 0.350, 0.930),
onComplete: function() {
TweenMax.to(smallCircles, 0.4, {
scale: "1",
ease: ITEManimate.bezier(0.815, 0.035, 0.350, 0.930),
});
}
});
}
})
}
animationTrigger.click(function() {
if ($(this).attr('data-toggle') == 'closed') {
$(this).attr('data-toggle', 'opened');
openAnimation();
} else if ($(this).attr('data-toggle', 'opened')) {
$(this).attr('data-toggle', 'closed');
closeAnimation();
}
});
}
};
$(window).resize(function() {});
return main.init();
}($));