fix:lỗi drag ở vị trí con trỏ

This commit is contained in:
2026-07-18 21:58:46 +07:00
parent 1364cbc34b
commit 8363a46499
+9 -11
View File
@@ -1614,12 +1614,11 @@
}; };
const handleRulerMouseDown = (e) => { const handleRulerMouseDown = (e) => {
const ruler = rulerRef.current;
if (!ruler) return;
const rect = ruler.getBoundingClientRect();
const wrapper = timelineWrapperRef.current; const wrapper = timelineWrapperRef.current;
const scrollLeft = wrapper ? wrapper.scrollLeft : 0; if (!wrapper) return;
const mouseX = e.clientX - rect.left + scrollLeft; const rect = wrapper.getBoundingClientRect();
const scrollLeft = wrapper.scrollLeft;
const mouseX = e.clientX - rect.left + scrollLeft - 300;
const time = mouseX / zoom; const time = mouseX / zoom;
clearLocalSelection(); clearLocalSelection();
@@ -1635,12 +1634,11 @@
useEffect(() => { useEffect(() => {
const handleMouseMove = (e) => { const handleMouseMove = (e) => {
if (!isDraggingRulerRef.current) return; if (!isDraggingRulerRef.current) return;
const ruler = rulerRef.current;
const wrapper = timelineWrapperRef.current; const wrapper = timelineWrapperRef.current;
if (!ruler || !wrapper) return; if (!wrapper) return;
const rect = ruler.getBoundingClientRect(); const rect = wrapper.getBoundingClientRect();
const scrollLeft = wrapper.scrollLeft; const scrollLeft = wrapper.scrollLeft;
const mouseX = e.clientX - rect.left + scrollLeft; const mouseX = e.clientX - rect.left + scrollLeft - 300;
const time = Math.max(0, Math.min(maxDuration, mouseX / zoom)); const time = Math.max(0, Math.min(maxDuration, mouseX / zoom));
setSelectionEnd(time); setSelectionEnd(time);
@@ -1684,7 +1682,7 @@
if (!wrapper) return; if (!wrapper) return;
const rect = wrapper.getBoundingClientRect(); const rect = wrapper.getBoundingClientRect();
const scrollLeft = wrapper.scrollLeft; const scrollLeft = wrapper.scrollLeft;
const mouseX = e.clientX - rect.left + scrollLeft; const mouseX = e.clientX - rect.left + scrollLeft - 300;
const time = Math.max(0, Math.min(maxDuration, mouseX / zoom)); const time = Math.max(0, Math.min(maxDuration, mouseX / zoom));
setLocalSelectionEnd(time); setLocalSelectionEnd(time);
}; };
@@ -1785,7 +1783,7 @@
const rect = wrapper.getBoundingClientRect(); const rect = wrapper.getBoundingClientRect();
const scrollLeft = wrapper.scrollLeft; const scrollLeft = wrapper.scrollLeft;
const mouseX = e.clientX - rect.left + scrollLeft; const mouseX = e.clientX - rect.left + scrollLeft - 300;
const time = mouseX / zoom; const time = mouseX / zoom;
const rawStart = Math.max(0, time - drag.clickOffset); const rawStart = Math.max(0, time - drag.clickOffset);
const newStart = snapTime(rawStart, snapValueRef.current, bpmRef.current); const newStart = snapTime(rawStart, snapValueRef.current, bpmRef.current);