-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
146 lines (121 loc) · 3.86 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
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
$('.course').width($('.marquee-left1').width()); // For the marquees
// Make all dropdown options the widest size
$(document).ready(function() {
$(".dropdown-items").css({
'width': ($(".dropdown-button").width() + 'px')
});
});
// Pivot courses when not on mobile with vanilla-tilt.js
if (!(window.matchMedia("only screen and (max-width: 750px)").matches)) {
VanillaTilt.init(document.querySelectorAll(".course"), {
max: 7,
speed: 300,
glare: true,
"max-glare": 0.4
});
}
gsap.registerPlugin("ScrollTrigger");
// Fade the chevron
gsap.to(".arrow", {
opacity: 0,
scrollTrigger: {
trigger: ".arrow",
start: "top center+=10%",
end: "top center-=10%",
scrub: 0.4
}
})
// Show each tool
const tools = gsap.utils.toArray('.tool');
tools.forEach(tool => {
gsap.to(tool, {
scrollTrigger: {
trigger: tool,
start: "top center+=5%",
scrub: 0.4,
toggleClass: {targets: tool, className: "tool-seen"}
}
})
});
// Flip the flap
var toolTimeline = gsap.timeline();
toolTimeline.to(".flap", { rotationX: 180, })
ScrollTrigger.create({
trigger: ".tools",
animation: toolTimeline,
start: "top center+=15%",
end: "top center-=15%",
scrub: 0.4
})
// Unite the circles
gsap.registerPlugin(MotionPathPlugin);
var redCircleTimeline = gsap.timeline();
var blueCircleTimeline = gsap.timeline();
var greenCircleTimeline = gsap.timeline();
gsap.set("#red-circle", {xPercent: -50, yPercent: -50, transformOrigin: "50% 50%"});
gsap.set("#blue-circle", {xPercent: -50, yPercent: -50, transformOrigin: "50% 50%"});
gsap.set("#green-circle", {xPercent: -50, yPercent: -50, transformOrigin: "50% 50%"});
redCircleTimeline.to("#red-circle", {motionPath: {path: "#red-path", align: "#red-path", end: 0.5} });
blueCircleTimeline.to("#blue-circle", {motionPath: {path: "#blue-path", align: "#blue-path", end: 0.5} });
greenCircleTimeline.to("#green-circle", {motionPath: {path: "#green-path", align: "#green-path", end: 0.5} });
ScrollTrigger.create({
trigger: ".looking-for",
animation: redCircleTimeline,
start: "top center+=15%",
end: "top center-=15%",
scrub: 0.4
})
ScrollTrigger.create({
trigger: ".looking-for",
animation: blueCircleTimeline,
start: "top center+=15%",
end: "top center-=15%",
scrub: 0.4
})
ScrollTrigger.create({
trigger: ".looking-for",
animation: greenCircleTimeline,
start: "top center+=15%",
end: "top center-=15%",
scrub: 0.4
})
// Copy email to clipboard
function copyToClipboard() {
var copyText = document.querySelector("#email-address");
copyText.value = "[email protected]";
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
document.querySelector(".copied").classList.add("click");
}
function copyToClipboard2() {
var copyText = document.querySelector("#email-address");
copyText.value = "[email protected]";
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
document.querySelector(".copied2").classList.add("click");
}
document.querySelector("#email-link").addEventListener("click", copyToClipboard);
document.querySelector("#email-footer-link").addEventListener("click", copyToClipboard2);
// Fade the logo link
gsap.to(".logo-link", {
opacity: 1,
scrollTrigger: {
trigger: ".arrow",
start: "top top+=10%",
end: "top top",
scrub: 0.2
}
})
// Recalculate logo position on resize and reload if max section width reached
function shiftLogoLink() {
if (document.querySelector(".programmer").offsetWidth >= 2250) {
var rightPadding = (window.innerWidth - 2250) / 2;
document.querySelector(".logo-link").style.right = rightPadding.toString() + "px";
} else {
document.querySelector(".logo-link").style.right = "10vw";
}
}
window.addEventListener('resize', shiftLogoLink);
window.addEventListener('load', shiftLogoLink);