diff --git a/src/app/main.js b/src/app/main.js index c9c30e4..c4a0425 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -326,6 +326,7 @@ function toggleFocus(){ focusToday=!focusToday; const b=$id("gfocusbtn"); if(b)b let GVIEW="proj"; // "proj" | "tasks" | "subs" let ganttScroll={left:0,top:0}; // preserved across re-renders so edits don't jump to top let ganttRestoring=false; +let pageScrollY=0; // window scroll on layouts where .gscroll is horizontal-only function setGView(v){ GVIEW=v; defer(renderGantt); } function setZoom(i){ ZOOM=i; setTimeout(renderAll,0); } // drives the scale window and the gantt zoom function onGanttScroll(){ @@ -343,6 +344,20 @@ function restoreGanttScroll(sc){ requestAnimationFrame(()=>{ apply(); requestAnimationFrame(()=>{ apply(); ganttRestoring=false; }); }); else ganttRestoring=false; } +function restorePageScroll(){ + const y=pageScrollY; + const apply=()=>{ window.scrollTo(0,y); }; + apply(); + if(typeof requestAnimationFrame!=="undefined") + requestAnimationFrame(()=>{ apply(); requestAnimationFrame(apply); }); +} +function restoreDetailScroll(box,top){ + if(!box) return; + const apply=()=>{ box.scrollTop=top; }; + apply(); + if(typeof requestAnimationFrame!=="undefined") + requestAnimationFrame(()=>{ apply(); requestAnimationFrame(apply); }); +} function applyBarDrag(n,mode,s,e,s0,e0){ if(typeof commitBarDrag==="function"){ commitBarDrag(n,mode,s,e,s0,e0); return; } if(mode==="move"){ n.due=dayIso(e); if(n.start) n.start=dayIso(s); } @@ -512,6 +527,7 @@ function renderGantt(){ } const prevSc=document.querySelector(".gscroll"); if(prevSc){ ganttScroll.left=prevSc.scrollLeft; ganttScroll.top=prevSc.scrollTop; } + pageScrollY=window.scrollY||document.documentElement.scrollTop||0; document.getElementById("gantt").innerHTML= `