-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
85 lines (74 loc) · 2.56 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//efecto para el titulo
let docTitle = document.title;
window.addEventListener("blur",() =>{
document.title = "Regresa no te vayas :'(";
});
window.addEventListener("focus", () =>{
document.title =docTitle;
})
//hamburger
const bar = document.querySelector('#bar');
const nav = document.querySelector('.header_nav');
const cerrar = document.querySelector('#close');
if(bar){
bar.addEventListener('click',()=>{
nav.classList.add('active');
});
};
if(cerrar){
cerrar.addEventListener('click',()=>{
nav.classList.remove('active');
});
;}
//efecto type
function animacion(){
let textoAnimacion =[
['c','o','n','s','t','r','u','y','o',' ','p','á','g','i','n','a','s',' ','w','e','b'],
['s','o','y',' ','p','r','o','g','r','a','m','a','d','o','r'],
];
let letraContador = -1;
let nivelArray = 0;
const contenedorAnimaicon = document.querySelector('.cont_text_animation');
function pintarTexto(){
letraContador++;
contenedorAnimaicon.textContent += textoAnimacion[nivelArray][letraContador];
if(letraContador === textoAnimacion[nivelArray].length -1){
clearInterval(intervalo);
setTimeout(()=>{
intervalo = setInterval(()=>{
contenedorAnimaicon.textContent = '';
letraContador--;
textoAnimacion[nivelArray].pop();
textoAnimacion[nivelArray].forEach((elemento)=>{
contenedorAnimaicon.textContent += elemento;
});
if(letraContador < 0){
clearInterval(intervalo);
nivelArray++;
intervalo = setInterval(pintarTexto,150);
if(nivelArray > textoAnimacion.length -1){
clearInterval(intervalo);
nivelArray = 0;
animacion();
};
};
},150);
},1000);
};
};
let intervalo = setInterval(pintarTexto,150);
};
window.addEventListener("load",animacion);
//efecto de transicion
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
// console.log(entry)
if (entry.isIntersecting){
entry.target.classList.add('show');
} else{
entry.target.classList.remove('show');
}
});
});
const hiddenElements = document.querySelectorAll('.hidden');
hiddenElements.forEach((el) => observer.observe(el));