fix: tempo lane DOM scrollLeft traversal finds overflow-x:auto parent

This commit is contained in:
2026-07-25 09:33:11 +07:00
parent e5a563d343
commit 186c5353d4
+4 -3
View File
@@ -1207,11 +1207,12 @@ const TempoTrackLane = ({
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
const dpr = window.devicePixelRatio || 1; const dpr = window.devicePixelRatio || 1;
let el = canvas.parentElement; let el = canvas.parentElement;
for (let i = 0; i < 4 && el; i++) { while (el) {
if (el.scrollWidth > el.clientWidth || getComputedStyle(el).overflowX === 'auto' || getComputedStyle(el).overflowX === 'scroll') break; const ox = getComputedStyle(el).overflowX;
if (ox === 'auto' || ox === 'scroll') break;
el = el.parentElement; el = el.parentElement;
} }
const scrollLeftVal = el && el.scrollWidth > el.clientWidth ? el.scrollLeft : (scrollLeft || 0); 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);