Skip to content
Merged
Show file tree
Hide file tree
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
66 changes: 65 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2822,9 +2822,73 @@ window.addEventListener("keydown", (e) => {
else if ((e.ctrlKey || e.metaKey) && (k === "y" || k === "Y")) { e.preventDefault(); redo(); }
});

window.addEventListener("resize", () => { state.dirtyTimeline = true; });
window.addEventListener("resize", () => { state.dirtyTimeline = true; clampTimelineHeight(); });

/* ── Resizable upper / timeline split ── */
const TL_H_KEY = "fablecut-timeline-h";
const TL_H_MIN = 180;
const UPPER_MIN = 140;
function availableTimelineMax() {
const app = $("app").getBoundingClientRect();
const topbar = document.querySelector(".topbar")?.getBoundingClientRect();
const topbarH = topbar ? topbar.height : 46;
const split = 6;
const gaps = 18; // three 6px flex gaps between four children
return Math.floor(app.height - topbarH - UPPER_MIN - split - gaps);
}
Comment on lines +2831 to +2838

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

availableTimelineMax doesn't account for .app's 12px vertical padding.

getBoundingClientRect().height includes padding, but flex children are laid out in the content area (height - padding). The calculation is missing 12px (6px top + 6px bottom), so the max is overestimated by 12px, causing slight overflow when the timeline is dragged to its maximum.

🐛 Proposed fix
 function availableTimelineMax() {
   const app = $("app").getBoundingClientRect();
   const topbar = document.querySelector(".topbar")?.getBoundingClientRect();
   const topbarH = topbar ? topbar.height : 46;
   const split = 6;
   const gaps = 18; // three 6px flex gaps between four children
-  return Math.floor(app.height - topbarH - UPPER_MIN - split - gaps);
+  const padding = 12; // 6px top + 6px bottom on .app
+  return Math.floor(app.height - padding - topbarH - UPPER_MIN - split - gaps);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function availableTimelineMax() {
const app = $("app").getBoundingClientRect();
const topbar = document.querySelector(".topbar")?.getBoundingClientRect();
const topbarH = topbar ? topbar.height : 46;
const split = 6;
const gaps = 18; // three 6px flex gaps between four children
return Math.floor(app.height - topbarH - UPPER_MIN - split - gaps);
}
function availableTimelineMax() {
const app = $("app").getBoundingClientRect();
const topbar = document.querySelector(".topbar")?.getBoundingClientRect();
const topbarH = topbar ? topbar.height : 46;
const split = 6;
const gaps = 18; // three 6px flex gaps between four children
const padding = 12; // 6px top + 6px bottom on .app
return Math.floor(app.height - padding - topbarH - UPPER_MIN - split - gaps);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app.js` around lines 2831 - 2838, Update availableTimelineMax to subtract the
app’s 12px total vertical padding from the getBoundingClientRect height before
calculating the available timeline maximum, preserving the existing topbar,
minimum, split, and gap deductions.

function setTimelineHeight(px) {
const h = clamp(Math.round(px), TL_H_MIN, Math.max(TL_H_MIN, availableTimelineMax()));
$("app").style.setProperty("--timeline-h", h + "px");
state.dirtyTimeline = true;
return h;
}
function resetTimelineHeight() {
const h = setTimelineHeight(window.innerHeight * 0.32);
localStorage.removeItem(TL_H_KEY);
state.dirtyTimeline = true;
return h;
}
function clampTimelineHeight() {
const cur = $("timelinePanel")?.getBoundingClientRect().height;
if (cur) setTimelineHeight(cur);
}
function initPanelSplit() {
const handle = $("splitUpperTimeline");
const tl = $("timelinePanel");
if (!handle || !tl) return;
const saved = parseFloat(localStorage.getItem(TL_H_KEY));
if (saved > 0) setTimelineHeight(saved);
else resetTimelineHeight();

handle.addEventListener("pointerdown", (e) => {
if (e.button !== 0) return;
e.preventDefault();
handle.setPointerCapture(e.pointerId);
handle.classList.add("dragging");
document.body.classList.add("resizing-panels");
const y0 = e.clientY;
const h0 = tl.getBoundingClientRect().height;
const onMove = (ev) => setTimelineHeight(h0 - (ev.clientY - y0));
const onUp = () => {
handle.releasePointerCapture(e.pointerId);
handle.classList.remove("dragging");
document.body.classList.remove("resizing-panels");
handle.removeEventListener("pointermove", onMove);
handle.removeEventListener("pointerup", onUp);
localStorage.setItem(TL_H_KEY, String(Math.round(tl.getBoundingClientRect().height)));
state.dirtyTimeline = true;
};
handle.addEventListener("pointermove", onMove);
handle.addEventListener("pointerup", onUp);
});
Comment on lines +2863 to +2883

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Add a pointercancel handler to clean up drag state.

If the browser cancels the pointer (common on touch when the OS or a scroll gesture intervenes), pointerup never fires. The dragging class on the handle and resizing-panels class on <body> remain stuck, leaving cursor: ns-resize and user-select: none on all elements until page reload. Extract the shared cleanup and register it for pointercancel as well.

🔒 Proposed fix
     const onMove = (ev) => setTimelineHeight(h0 - (ev.clientY - y0));
-    const onUp = () => {
+    const cleanup = () => {
       handle.releasePointerCapture(e.pointerId);
       handle.classList.remove("dragging");
       document.body.classList.remove("resizing-panels");
       handle.removeEventListener("pointermove", onMove);
       handle.removeEventListener("pointerup", onUp);
+      handle.removeEventListener("pointercancel", cleanup);
+    };
+    const onUp = () => {
+      cleanup();
       localStorage.setItem(TL_H_KEY, String(Math.round(tl.getBoundingClientRect().height)));
       state.dirtyTimeline = true;
     };
     handle.addEventListener("pointermove", onMove);
     handle.addEventListener("pointerup", onUp);
+    handle.addEventListener("pointercancel", cleanup);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
handle.addEventListener("pointerdown", (e) => {
if (e.button !== 0) return;
e.preventDefault();
handle.setPointerCapture(e.pointerId);
handle.classList.add("dragging");
document.body.classList.add("resizing-panels");
const y0 = e.clientY;
const h0 = tl.getBoundingClientRect().height;
const onMove = (ev) => setTimelineHeight(h0 - (ev.clientY - y0));
const onUp = () => {
handle.releasePointerCapture(e.pointerId);
handle.classList.remove("dragging");
document.body.classList.remove("resizing-panels");
handle.removeEventListener("pointermove", onMove);
handle.removeEventListener("pointerup", onUp);
localStorage.setItem(TL_H_KEY, String(Math.round(tl.getBoundingClientRect().height)));
state.dirtyTimeline = true;
};
handle.addEventListener("pointermove", onMove);
handle.addEventListener("pointerup", onUp);
});
handle.addEventListener("pointerdown", (e) => {
if (e.button !== 0) return;
e.preventDefault();
handle.setPointerCapture(e.pointerId);
handle.classList.add("dragging");
document.body.classList.add("resizing-panels");
const y0 = e.clientY;
const h0 = tl.getBoundingClientRect().height;
const onMove = (ev) => setTimelineHeight(h0 - (ev.clientY - y0));
const cleanup = () => {
handle.releasePointerCapture(e.pointerId);
handle.classList.remove("dragging");
document.body.classList.remove("resizing-panels");
handle.removeEventListener("pointermove", onMove);
handle.removeEventListener("pointerup", onUp);
handle.removeEventListener("pointercancel", cleanup);
};
const onUp = () => {
cleanup();
localStorage.setItem(TL_H_KEY, String(Math.round(tl.getBoundingClientRect().height)));
state.dirtyTimeline = true;
};
handle.addEventListener("pointermove", onMove);
handle.addEventListener("pointerup", onUp);
handle.addEventListener("pointercancel", cleanup);
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app.js` around lines 2863 - 2883, Update the pointer drag handling around the
pointerdown listener by extracting the shared cleanup from onUp into a reusable
handler, then register it for both pointerup and pointercancel. Ensure
cancellation releases the pointer capture, removes dragging/resizing-panels
classes, unregisters move and end listeners, and preserves the existing
persistence and dirty-state behavior for normal pointerup.

handle.addEventListener("dblclick", (e) => {
e.preventDefault();
resetTimelineHeight();
});
}

/* ── Boot ── */
initPanelSplit();
buildTrackDOM();
rebuildClips();
renderBin();
Expand Down
4 changes: 3 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@
</aside>
</div>

<div class="v-split" id="splitUpperTimeline" role="separator" aria-orientation="horizontal" title="Drag to resize · double-click to reset"></div>

<!-- ══════════ TIMELINE ══════════ -->
<section class="panel timeline-panel">
<section class="panel timeline-panel" id="timelinePanel">
<div class="timeline-toolbar">
<button class="btn tiny" id="btnSplit" title="Split at playhead (S)">✂ Split</button>
<button class="btn tiny" id="btnDelete" title="Delete selected (Del)">🗑 Delete</button>
Expand Down
21 changes: 19 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,25 @@ body {
color: var(--text);
font: 13px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}
.app { display: grid; grid-template-rows: 46px minmax(0, 1fr) minmax(230px, 38%); height: 100vh; gap: 6px; padding: 6px; }
.app {
display: flex; flex-direction: column; height: 100vh; gap: 6px; padding: 6px;
}
.topbar { flex: 0 0 46px; }
.upper { flex: 1 1 0; min-height: 140px; min-width: 0; }
.timeline-panel {
flex: 0 0 var(--timeline-h, 32vh); min-height: 180px; overflow: hidden;
}
.v-split {
flex: 0 0 6px; cursor: ns-resize; position: relative; z-index: 5;
border-radius: 3px;
}
.v-split::after {
content: ""; position: absolute; left: 18%; right: 18%; top: 2px; height: 2px;
border-radius: 1px; background: var(--border); transition: background .15s;
}
.v-split:hover::after, .v-split.dragging::after { background: var(--accent); }
body.resizing-panels { cursor: ns-resize !important; }
body.resizing-panels * { cursor: ns-resize !important; user-select: none !important; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.flex-spacer { flex: 1; }
Expand Down Expand Up @@ -167,7 +185,6 @@ input[type=range] { accent-color: var(--accent); height: 18px; }
.kf-btn.has { color: #ffd166; border-color: #ffd16666; }

/* ── Timeline ── */
.timeline-panel { overflow: hidden; }
.timeline-toolbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.tiny-label { font-size: 11px; }
#zoomSlider { width: 130px; }
Expand Down
Loading