fix: revert TempoTrackLane PADDING_LEFT to 2s, remove DOM scrollLeft hack
This commit is contained in:
@@ -1206,13 +1206,7 @@ const TempoTrackLane = ({
|
|||||||
if (!canvas) return;
|
if (!canvas) return;
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
const dpr = window.devicePixelRatio || 1;
|
const dpr = window.devicePixelRatio || 1;
|
||||||
let el = canvas.parentElement;
|
const scrollLeftVal = scrollLeft || 0;
|
||||||
while (el) {
|
|
||||||
const ox = getComputedStyle(el).overflowX;
|
|
||||||
if (ox === 'auto' || ox === 'scroll') break;
|
|
||||||
el = el.parentElement;
|
|
||||||
}
|
|
||||||
const scrollLeftVal = el ? el.scrollLeft : (scrollLeft || 0);
|
|
||||||
const height = canvas.parentElement ? canvas.parentElement.clientHeight : 40;
|
const height = canvas.parentElement ? canvas.parentElement.clientHeight : 40;
|
||||||
canvas.width = Math.min(Math.round(drawWidth * dpr), 32768);
|
canvas.width = Math.min(Math.round(drawWidth * dpr), 32768);
|
||||||
canvas.height = Math.min(Math.round(height * dpr), 32768);
|
canvas.height = Math.min(Math.round(height * dpr), 32768);
|
||||||
@@ -1224,7 +1218,7 @@ const TempoTrackLane = ({
|
|||||||
ctx.fillRect(0, 0, drawWidth, height);
|
ctx.fillRect(0, 0, drawWidth, height);
|
||||||
const beatDuration = 60 / bpm;
|
const beatDuration = 60 / bpm;
|
||||||
const barDuration = beatDuration * 4;
|
const barDuration = beatDuration * 4;
|
||||||
const PADDING_LEFT = beatDuration; // 1-beat margin on left
|
const PADDING_LEFT = 2; // seconds of empty space on left edge
|
||||||
const tStart = scrollLeftVal / zoom - PADDING_LEFT;
|
const tStart = scrollLeftVal / zoom - PADDING_LEFT;
|
||||||
const tEnd = (scrollLeftVal + drawWidth) / zoom;
|
const tEnd = (scrollLeftVal + drawWidth) / zoom;
|
||||||
const firstBeat = Math.floor(tStart / beatDuration) * beatDuration;
|
const firstBeat = Math.floor(tStart / beatDuration) * beatDuration;
|
||||||
|
|||||||
Reference in New Issue
Block a user