-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
149 lines (128 loc) · 4.7 KB
/
Copy pathscript.js
File metadata and controls
149 lines (128 loc) · 4.7 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
138
139
140
141
142
143
144
145
146
147
148
149
// Navegación suave
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Animación del header al hacer scroll
let lastScroll = 0;
const header = document.querySelector('.header');
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
if (currentScroll <= 0) {
header.classList.remove('hidden');
return;
}
if (currentScroll > lastScroll && !header.classList.contains('hidden')) {
header.classList.add('hidden');
} else if (currentScroll < lastScroll && header.classList.contains('hidden')) {
header.classList.remove('hidden');
}
lastScroll = currentScroll;
});
// Animación de elementos al hacer scroll
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, observerOptions);
document.querySelectorAll('.beneficio, .tech-item, .estadistica').forEach(el => {
el.classList.add('fade-in');
observer.observe(el);
});
// Animación de números en estadísticas
function animateValue(obj, start, end, duration) {
let startTimestamp = null;
const step = (timestamp) => {
if (!startTimestamp) startTimestamp = timestamp;
const progress = Math.min((timestamp - startTimestamp) / duration, 1);
obj.innerHTML = Math.floor(progress * (end - start) + start) + '%';
if (progress < 1) {
window.requestAnimationFrame(step);
}
};
window.requestAnimationFrame(step);
}
// Animar números cuando son visibles
const numberObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const target = entry.target;
const endValue = parseInt(target.getAttribute('data-value'));
animateValue(target, 0, endValue, 2000);
numberObserver.unobserve(target);
}
});
}, observerOptions);
document.querySelectorAll('.estadistica h3').forEach(el => {
const value = parseInt(el.textContent);
el.setAttribute('data-value', value);
numberObserver.observe(el);
});
// Efecto de hover en tarjetas
document.querySelectorAll('.beneficio, .tech-item').forEach(card => {
card.addEventListener('mouseover', () => {
card.style.transform = 'translateY(-5px)';
card.style.boxShadow = '0 8px 15px rgba(0, 0, 0, 0.1)';
});
card.addEventListener('mouseout', () => {
card.style.transform = 'translateY(0)';
card.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)';
});
});
// Animación de iconos
document.querySelectorAll('.beneficio i, .tech-item i').forEach(icon => {
icon.addEventListener('mouseover', () => {
icon.style.transform = 'scale(1.1)';
icon.style.color = '#3498DB';
});
icon.addEventListener('mouseout', () => {
icon.style.transform = 'scale(1)';
icon.style.color = '#2C3E50';
});
});
// Manejo del formulario de contacto
const contactForm = document.getElementById('contact-form');
if (contactForm) {
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
const submitButton = contactForm.querySelector('button[type="submit"]');
const originalText = submitButton.innerHTML;
submitButton.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Enviando...';
submitButton.disabled = true;
// Simulación de envío
setTimeout(() => {
submitButton.innerHTML = '<i class="fas fa-check"></i> ¡Enviado!';
contactForm.reset();
setTimeout(() => {
submitButton.innerHTML = originalText;
submitButton.disabled = false;
}, 2000);
}, 1500);
});
}
// Efecto parallax en el hero
const hero = document.querySelector('.hero');
if (hero) {
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
hero.style.backgroundPositionY = `${scrolled * 0.5}px`;
});
}
// Prevenir el scroll horizontal
document.body.style.overflowX = 'hidden';