fix: drag-move delta relative to clicked note, not first selected
This commit is contained in:
@@ -6613,7 +6613,8 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
|||||||
idx: clickedNoteIdx,
|
idx: clickedNoteIdx,
|
||||||
startOffsetBeat: beat - clickedNote.start_beat,
|
startOffsetBeat: beat - clickedNote.start_beat,
|
||||||
startOffsetPitch: pitch,
|
startOffsetPitch: pitch,
|
||||||
selectedNotesOffset: selectedNotesOffset
|
selectedNotesOffset: selectedNotesOffset,
|
||||||
|
clickedOriginalStartBeat: clickedNote.start_beat
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Click on empty space with pen tool: DRAW a new note (brush mode with visitedPitches)
|
// Click on empty space with pen tool: DRAW a new note (brush mode with visitedPitches)
|
||||||
@@ -6881,11 +6882,9 @@ const PianoRollTabEditor = ({ st, zoom, bpm, viewportWidth, activeTracks, onClos
|
|||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
} else if (draggedNote.mode === 'move') {
|
} else if (draggedNote.mode === 'move') {
|
||||||
const firstOffset = draggedNote.selectedNotesOffset && draggedNote.selectedNotesOffset[0];
|
const refOrigStart = draggedNote.clickedOriginalStartBeat;
|
||||||
if (!firstOffset) return;
|
if (refOrigStart === undefined) return;
|
||||||
const firstNote = notes.find(n => n.id === firstOffset.id);
|
const deltaBeat = getSnapBeat(beat - draggedNote.startOffsetBeat, snapValue) - refOrigStart;
|
||||||
if (!firstNote) return;
|
|
||||||
const deltaBeat = getSnapBeat(beat - draggedNote.startOffsetBeat, snapValue) - firstOffset.originalStartBeat;
|
|
||||||
// Clamp so no note goes past beat 0
|
// Clamp so no note goes past beat 0
|
||||||
const minOrigStart = Math.min(...draggedNote.selectedNotesOffset.map(o => o.originalStartBeat));
|
const minOrigStart = Math.min(...draggedNote.selectedNotesOffset.map(o => o.originalStartBeat));
|
||||||
const clampedDeltaBeat = minOrigStart + deltaBeat < 0 ? -minOrigStart : deltaBeat;
|
const clampedDeltaBeat = minOrigStart + deltaBeat < 0 ? -minOrigStart : deltaBeat;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user