-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
225 lines (182 loc) · 7.03 KB
/
Copy pathscript.js
File metadata and controls
225 lines (182 loc) · 7.03 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
const hamburger = document.getElementById('hamburger');
const mobileMenu = document.getElementById('mobileMenu');
if (hamburger && mobileMenu) {
hamburger.addEventListener('click', () => {
mobileMenu.classList.toggle('show');
});
}
class ProjectCarousel {
constructor() {
this.track = document.getElementById('carouselTrack');
this.cards = document.querySelectorAll('.project-card');
this.prevBtn = document.getElementById('prevBtn');
this.nextBtn = document.getElementById('nextBtn');
this.indicatorsContainer = document.getElementById('indicators');
this.currentIndex = 0;
this.cardsPerView = this.getCardsPerView();
this.totalSlides = Math.ceil(this.cards.length / this.cardsPerView);
this.init();
}
getCardsPerView() {
if (window.innerWidth <= 480) return 1;
if (window.innerWidth <= 768) return 2;
return 3;
}
init() {
this.createIndicators();
this.updateCarousel();
this.addEventListeners();
}
createIndicators() {
this.indicatorsContainer.innerHTML = '';
for (let i = 0; i < this.totalSlides; i++) {
const indicator = document.createElement('div');
indicator.className = `indicator ${i === 0 ? 'active' : ''}`;
indicator.addEventListener('click', () => this.goToSlide(i));
this.indicatorsContainer.appendChild(indicator);
}
}
updateCarousel() {
const translateX = -(this.currentIndex * 100);
this.track.style.transform = `translateX(${translateX}%)`;
// Actualizar clases active
this.cards.forEach((card, index) => {
const isVisible = index >= this.currentIndex * this.cardsPerView &&
index < (this.currentIndex + 1) * this.cardsPerView;
card.classList.toggle('active', isVisible);
});
// Actualizar indicadores
document.querySelectorAll('.indicator').forEach((indicator, index) => {
indicator.classList.toggle('active', index === this.currentIndex);
});
}
nextSlide() {
this.currentIndex = (this.currentIndex + 1) % this.totalSlides;
this.updateCarousel();
}
prevSlide() {
this.currentIndex = this.currentIndex === 0 ? this.totalSlides - 1 : this.currentIndex - 1;
this.updateCarousel();
}
goToSlide(index) {
this.currentIndex = index;
this.updateCarousel();
}
addEventListeners() {
this.nextBtn.addEventListener('click', () => this.nextSlide());
this.prevBtn.addEventListener('click', () => this.prevSlide());
// Auto-play (opcional)
// setInterval(() => this.nextSlide(), 5000);
// Responsive
window.addEventListener('resize', () => {
const newCardsPerView = this.getCardsPerView();
if (newCardsPerView !== this.cardsPerView) {
this.cardsPerView = newCardsPerView;
this.totalSlides = Math.ceil(this.cards.length / this.cardsPerView);
this.currentIndex = 0;
this.createIndicators();
this.updateCarousel();
}
});
// Touch support para móviles
let startX = 0;
let endX = 0;
this.track.addEventListener('touchstart', (e) => {
startX = e.touches[0].clientX;
});
this.track.addEventListener('touchend', (e) => {
endX = e.changedTouches[0].clientX;
const diff = startX - endX;
if (Math.abs(diff) > 50) {
if (diff > 0) {
this.nextSlide();
} else {
this.prevSlide();
}
}
});
}
}
// Inicializar el carrusel solo si existe en la página
document.addEventListener('DOMContentLoaded', () => {
if (document.getElementById('carouselTrack')) {
new ProjectCarousel();
}
});
// Simulación de envío de formulario de solicitud de CV
// document.addEventListener('DOMContentLoaded', function() {
// var form = document.getElementById('formSolicitarCV');
// if (form) {
// form.addEventListener('submit', function(e) {
// e.preventDefault();
// document.getElementById('cvFormMsg').innerHTML =
// '<div class="alert alert-success">¡Solicitud enviada! Te contactaré pronto.</div>';
// form.reset();
// });
// }
// });
/* =========================================================
FUNCIONES PARA EL MODAL DE VIDEO (FULLSCREEN)
========================================================= */
function openVideoModal(videoSrc) {
const modal = document.getElementById('videoModal');
const videoPlayer = document.getElementById('modalVideoPlayer');
const videoSource = document.getElementById('modalVideoSource');
if (modal && videoPlayer && videoSource) {
videoSource.src = videoSrc;
videoPlayer.load(); // Cargar la nueva ruta
modal.classList.add('active');
videoPlayer.play();
// Bloquear scroll del body
document.body.style.overflow = 'hidden';
}
}
function closeVideoModal() {
const modal = document.getElementById('videoModal');
const videoPlayer = document.getElementById('modalVideoPlayer');
if (modal && videoPlayer) {
videoPlayer.pause();
modal.classList.remove('active');
// Restaurar scroll del body
document.body.style.overflow = 'auto';
}
}
// Cerrar modal al hacer clic fuera del video
window.onclick = function (event) {
const modal = document.getElementById('videoModal');
if (event.target == modal) {
closeVideoModal();
}
}
/* =========================================================
ANIMACIÓN DE MARCA PERSONAL (degnisDev)
========================================================= */
document.addEventListener('DOMContentLoaded', () => {
const brandContainer = document.getElementById('brand-typing');
if (!brandContainer) return;
const brandName = "degnisDev";
brandContainer.innerHTML = ''; // Limpiar
brandName.split('').forEach((char, index) => {
const span = document.createElement('span');
span.textContent = char;
span.className = 'brand-char';
brandContainer.appendChild(span);
setTimeout(() => {
span.classList.add('active');
}, 800 + (index * 120));
});
});
function toggleStack(button) {
// Buscamos el div del stack que está justo después del botón
const stack = button.nextElementSibling;
if (stack.classList.contains('d-none')) {
stack.classList.remove('d-none');
button.innerHTML = '<i class="bi bi-code-slash me-1"></i> Ocultar Stack';
// Cambiamos el color del botón para que resalte que está activo
button.classList.replace('btn-outline-dark', 'btn-dark');
} else {
stack.classList.add('d-none');
button.innerHTML = '<i class="bi bi-code-slash me-1"></i> Ver Stack';
button.classList.replace('btn-dark', 'btn-outline-dark');
}
}