-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
137 lines (113 loc) · 3.24 KB
/
script.js
File metadata and controls
137 lines (113 loc) · 3.24 KB
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
// ScrollTrigger animations
function hide(elem) {
gsap.set(elem, {autoAlpha: 0});
}
document.addEventListener("DOMContentLoaded", function() {
gsap.registerPlugin(ScrollTrigger);
gsap.utils.toArray(".gs_reveal").forEach(function(elem) {
hide(elem); // assure that the element is hidden when scrolled into view
ScrollTrigger.create({
trigger: elem,
onEnter: function() { animateFrom(elem) },
onEnterBack: function() { animateFrom(elem, -1) },
onLeave: function() { hide(elem) } // assure that the element is hidden when scrolled into view
});
});
});
// ScrollTrigger animations
function animateFrom(elem, direction) {
direction = direction || 1;
var x = 0,
y = direction * 100;
if(elem.classList.contains("gs_reveal_fromLeft")) {
x = -100;
y = 0;
} else if (elem.classList.contains("gs_reveal_fromRight")) {
x = 100;
y = 0;
}
elem.style.transform = "translate(" + x + "px, " + y + "px)";
elem.style.opacity = "0";
gsap.fromTo(elem, {x: x, y: y, autoAlpha: 0}, {
duration: 1.25,
x: 0,
y: 0,
autoAlpha: 1,
ease: "expo",
overwrite: "auto"
});
}
// Spotlight effect
document.getElementById("cards").onmousemove = e => {
for(const card of document.getElementsByClassName("card")) {
const rect = card.getBoundingClientRect(),
x = e.clientX - rect.left,
y = e.clientY - rect.top;
card.style.setProperty("--mouse-x", `${x}px`);
card.style.setProperty("--mouse-y", `${y}px`);
};
}
// Theme switcher
const root = document.querySelector(":root"),
inputs = document.querySelectorAll("input[name='theme']");
const theme = localStorage.getItem("theme-color");
const updateRoot = value => root.style.setProperty("--theme-color", `var(--${value})`);
for(const input of inputs) {
if(theme && input.value === theme) {
input.checked = true;
updateRoot(theme);
}
input.onchange = e => {
updateRoot(e.target.value);
localStorage.setItem("theme-color", e.target.value);
}
}
/* MOBILE */
function NewTabigm() {
window.open(
"https://instagram.com/sanxti","_self");
}
function NewTabgitm() {
window.open(
"https://github.com/santihdzs","_self");
}
function NewTabytm() {
window.open(
"https://youtube.com/c/SantiHdzs","_self");
}
function NewTabscm() {
window.open(
"https://www.snapchat.com/add/santihdzs?share_id=Eeg1tvp3SBaSz7kvjckZTg&locale=en_MX","_self");
}
function NewTabspm() {
window.open(
"https://open.spotify.com/user/santihs-mx?si=e8835d63503648f6","_self");
}
$(".card1").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
$(".card2").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
$(".card3").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
$(".card4").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
$(".card5").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
$(".card6").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});
$(".card7").click(function() {
window.location = $(this).find("a").attr("href");
return false;
});