| Server IP : 172.67.191.97 / Your IP : 104.23.243.196 Web Server : Apache/2.4.63 (Ubuntu) System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.4.5 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/congresofce2/templates/g5_helium/custom/js/ |
Upload File : |
document.addEventListener("DOMContentLoaded", function () {
/* =========================================
LENIS (SCROLL SUAVE)
========================================= */
window.lenis = new Lenis({
duration: 1.8,
lerp: 0.08,
smoothWheel: true,
smoothTouch: false,
wheelMultiplier: 1
});
function raf(time) {
window.lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
/* =========================================
ELEMENTOS
========================================= */
const sections = document.querySelectorAll(
"#inicio, #cronograma, #ponencias, #memorias, #contacto, #ejes"
);
const navLinks = document.querySelectorAll(".g-menu-item-container");
const header = document.querySelector("#g-navigation");
/* =========================================
OFFSET DIN�MICO (?? FIX M�VIL REAL)
========================================= */
function getOffset() {
const isMobile = window.innerWidth <= 768;
const headerHeight = header
? header.getBoundingClientRect().height
: 120;
// m�vil: m�s estable y evita �tapado�
if (isMobile) {
return -(headerHeight + 20);
}
// desktop
return -(header.offsetHeight + 10);
}
/* =========================================
MENU ACTIVO
========================================= */
function activarMenu() {
let maxVisible = 0;
let current = null;
sections.forEach(section => {
const rect = section.getBoundingClientRect();
const visibleHeight =
Math.min(rect.bottom, window.innerHeight) -
Math.max(rect.top, 0);
if (visibleHeight > maxVisible) {
maxVisible = visibleHeight;
current = section.id;
}
});
navLinks.forEach(link => {
link.classList.remove("menu-activo");
const href = link.getAttribute("href");
// secci�n activa
if (current && href && href.includes("#" + current)) {
link.classList.add("menu-activo");
}
// inicio (home Joomla/Gantry)
if (
window.scrollY < 120 &&
href &&
href.includes("option=com_gantry5")
) {
link.classList.add("menu-activo");
}
});
}
window.addEventListener("scroll", activarMenu, { passive: true });
activarMenu();
/* =========================================
CLICK MENU + LENIS
========================================= */
navLinks.forEach(link => {
link.addEventListener("click", function (e) {
const href = this.getAttribute("href");
if (href && href.includes("#")) {
const id = href.split("#")[1];
const target = document.getElementById(id);
if (target) {
e.preventDefault();
// ?? IMPORTANTE: espera a que cierre men� m�vil (fix real)
setTimeout(() => {
window.lenis.scrollTo(target, {
offset: getOffset(),
duration: 1.8
});
}, 50);
}
}
});
});
});