Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
88 lines (78 loc) · 3.42 KB
/
Copy pathscript.js
File metadata and controls
88 lines (78 loc) · 3.42 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
document.addEventListener("DOMContentLoaded", () => {
// 1. EFECTO DE MÁQUINA DE ESCRIBIR EN EL TÍTULO
const titulo = document.querySelector('.hero h1');
if (titulo) {
const textoOriginal = titulo.textContent;
titulo.textContent = ''; // Vaciamos el texto inicial
let i = 0;
function maquinaDeEscribir() {
if (i < textoOriginal.length) {
titulo.textContent += textoOriginal.charAt(i);
i++;
setTimeout(maquinaDeEscribir, 100); // Velocidad de las teclas (100ms)
}
}
setTimeout(maquinaDeEscribir, 300); // Espera un poquito antes de empezar
}
// 2. APARICIÓN EN CASCADA PARA LAS TARJETAS DE PROYECTOS
const tarjetas = document.querySelectorAll('.card');
const observadorTarjetas = new IntersectionObserver((entradas) => {
entradas.forEach(entrada => {
if (entrada.isIntersecting) {
entrada.target.style.opacity = "1";
entrada.target.style.transform = "translateY(0)";
observadorTarjetas.unobserve(entrada.target); // Deja de animar una vez que ya apareció
}
});
}, { threshold: 0.1 });
tarjetas.forEach((tarjeta, index) => {
tarjeta.style.opacity = "0";
tarjeta.style.transform = "translateY(50px)";
// Añade un retraso multiplicando el índice (0s, 0.2s, 0.4s...)
tarjeta.style.transition = `all 0.6s ease-out ${index * 0.2}s`;
observadorTarjetas.observe(tarjeta);
});
// 3. ANIMACIÓN "POP" PARA LAS ETIQUETAS DE HABILIDADES
const skills = document.querySelectorAll('.skill-tag');
const observadorSkills = new IntersectionObserver((entradas) => {
entradas.forEach(entrada => {
if (entrada.isIntersecting) {
entrada.target.style.opacity = "1";
entrada.target.style.transform = "scale(1)";
observadorSkills.unobserve(entrada.target);
}
});
}, { threshold: 0.1 });
skills.forEach((skill, index) => {
skill.style.opacity = "0";
skill.style.transform = "scale(0.8)"; // Empieza un poco más pequeña
// Efecto dominó más rápido para las habilidades
skill.style.transition = `all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) ${index * 0.1}s`;
observadorSkills.observe(skill);
});
// 4. SOMBRA DINÁMICA EN EL MENÚ DE NAVEGACIÓN
const header = document.querySelector('header');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
header.style.boxShadow = "0 4px 15px rgba(0, 0, 0, 0.2)";
header.style.transition = "box-shadow 0.3s ease";
} else {
header.style.boxShadow = "0 2px 4px rgba(0,0,0,0.1)";
}
});
// 5. DESPLAZAMIENTO SUAVE PARA LOS ENLACES DEL MENÚ
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault(); // Evita el salto brusco normal
const targetId = this.getAttribute('href');
if(targetId === '#') return;
const targetElement = document.querySelector(targetId);
if(targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
});