리펙토링: 전체 구조 검토, 개선

This commit is contained in:
2026-05-15 18:36:55 +09:00
parent 75a1f9e2f5
commit a1a5672d97
10 changed files with 117 additions and 23 deletions
+8 -1
View File
@@ -125,7 +125,14 @@ async function expandNode(nodeEl, autoExpandPath) {
if (!childrenEl.dataset.loaded) {
childrenEl.dataset.loaded = 'true';
const dirs = await window.api.listDirectories(nodeEl.dataset.path);
dirs.forEach(dir => childrenEl.appendChild(createNode(dir)));
if (dirs === null) {
const err = document.createElement('div');
err.className = 'tree-access-error';
err.textContent = '접근 불가';
childrenEl.appendChild(err);
} else {
dirs.forEach(dir => childrenEl.appendChild(createNode(dir)));
}
}
// Auto-expand toward the target path
+18 -1
View File
@@ -4,9 +4,15 @@ let _state, _cb;
let rbActive = false;
let rbStartX = 0;
let rbStartY = 0;
let _rafPending = false;
let _lastMoveEvent = null;
let lastSelectedIdx = null;
export function resetAnchor() {
lastSelectedIdx = null;
}
export function init({ gridContainer, rubberBand, grid, state, callbacks }) {
_rubberBand = rubberBand;
_grid = grid;
@@ -98,6 +104,17 @@ function _onStart(e) {
function _onMove(e) {
if (!rbActive) return;
_lastMoveEvent = e;
if (!_rafPending) {
_rafPending = true;
requestAnimationFrame(_processMove);
}
}
function _processMove() {
_rafPending = false;
const e = _lastMoveEvent;
if (!rbActive || !e) return;
const left = Math.min(rbStartX, e.clientX);
const top = Math.min(rbStartY, e.clientY);
@@ -110,11 +127,11 @@ function _onMove(e) {
});
const sel = { left, top, right: left + width, bottom: top + height };
const preserve = e.shiftKey || e.ctrlKey || e.metaKey;
Array.from(_grid.children).forEach((card, i) => {
const r = card.getBoundingClientRect();
const overlaps = !(r.right < sel.left || r.left > sel.right ||
r.bottom < sel.top || r.top > sel.bottom);
const preserve = e.shiftKey || e.ctrlKey || e.metaKey;
if (overlaps) {
_state.selectedIdxs.add(i);
} else if (!preserve) {