From ca7bd7e24e32a0633dcd3c3a69a237216f04048d Mon Sep 17 00:00:00 2001 From: Yuyao Huang Date: Sat, 9 May 2026 14:47:03 +0800 Subject: [PATCH] fix: align task to top instead of center in scroll view --- static/js/tasks.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/static/js/tasks.js b/static/js/tasks.js index 27ed27a..9e77ec9 100644 --- a/static/js/tasks.js +++ b/static/js/tasks.js @@ -164,20 +164,9 @@ function scrollToTask(taskId) { if (taskElement) { const scrollView = document.getElementById("scroll-view"); const taskTop = taskElement.offsetTop; - const scrollViewHeight = scrollView.clientHeight; - const taskHeight = taskElement.offsetHeight; - const targetScrollTop = taskTop - (scrollViewHeight / 2) + (taskHeight / 2); - console.log("scrollViewHeight:", scrollViewHeight, "taskHeight:", taskHeight); - console.log("taskTop:", taskTop, "targetScrollTop:", targetScrollTop); - scrollView.scrollTop = targetScrollTop; - console.log("scrollTop set to:", scrollView.scrollTop); - - // Check all task positions - const allTasks = scrollView.querySelectorAll('.task-item'); - console.log("All task positions:"); - allTasks.forEach((t, i) => { - console.log(` Task ${t.dataset.taskId}: offsetTop=${t.offsetTop}, visible=${t.offsetTop >= targetScrollTop && t.offsetTop < targetScrollTop + scrollViewHeight}`); - }); + // Align task to top of scroll view instead of center + scrollView.scrollTop = taskTop; + console.log("scrollTop set to taskTop:", taskTop); } else { console.log("Task element not found for id:", taskId); }