fix: allow item drag/resize to snap at column 0

- Removed Math.max(beatSec, ...) clamp from clip drag, section drag, section resize handlers
- Replaced with Math.max(0, ...) so items can snap to time 0
This commit is contained in:
2026-07-25 10:59:17 +07:00
parent cb3e8117b2
commit 01cd3d1867
3 changed files with 13 additions and 7 deletions
+4 -4
View File
@@ -10322,11 +10322,11 @@ const App = () => {
const mouseX = e.clientX - rect.left + scrollLeft;
const time = Math.max(0, mouseX / zoom - leadInMarginRef.current);
const beatSec = (60.0 / (parseInt(bpmRef.current) || 120));
const rawStart = Math.max(beatSec, time - drag.clickOffset);
const rawStart = Math.max(0, time - drag.clickOffset);
const secPerBar = beatSec * 4;
const marginBar = maxDurationRef.current - secPerBar;
const clampedStart = Math.min(rawStart, marginBar);
const newStart = snapTime(clampedStart, snapValueRef.current, bpmRef.current);
const newStart = snapTime(Math.max(0, clampedStart), snapValueRef.current, bpmRef.current);
const itemPx = newStart * zoom;
const keepMargin = 80;
if (itemPx > scrollLeft + rect.width - keepMargin) {
@@ -10492,7 +10492,7 @@ const App = () => {
const beatSec = (60.0 / (parseInt(bpm) || 120));
const secondsPerBar = beatSec * 4;
const marginBar = maxDurationRef.current - secondsPerBar;
const rawStart = Math.max(beatSec, Math.min(time - drag.clickOffset, marginBar));
const rawStart = Math.max(0, Math.min(time - drag.clickOffset, marginBar));
const newStart = snapTime(rawStart, snapValueRef.current, bpmRef.current);
const itemPx = newStart * zoom;
const keepMargin = 80;
@@ -10573,7 +10573,7 @@ const App = () => {
const item = items[idx];
if (resize.side === 'left') {
const beatSec = (60.0 / (parseInt(bpm) || 120));
const newStart = Math.max(beatSec, Math.min(time, resize.originalStart + resize.originalDuration - 0.1));
const newStart = Math.max(0, Math.min(time, resize.originalStart + resize.originalDuration - 0.1));
const end = resize.originalStart + resize.originalDuration;
const newDuration = end - newStart;
if (newDuration < 0.1) return t;
File diff suppressed because one or more lines are too long
+6
View File
@@ -92,6 +92,12 @@
- **Ghi chú/Test (nếu có):** `npm run build` — build passes.
---
### [2026-07-25 10:58] Task: Fix clip/section snap to column 0
- **Tóm tắt thay đổi:** Xóa `Math.max(beatSec, ...)` trong clip drag (10325), section drag (10495), section resize (10576) — thay bằng `Math.max(0, ...)` để item có thể snap vào column 0.
- **Các file ảnh hưởng:** `app/static/js/app.jsx`, `app/static/js/app.precompiled.js`
- **Ghi chú/Test (nếu có):** `npm run build` — build passes.
---
### [2026-07-25 10:54] Task: Fix TempoTrackLane height + clamp selection at column 0
- **Tóm tắt thay đổi:** Fix TempoTrackLane canvas height = 40px cố định (thay vì parentElement.clientHeight gây tràn). Wrapper `h-10 shrink-0 overflow-hidden` để không đẩy track lanes lệch TCP. Clamp selLeft/selRight/ruler handlers >= 0 để selection không vào vùng âm.
- **Các file ảnh hưởng:** `app/static/js/app.jsx`, `app/static/js/app.precompiled.js`