fix(cc11): replace auto-select (khong accumulate) + prefer selected note khi click lane (chord) + bump cache-buster v-param
This commit is contained in:
+16
-6
@@ -10509,6 +10509,16 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
});
|
||||
return best;
|
||||
};
|
||||
const findCC11TargetNote = (b) => {
|
||||
// Chord: prefer note dang duoc chon duoi click de khong ve/anchor
|
||||
// nham cho note khac cung beat
|
||||
const cur = notesRef.current;
|
||||
for (let i = 0; i < cur.length; i++) {
|
||||
const n = cur[i];
|
||||
if (selectedNoteIds.includes(n.id) && b >= n.start_beat && b <= n.start_beat + (n.duration_beats || 1)) return i;
|
||||
}
|
||||
return findCC11NoteAtBeat(b);
|
||||
};
|
||||
const handleCC11MouseDown = (e) => {
|
||||
const canvas = ccCanvasRef.current;
|
||||
if (!canvas) return;
|
||||
@@ -10517,14 +10527,14 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
const y = e.clientY - rect.top;
|
||||
const h = rect.height;
|
||||
const beat = x / pixelsPerBeat - renderBeatOffset;
|
||||
const noteIdx = findCC11NoteAtBeat(beat);
|
||||
const noteIdx = findCC11TargetNote(beat);
|
||||
if (noteIdx === -1) { ccDragRef.current = null; return; }
|
||||
const note = notesRef.current[noteIdx];
|
||||
if (!note) return;
|
||||
// Auto-select note duoc click: draw branch chi ve curve cho note duoc chon
|
||||
// (selectedNoteIds) -> khong select -> anchor them nhung vo hinh (bug: khong ve duoc CC11)
|
||||
if (note.id && !selectedNoteIds.includes(note.id)) {
|
||||
setSelectedNoteIds(prev => [...prev, note.id]);
|
||||
// Auto-select note duoc click: REPLACE selection (khong accumulate —
|
||||
// truoc day [...prev, id] cong don nhieu note -> lane ve graph cua note khac)
|
||||
if (note.id) {
|
||||
setSelectedNoteIds([note.id]);
|
||||
}
|
||||
const dur = note.duration_beats || 1;
|
||||
const ratio = Math.max(0, Math.min(1, (beat - note.start_beat) / dur));
|
||||
@@ -10568,7 +10578,7 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
||||
const y = e.clientY - rect.top;
|
||||
const h = rect.height;
|
||||
const beat = x / pixelsPerBeat - renderBeatOffset;
|
||||
const noteIdx = findCC11NoteAtBeat(beat);
|
||||
const noteIdx = findCC11TargetNote(beat);
|
||||
if (noteIdx === -1) return;
|
||||
const note = notes[noteIdx];
|
||||
const dur = note.duration_beats || 1;
|
||||
|
||||
Reference in New Issue
Block a user