mejoras estateticas v2.3
This commit is contained in:
+63
-9
@@ -9,9 +9,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
async function initApp() {
|
||||
initTheme();
|
||||
initHeroVideoSpeed();
|
||||
await loadIncludes();
|
||||
initModals();
|
||||
/*initBrujulaIDE();*/
|
||||
initAcademyCourses();
|
||||
initSolucionesFilters();
|
||||
initInsightsFeed();
|
||||
@@ -63,18 +63,31 @@ function highlightActiveNavLink() {
|
||||
const currentPath = window.location.pathname;
|
||||
const navLinks = document.querySelectorAll('.nav-link');
|
||||
|
||||
// 1. Limpiar estado activo previo
|
||||
navLinks.forEach(link => link.classList.remove('active'));
|
||||
|
||||
// 2. Evaluar cada enlace
|
||||
navLinks.forEach(link => {
|
||||
const href = link.getAttribute('href');
|
||||
if (!href) return;
|
||||
// Ignoramos enlaces vacíos o anclas "#"
|
||||
if (!href || href === '#') return;
|
||||
|
||||
// Comparación de página activa
|
||||
if (
|
||||
(currentPath === '/' || currentPath.endsWith('index.html')) && (href === '/' || href === 'index.html' || href === './') ||
|
||||
(currentPath.includes(href) && href !== '/' && href !== 'index.html')
|
||||
) {
|
||||
const isHome = (currentPath === '/' || currentPath.endsWith('index.html')) &&
|
||||
(href === '/' || href === 'index.html' || href === './');
|
||||
|
||||
const isCurrentPage = currentPath.includes(href) && href !== '/' && href !== 'index.html';
|
||||
|
||||
if (isHome || isCurrentPage) {
|
||||
link.classList.add('active');
|
||||
} else {
|
||||
link.classList.remove('active');
|
||||
|
||||
// Si este enlace está dentro de un submenú, marcar también al padre
|
||||
const parentDropdown = link.closest('.dropdown');
|
||||
if (parentDropdown) {
|
||||
const parentToggle = parentDropdown.querySelector('.dropdown-toggle');
|
||||
if (parentToggle) {
|
||||
parentToggle.classList.add('active');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1122,4 +1135,45 @@ function initCareersForm() {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/* ==========================================================================
|
||||
11. Video de Insights
|
||||
========================================================================== */
|
||||
function initHeroVideoSpeed() {
|
||||
const video = document.getElementById('hero-bg-video');
|
||||
if (!video) return;
|
||||
|
||||
const targetSpeed = 0.5; // 50% de la velocidad normal
|
||||
|
||||
// 1. Forzar mute por propiedad nativa JS (garantiza el autoplay sin bloqueo)
|
||||
video.muted = true;
|
||||
video.defaultMuted = true;
|
||||
video.playsInline = true;
|
||||
|
||||
const applySpeedAndPlay = () => {
|
||||
video.playbackRate = targetSpeed;
|
||||
|
||||
// Si quedó en pausa, disparar play explícito atrapando la promesa
|
||||
if (video.paused) {
|
||||
const playPromise = video.play();
|
||||
if (playPromise !== undefined) {
|
||||
playPromise.catch(err => {
|
||||
console.warn('El navegador requirió interacción previa:', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 2. Si el video ya está listo o ya empezó a correr
|
||||
if (video.readyState >= 2) {
|
||||
applySpeedAndPlay();
|
||||
} else {
|
||||
video.addEventListener('canplay', applySpeedAndPlay, { once: true });
|
||||
video.addEventListener('loadeddata', applySpeedAndPlay, { once: true });
|
||||
}
|
||||
|
||||
// 3. Garantizar que tras el loop o reanudación conserve la velocidad
|
||||
video.addEventListener('play', () => {
|
||||
video.playbackRate = targetSpeed;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user