From 663a10f2d2eadaa9b71f19be1364bf71bb7eb60f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Oct 2026 13:14:55 -0600 Subject: [PATCH] =?UTF-8?q?fix(padres):=20enfocar=20y=20hacer=20scroll=20s?= =?UTF-8?q?uave=20al=20contenido=20y=20men=C3=BA=20en=20m=C3=B3vil=20en=20?= =?UTF-8?q?vez=20de=20saltar=20al=20inicio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/app.js | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 509b0e5..aa2e6bb 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -2611,6 +2611,17 @@ async function loadParentDashboard() { renderParentDashboardView(); } +function smoothScrollToElement(el, offset = 65) { + if (!el) return; + const rect = el.getBoundingClientRect(); + const currentY = window.pageYOffset || window.scrollY || document.documentElement.scrollTop || 0; + const targetY = currentY + rect.top - offset; + window.scrollTo({ + top: Math.max(0, targetY), + behavior: 'smooth' + }); +} + function renderParentDashboardView() { const bannerNoHijos = document.getElementById('parentNoChildrenBanner'); const sectionHijos = document.getElementById('parentChildrenSection'); @@ -2682,9 +2693,9 @@ function renderParentDashboardView() { } if (activeView) { - openParentSubView(activeView); + openParentSubView(activeView, false); } else { - closeParentSubView(); + closeParentSubView(false); } } @@ -2698,7 +2709,7 @@ function selectParentChild(childId) { } } -function openParentSubView(viewKey) { +function openParentSubView(viewKey, shouldScroll = true) { try { localStorage.setItem('recreopay_active_parent_subview', viewKey); } catch (e) {} @@ -2777,14 +2788,19 @@ function openParentSubView(viewKey) { loadActiveChildHistory(currentParentChild.id); } - window.scrollTo({ top: 0, behavior: 'smooth' }); + if (!isDesktop && targetEl && shouldScroll) { + setTimeout(() => { + smoothScrollToElement(targetEl, 65); + }, 60); + } + if (window.sounds) window.sounds.playTap(); } -function closeParentSubView() { +function closeParentSubView(shouldScroll = true) { const isDesktop = window.innerWidth >= 860; if (isDesktop) { - openParentSubView('resumen'); + openParentSubView('resumen', false); return; } @@ -2813,7 +2829,12 @@ function closeParentSubView() { box.classList.remove('active'); }); - window.scrollTo({ top: 0, behavior: 'smooth' }); + if (!isDesktop && sidebar && shouldScroll) { + setTimeout(() => { + smoothScrollToElement(sidebar, 65); + }, 60); + } + if (window.sounds) window.sounds.playTap(); }