-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
72 lines (65 loc) · 1.88 KB
/
app.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
function animateFrom(elem, direction) {
direction = direction || 1;
var x = 0,
y = direction * 100;
if (elem.classList.contains("saleIzquierda")) {
x = -100;
y = 0;
} else if (elem.classList.contains("saleDerecha")) {
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"
});
}
function hide(elem) {
gsap.set(elem, { autoAlpha: 0 });
}
document.addEventListener("DOMContentLoaded", function () {
gsap.registerPlugin(ScrollTrigger);
gsap.utils.toArray(".seRevela").forEach(function (elem) {
hide(elem); // assure that the element is hidden when scrolled into view
ScrollTrigger.create({
trigger: elem,
//markers: {startColor: "black", endColor: "black", fontSize: "18px", fontWeight: "bold", indent: 20},
onEnter: function () { animateFrom(elem) },
onEnterBack: function () { animateFrom(elem, -1) },
onLeave: function () { hide(elem) } // assure that the element is hidden when scrolled into view
});
});
});
var scrollPosition = window.scrollY;
var arrow = document.getElementById('arrow');
window.addEventListener('scroll', function() {
scrollPosition = window.scrollY;
if (scrollPosition >= 340) {
arrow.classList.add('opacity-100');
} else {
arrow.classList.remove('opacity-100');
arrow.classList.add('opacity-0');
}
});
new TypeIt("#wemeText", {
speed: 50,
waitUntilVisible: true
})
.type("Welcome!")
.exec(async () => {
//-- Return a promise that resolves after something happens.
await new Promise((resolve, reject) => {
setTimeout(() => {
return resolve();
}, 2000);
});
})
.delete(8)
.type("Hi, I am Cristian, FullStack Dev.")
.go();