Fix timeline scrolling

This commit is contained in:
daniel-inderos 2025-07-21 11:23:46 -06:00
parent 3446fdde87
commit d27f05be92
3 changed files with 22 additions and 3 deletions

View File

@ -878,7 +878,13 @@ export function Timeline() {
{/* Timeline Ruler */}
<div
className="flex-1 relative overflow-hidden h-4"
onWheel={handleWheel}
onWheel={(e) => {
// Check if this is horizontal scrolling - if so, don't handle it here
if (e.shiftKey || Math.abs(e.deltaX) > Math.abs(e.deltaY)) {
return; // Let ScrollArea handle horizontal scrolling
}
handleWheel(e);
}}
onMouseDown={handleSelectionMouseDown}
onClick={handleTimelineContentClick}
data-ruler-area
@ -999,7 +1005,13 @@ export function Timeline() {
{/* Timeline Tracks Content */}
<div
className="flex-1 relative overflow-hidden"
onWheel={handleWheel}
onWheel={(e) => {
// Check if this is horizontal scrolling - if so, don't handle it here
if (e.shiftKey || Math.abs(e.deltaX) > Math.abs(e.deltaY)) {
return; // Let ScrollArea handle horizontal scrolling
}
handleWheel(e);
}}
onMouseDown={(e) => {
handleTimelineMouseDown(e);
handleSelectionMouseDown(e);
@ -1013,7 +1025,7 @@ export function Timeline() {
containerRef={tracksContainerRef}
isActive={selectionBox?.isActive || false}
/>
<ScrollArea className="w-full h-full" ref={tracksScrollRef}>
<ScrollArea className="w-full h-full" ref={tracksScrollRef} type="scroll">
<div
className="relative flex-1"
style={{

View File

@ -18,6 +18,7 @@ const ScrollArea = React.forwardRef<
{children}
</ScrollAreaPrimitive.Viewport>
<ScrollBar />
<ScrollBar orientation="horizontal" />
<ScrollAreaPrimitive.Corner />
</ScrollAreaPrimitive.Root>
));

View File

@ -24,6 +24,12 @@ export function useTimelineZoom({
const delta = e.deltaY > 0 ? -0.15 : 0.15;
setZoomLevel((prev) => Math.max(0.1, Math.min(10, prev + delta)));
}
// For horizontal scrolling (when shift is held or horizontal wheel movement),
// let the event bubble up to allow ScrollArea to handle it
else if (e.shiftKey || Math.abs(e.deltaX) > Math.abs(e.deltaY)) {
// Don't prevent default - let ScrollArea handle horizontal scrolling
return;
}
// Otherwise, allow normal scrolling
}, []);