fix(padres): enfocar y hacer scroll suave al contenido y menú en móvil en vez de saltar al inicio
This commit is contained in:
+28
-7
@@ -2611,6 +2611,17 @@ async function loadParentDashboard() {
|
|||||||
renderParentDashboardView();
|
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() {
|
function renderParentDashboardView() {
|
||||||
const bannerNoHijos = document.getElementById('parentNoChildrenBanner');
|
const bannerNoHijos = document.getElementById('parentNoChildrenBanner');
|
||||||
const sectionHijos = document.getElementById('parentChildrenSection');
|
const sectionHijos = document.getElementById('parentChildrenSection');
|
||||||
@@ -2682,9 +2693,9 @@ function renderParentDashboardView() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (activeView) {
|
if (activeView) {
|
||||||
openParentSubView(activeView);
|
openParentSubView(activeView, false);
|
||||||
} else {
|
} else {
|
||||||
closeParentSubView();
|
closeParentSubView(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2698,7 +2709,7 @@ function selectParentChild(childId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openParentSubView(viewKey) {
|
function openParentSubView(viewKey, shouldScroll = true) {
|
||||||
try {
|
try {
|
||||||
localStorage.setItem('recreopay_active_parent_subview', viewKey);
|
localStorage.setItem('recreopay_active_parent_subview', viewKey);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
@@ -2777,14 +2788,19 @@ function openParentSubView(viewKey) {
|
|||||||
loadActiveChildHistory(currentParentChild.id);
|
loadActiveChildHistory(currentParentChild.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
if (!isDesktop && targetEl && shouldScroll) {
|
||||||
|
setTimeout(() => {
|
||||||
|
smoothScrollToElement(targetEl, 65);
|
||||||
|
}, 60);
|
||||||
|
}
|
||||||
|
|
||||||
if (window.sounds) window.sounds.playTap();
|
if (window.sounds) window.sounds.playTap();
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeParentSubView() {
|
function closeParentSubView(shouldScroll = true) {
|
||||||
const isDesktop = window.innerWidth >= 860;
|
const isDesktop = window.innerWidth >= 860;
|
||||||
if (isDesktop) {
|
if (isDesktop) {
|
||||||
openParentSubView('resumen');
|
openParentSubView('resumen', false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2813,7 +2829,12 @@ function closeParentSubView() {
|
|||||||
box.classList.remove('active');
|
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();
|
if (window.sounds) window.sounds.playTap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user