fix: sync bar ruler redraw during drag via canvasRedrawCount

This commit is contained in:
2026-07-25 09:24:31 +07:00
parent f1057ab7f2
commit 6aed5e2ec8
2 changed files with 20 additions and 4 deletions
+15 -4
View File
@@ -1196,7 +1196,8 @@ const TempoTrackLane = ({
onPlayheadSet, onPlayheadSet,
snapValue, snapValue,
onRulerMouseDown, onRulerMouseDown,
scrollLeft scrollLeft,
canvasRedrawCount
}) => { }) => {
const canvasRef = useRef(null); const canvasRef = useRef(null);
const drawWidth = Math.min(timelineWidth, viewportWidth); const drawWidth = Math.min(timelineWidth, viewportWidth);
@@ -1286,7 +1287,7 @@ const TempoTrackLane = ({
ctx.font = 'bold 10px Inter, sans-serif'; ctx.font = 'bold 10px Inter, sans-serif';
ctx.textAlign = 'right'; ctx.textAlign = 'right';
ctx.fillText(`${bpm} BPM`, drawWidth - 6, 12); ctx.fillText(`${bpm} BPM`, drawWidth - 6, 12);
}, [bpm, zoom, timelineWidth, viewportWidth, snapValue, scrollLeft]); }, [bpm, zoom, timelineWidth, viewportWidth, snapValue, scrollLeft, canvasRedrawCount]);
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", { return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
key: "virtual-spacer-tempo", key: "virtual-spacer-tempo",
style: { style: {
@@ -10222,8 +10223,10 @@ const App = () => {
const followMargin = 120; const followMargin = 120;
if (itemPx > scrollLeft + rect.width - followMargin) { if (itemPx > scrollLeft + rect.width - followMargin) {
wrapper.scrollLeft = itemPx - rect.width + followMargin; wrapper.scrollLeft = itemPx - rect.width + followMargin;
setCanvasRedrawCount(n => n + 1);
} else if (itemPx < scrollLeft + followMargin) { } else if (itemPx < scrollLeft + followMargin) {
wrapper.scrollLeft = Math.max(0, itemPx - followMargin); wrapper.scrollLeft = Math.max(0, itemPx - followMargin);
setCanvasRedrawCount(n => n + 1);
} }
const targetTrackId = hoveredTrackIdRef.current || drag.trackId; const targetTrackId = hoveredTrackIdRef.current || drag.trackId;
updateActiveTracks(prev => prev.map(t => { updateActiveTracks(prev => prev.map(t => {
@@ -10386,8 +10389,10 @@ const App = () => {
const followMargin = 120; const followMargin = 120;
if (itemPx > scrollLeft + rect.width - followMargin) { if (itemPx > scrollLeft + rect.width - followMargin) {
wrapper.scrollLeft = itemPx - rect.width + followMargin; wrapper.scrollLeft = itemPx - rect.width + followMargin;
setCanvasRedrawCount(n => n + 1);
} else if (itemPx < scrollLeft + followMargin) { } else if (itemPx < scrollLeft + followMargin) {
wrapper.scrollLeft = Math.max(0, itemPx - followMargin); wrapper.scrollLeft = Math.max(0, itemPx - followMargin);
setCanvasRedrawCount(n => n + 1);
} }
const targetTrackId = hoveredTrackIdRef.current || drag.trackId; const targetTrackId = hoveredTrackIdRef.current || drag.trackId;
updateActiveTracks(prev => { updateActiveTracks(prev => {
@@ -10481,8 +10486,10 @@ const App = () => {
const followMargin = 120; const followMargin = 120;
if (edgePx > scrollLeft + rect.width - followMargin) { if (edgePx > scrollLeft + rect.width - followMargin) {
wrapper.scrollLeft = edgePx - rect.width + followMargin; wrapper.scrollLeft = edgePx - rect.width + followMargin;
setCanvasRedrawCount(n => n + 1);
} else if (edgePx < scrollLeft + followMargin) { } else if (edgePx < scrollLeft + followMargin) {
wrapper.scrollLeft = Math.max(0, edgePx - followMargin); wrapper.scrollLeft = Math.max(0, edgePx - followMargin);
setCanvasRedrawCount(n => n + 1);
} }
}; };
const handleMouseUp = () => { const handleMouseUp = () => {
@@ -14875,7 +14882,8 @@ const App = () => {
onPlayheadSet: handlePlayheadSet, onPlayheadSet: handlePlayheadSet,
snapValue: snapValue, snapValue: snapValue,
onRulerMouseDown: handleRulerMouseDown, onRulerMouseDown: handleRulerMouseDown,
scrollLeft: scrollLeft scrollLeft: scrollLeft,
canvasRedrawCount: canvasRedrawCount
}))), /*#__PURE__*/React.createElement("div", { }))), /*#__PURE__*/React.createElement("div", {
className: "flex-1 flex flex-col divide-y divide-[#141414] relative bg-[#111111] min-h-full" className: "flex-1 flex flex-col divide-y divide-[#141414] relative bg-[#111111] min-h-full"
}, activeTracks.map((track, idx) => { }, activeTracks.map((track, idx) => {
@@ -15386,8 +15394,11 @@ const App = () => {
bpm: parseInt(bpm) || 120, bpm: parseInt(bpm) || 120,
zoom: zoom, zoom: zoom,
timelineWidth: subTabTimelineWidth, timelineWidth: subTabTimelineWidth,
viewportWidth: viewportWidth,
onPlayheadSet: setCurrentTime, onPlayheadSet: setCurrentTime,
snapValue: snapValue snapValue: snapValue,
scrollLeft: scrollLeft,
canvasRedrawCount: canvasRedrawCount
}))), /*#__PURE__*/React.createElement("div", { }))), /*#__PURE__*/React.createElement("div", {
className: "flex-1 flex flex-col relative bg-[#111111] min-h-full" className: "flex-1 flex flex-col relative bg-[#111111] min-h-full"
}, vTrack && /*#__PURE__*/React.createElement("div", { }, vTrack && /*#__PURE__*/React.createElement("div", {
+5
View File
@@ -54,6 +54,11 @@
- **Các file ảnh hưởng:** `app/static/js/app.jsx` - **Các file ảnh hưởng:** `app/static/js/app.jsx`
- **Ghi chú/Test (nếu có):** `npx babel app/static/js/app.jsx` — compile pass. - **Ghi chú/Test (nếu có):** `npx babel app/static/js/app.jsx` — compile pass.
### [2026-07-25 09:23] Task: Sync bar ruler redraw during drag
- **Tóm tắt thay đổi:** (1) TempoTrackLane nhận `canvasRedrawCount` prop + deps — force redraw bar numbers khi drag. (2) Cả 3 drag handler increment `setCanvasRedrawCount` sau auto-follow scroll. (3) Sub-tab TempoTrackLane thêm `viewportWidth` + `scrollLeft` + `canvasRedrawCount` — đồng bộ ruler với timeline.
- **Các file ảnh hưởng:** `app/static/js/app.jsx`
- **Ghi chú/Test (nếu có):** `npx babel app/static/js/app.jsx` — compile pass.
### [2026-07-25 07:25] Task: Fix auto-scroll + maxDuration tab isolation + 1-bar margin ### [2026-07-25 07:25] Task: Fix auto-scroll + maxDuration tab isolation + 1-bar margin
- **Tóm tắt thay đổi:** (1) `maxDuration` dùng `activeTracks` + 4-bar buffer. (2) Cách ly MAIN vs SECTION-TAB. (3) Clip/section/MIDI drag/stretch/resize clamp 1-bar from right. (4) Clip drag + stretched clip dùng `updateActiveTracks`. (5) Stretched clip handler thêm auto-scroll. - **Tóm tắt thay đổi:** (1) `maxDuration` dùng `activeTracks` + 4-bar buffer. (2) Cách ly MAIN vs SECTION-TAB. (3) Clip/section/MIDI drag/stretch/resize clamp 1-bar from right. (4) Clip drag + stretched clip dùng `updateActiveTracks`. (5) Stretched clip handler thêm auto-scroll.
- **Các file ảnh hưởng:** `app/static/js/app.jsx` - **Các file ảnh hưởng:** `app/static/js/app.jsx`