Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -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); }
Expand Down Expand Up @@ -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=
`<div class="gscroll"><div class="ginner" style="min-width:${(SPAN_EFFV/(VIS-1+TW)*100).toFixed(1)}%">`+
rows.join("")+
Expand All @@ -520,6 +536,7 @@ function renderGantt(){
const sc=document.querySelector(".gscroll");
sc.addEventListener("scroll",onGanttScroll,{passive:true});
restoreGanttScroll(sc);
restorePageScroll();
const gpane=document.querySelector(".gantt");
if(gpane&&!gpane._floatBound){ gpane._floatBound=true; gpane.addEventListener("scroll",placeFloat,{passive:true}); }
pinFlags(); placeFloat(); placeOverflowTitles();
Expand Down Expand Up @@ -904,6 +921,9 @@ let DETAIL_ID=null;
function openDetail(id){
const path=findPath(id);
if(!path){ if(DETAIL_ID===id) closeSheet(); DETAIL_ID=null; return; }
const box=document.querySelector(".tbox");
const keepScroll=DETAIL_ID===id;
const savedScroll=keepScroll&&box?box.scrollTop:0;
DETAIL_ID=id;
const n=path[path.length-1], leaf=!n.children.length;
document.getElementById("dCrumb").innerHTML=path.length>1
Expand Down Expand Up @@ -950,6 +970,7 @@ function openDetail(id){
<button class="danger" onclick="deleteTask(${id})">Delete ${path.length===1?"project":path.length>=3?"subtask":"task"}</button>`;
document.getElementById("tmodal").classList.add("show");
document.getElementById("scrim").classList.add("show");
restoreDetailScroll(box,savedScroll);
}
function closeSheet(){ DETAIL_ID=null;
document.getElementById("tmodal").classList.remove("show");
Expand Down
Loading