fix: add snapTime to section/MIDI item drag, followMargin 0.75 for 75% viewport ahead
This commit is contained in:
@@ -10225,7 +10225,7 @@ const App = () => {
|
|||||||
const clampedStart = Math.min(rawStart, marginBar);
|
const clampedStart = Math.min(rawStart, marginBar);
|
||||||
const newStart = snapTime(clampedStart, snapValueRef.current, bpmRef.current);
|
const newStart = snapTime(clampedStart, snapValueRef.current, bpmRef.current);
|
||||||
const itemPx = newStart * zoom;
|
const itemPx = newStart * zoom;
|
||||||
const followMargin = Math.round(rect.width * 0.4);
|
const followMargin = Math.round(rect.width * 0.75);
|
||||||
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);
|
setCanvasRedrawCount(n => n + 1);
|
||||||
@@ -10389,9 +10389,10 @@ const App = () => {
|
|||||||
const beatSec = (60.0 / (parseInt(bpm) || 120));
|
const beatSec = (60.0 / (parseInt(bpm) || 120));
|
||||||
const secondsPerBar = beatSec * 4;
|
const secondsPerBar = beatSec * 4;
|
||||||
const marginBar = maxDurationRef.current - secondsPerBar;
|
const marginBar = maxDurationRef.current - secondsPerBar;
|
||||||
const newStart = Math.max(beatSec, Math.min(time - drag.clickOffset, marginBar));
|
const rawStart = Math.max(beatSec, Math.min(time - drag.clickOffset, marginBar));
|
||||||
|
const newStart = snapTime(rawStart, snapValueRef.current, bpmRef.current);
|
||||||
const itemPx = newStart * zoom;
|
const itemPx = newStart * zoom;
|
||||||
const followMargin = Math.round(rect.width * 0.4);
|
const followMargin = Math.round(rect.width * 0.75);
|
||||||
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);
|
setCanvasRedrawCount(n => n + 1);
|
||||||
@@ -10488,7 +10489,7 @@ const App = () => {
|
|||||||
: { ...t, midiItems: items };
|
: { ...t, midiItems: items };
|
||||||
}));
|
}));
|
||||||
const edgePx = (resize.side === 'left' ? Math.max(0, time) : time) * zoom;
|
const edgePx = (resize.side === 'left' ? Math.max(0, time) : time) * zoom;
|
||||||
const followMargin = Math.round(rect.width * 0.4);
|
const followMargin = Math.round(rect.width * 0.75);
|
||||||
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);
|
setCanvasRedrawCount(n => n + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user