perf(project): smooth sidebar resizing

Batch drag updates per frame and defer full layout recalculation until release. Cover resize edge cases and retain goals review records.
This commit is contained in:
2026-10-03 06:45:56 +09:00
parent 36a6866b96
commit e726f986db
12 changed files with 473 additions and 17 deletions
@@ -296,5 +296,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261003a" defer></script>
<script src="/static/project.js?v=20261003e" defer></script>
{% endblock %}
@@ -223,5 +223,5 @@
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project-goal-text.js?v=20261003c" defer></script>
<script src="/static/project.js?v=20261003a" defer></script>
<script src="/static/project.js?v=20261003e" defer></script>
{% endblock %}
@@ -104,5 +104,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261003a" defer></script>
<script src="/static/project.js?v=20261003e" defer></script>
{% endblock %}
@@ -100,5 +100,5 @@
"today": {{ today | tojson }}
}
</script>
<script src="/static/project.js?v=20261003a" defer></script>
<script src="/static/project.js?v=20261003e" defer></script>
{% endblock %}
@@ -496,5 +496,5 @@
</script>
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
<script src="/static/project.js?v=20261003a" defer></script>
<script src="/static/project.js?v=20261003e" defer></script>
{% endblock %}
@@ -70,5 +70,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261003a" defer></script>
<script src="/static/project.js?v=20261003e" defer></script>
{% endblock %}
+35 -11
View File
@@ -8422,35 +8422,59 @@
handle.title = "끌어서 메뉴 너비 조절 (최소 170px)";
layout.appendChild(handle);
function width() { return parseInt(layout.style.getPropertyValue("--pj-side-w"), 10) || Math.round(side.getBoundingClientRect().width / uiZoom()) || 250; }
let currentWidth = width();
function apply(w) {
w = Math.max(170, Math.min(500, Math.round(w)));
// 같은 픽셀 너비면 스타일을 다시 쓰거나 화면을 다시 계산하지 않는다.
if (w === currentWidth && layout.style.getPropertyValue("--pj-side-w") === w + "px") return;
currentWidth = w;
layout.style.setProperty("--pj-side-w", w + "px"); handle.setAttribute("aria-valuenow", String(w));
window.dispatchEvent(new Event("resize"));
}
function remember() { try { localStorage.setItem(key, String(width())); } catch (_) {} }
function remember() { try { localStorage.setItem(key, String(currentWidth)); } catch (_) {} }
try { const saved = Number(localStorage.getItem(key)); if (Number.isFinite(saved) && saved > 0) apply(saved); } catch (_) {}
handle.setAttribute("aria-valuenow", String(width()));
handle.setAttribute("aria-valuenow", String(currentWidth));
let finishDrag = null;
handle.addEventListener("mousedown", function (e) {
if (e.button !== 0) return;
if (e.button !== 0 || finishDrag) return;
e.preventDefault();
const x = e.clientX, w = width();
currentWidth = width(); // 기본 너비는 창 크기에 따라 250px/220px로 바뀔 수 있다.
const x = e.clientX, w = currentWidth, zoom = uiZoom();
let pendingWidth = w, frame = null;
handle.classList.add("is-dragging"); document.documentElement.classList.add("pj-side-resizing");
function move(ev) { apply(w + (ev.clientX - x) / uiZoom()); }
function up() {
document.removeEventListener("mousemove", move); document.removeEventListener("mouseup", up);
handle.classList.remove("is-dragging"); document.documentElement.classList.remove("pj-side-resizing"); remember();
// 마우스 이벤트가 화면 주사율보다 빨라도 최신 위치만 프레임당 한 번 반영한다.
function flush() { frame = null; apply(pendingWidth); }
function move(ev) {
pendingWidth = w + (ev.clientX - x) / zoom;
if (frame === null) frame = window.requestAnimationFrame(flush);
}
function up() {
// 마지막 프레임 전에 놓아도 마지막 이동 위치를 반영하고 예약된 콜백을 정리한다.
if (frame !== null) { window.cancelAnimationFrame(frame); flush(); }
document.removeEventListener("mousemove", move); document.removeEventListener("mouseup", up);
window.removeEventListener("blur", up); finishDrag = null;
handle.classList.remove("is-dragging"); document.documentElement.classList.remove("pj-side-resizing"); remember();
// resize 는 목표 표의 모든 글 높이·달력 등까지 재계산하므로 드래그 종료 때만 보낸다.
if (currentWidth !== w) window.dispatchEvent(new Event("resize"));
}
finishDrag = up;
document.addEventListener("mousemove", move); document.addEventListener("mouseup", up);
window.addEventListener("blur", up); // 창 밖에서 놓아도 드래그 상태가 남지 않게 한다.
});
handle.addEventListener("keydown", function (e) {
if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(e.key)) return;
e.preventDefault();
apply(e.key === "Home" ? 170 : e.key === "End" ? 500 : width() + (e.key === "ArrowLeft" ? -10 : 10)); remember();
if (finishDrag) finishDrag();
currentWidth = width();
const before = currentWidth;
apply(e.key === "Home" ? 170 : e.key === "End" ? 500 : currentWidth + (e.key === "ArrowLeft" ? -10 : 10)); remember();
if (currentWidth !== before) window.dispatchEvent(new Event("resize"));
});
handle.addEventListener("dblclick", function () {
if (finishDrag) finishDrag();
layout.style.removeProperty("--pj-side-w");
currentWidth = width();
try { localStorage.removeItem(key); } catch (_) {}
handle.setAttribute("aria-valuenow", String(width())); window.dispatchEvent(new Event("resize"));
handle.setAttribute("aria-valuenow", String(currentWidth)); window.dispatchEvent(new Event("resize"));
});
}
function initScrollIndicators() {