fix: clip getting deselected after a drag
This commit is contained in:
@ -1251,6 +1251,8 @@ function TimelineTrackContent({
|
|||||||
setResizing(null);
|
setResizing(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [justFinishedDrag, setJustFinishedDrag] = useState(false);
|
||||||
|
|
||||||
const handleClipMouseDown = (e: React.MouseEvent, clip: any) => {
|
const handleClipMouseDown = (e: React.MouseEvent, clip: any) => {
|
||||||
// Calculate the offset from the left edge of the clip to where the user clicked
|
// Calculate the offset from the left edge of the clip to where the user clicked
|
||||||
const clipElement = e.currentTarget.parentElement as HTMLElement;
|
const clipElement = e.currentTarget.parentElement as HTMLElement;
|
||||||
@ -1261,6 +1263,16 @@ function TimelineTrackContent({
|
|||||||
startDrag(e, clip.id, track.id, clip.startTime, clickOffsetTime);
|
startDrag(e, clip.id, track.id, clip.startTime, clickOffsetTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Reset drag flag when drag ends
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isDragging && justFinishedDrag) {
|
||||||
|
const timer = setTimeout(() => setJustFinishedDrag(false), 50);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
} else if (isDragging && !justFinishedDrag) {
|
||||||
|
setJustFinishedDrag(true);
|
||||||
|
}
|
||||||
|
}, [isDragging, justFinishedDrag]);
|
||||||
|
|
||||||
const handleTrackDragOver = (e: React.DragEvent) => {
|
const handleTrackDragOver = (e: React.DragEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -1766,6 +1778,11 @@ function TimelineTrackContent({
|
|||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
// Don't handle click if we just finished dragging
|
||||||
|
if (justFinishedDrag) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Close context menu if it's open
|
// Close context menu if it's open
|
||||||
if (contextMenu) {
|
if (contextMenu) {
|
||||||
setContextMenu(null);
|
setContextMenu(null);
|
||||||
|
Reference in New Issue
Block a user