mirror of
https://github.com/kuaifan/dootask.git
synced 2026-10-31 06:50:43 +00:00
列与任务卡片原先写在 ProjectPanel 的同一个渲染函数里,卡片可见状态、倒计时等任一变化都会带动全部列的 draggable、Scrollbar 等插槽组件重渲染: - 新增 ProjectColumn,每列自行维护列与任务的可见状态,面板只通知其检查可视区 - 任务可见性计算抽成 utils/taskVisibility.js,看板与表格共用 - 跨列拖入的任务落下即标记可见,避免先显示空白占位 - 搜索、筛选、打开任务等面板级逻辑通过 provide 的 projectPanel 读取
36 lines
1.3 KiB
JavaScript
Vendored
36 lines
1.3 KiB
JavaScript
Vendored
// 按滚动容器可视区(上下各多算一个任务高度)更新任务的可见状态,未可见的任务只渲染占位
|
|
// 首次可见的任务逐个等待渲染,让后续任务按真实高度判断
|
|
export async function updateTaskVisibilitys(vm, target, visibilitys) {
|
|
if (!target) {
|
|
return
|
|
}
|
|
const targetItem = target.querySelectorAll('.task-item');
|
|
if (!targetItem.length) {
|
|
return
|
|
}
|
|
const targetRect = target.getBoundingClientRect();
|
|
for (const item of targetItem) {
|
|
const dataId = item.getAttribute('data-id');
|
|
if (!dataId) {
|
|
continue;
|
|
}
|
|
const taskRect = item.getBoundingClientRect();
|
|
const originalVisible = visibilitys[dataId]?.visible || false;
|
|
const currentVisible = (
|
|
taskRect.top >= targetRect.top - taskRect.height &&
|
|
taskRect.bottom <= targetRect.bottom + taskRect.height
|
|
);
|
|
if (currentVisible === originalVisible) {
|
|
continue;
|
|
}
|
|
const firstVisible = visibilitys[dataId] === undefined && currentVisible;
|
|
vm.$set(visibilitys, dataId, {
|
|
visible: currentVisible,
|
|
height: taskRect.height
|
|
});
|
|
if (firstVisible) {
|
|
await vm.$nextTick();
|
|
}
|
|
}
|
|
}
|