mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
Merge pull request [#395](https://github.com/mazeincoding/AppCut/issues/395)
This commit is contained in:
@@ -878,7 +878,13 @@ export function Timeline() {
|
|||||||
{/* Timeline Ruler */}
|
{/* Timeline Ruler */}
|
||||||
<div
|
<div
|
||||||
className="flex-1 relative overflow-hidden h-4"
|
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}
|
onMouseDown={handleSelectionMouseDown}
|
||||||
onClick={handleTimelineContentClick}
|
onClick={handleTimelineContentClick}
|
||||||
data-ruler-area
|
data-ruler-area
|
||||||
@@ -999,7 +1005,13 @@ export function Timeline() {
|
|||||||
{/* Timeline Tracks Content */}
|
{/* Timeline Tracks Content */}
|
||||||
<div
|
<div
|
||||||
className="flex-1 relative overflow-hidden"
|
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) => {
|
onMouseDown={(e) => {
|
||||||
handleTimelineMouseDown(e);
|
handleTimelineMouseDown(e);
|
||||||
handleSelectionMouseDown(e);
|
handleSelectionMouseDown(e);
|
||||||
@@ -1013,7 +1025,12 @@ export function Timeline() {
|
|||||||
containerRef={tracksContainerRef}
|
containerRef={tracksContainerRef}
|
||||||
isActive={selectionBox?.isActive || false}
|
isActive={selectionBox?.isActive || false}
|
||||||
/>
|
/>
|
||||||
<ScrollArea className="w-full h-full" ref={tracksScrollRef}>
|
<ScrollArea
|
||||||
|
className="w-full h-full"
|
||||||
|
ref={tracksScrollRef}
|
||||||
|
type="scroll"
|
||||||
|
showHorizontalScrollbar
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
className="relative flex-1"
|
className="relative flex-1"
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -7,17 +7,22 @@ import { cn } from "../../lib/utils";
|
|||||||
|
|
||||||
const ScrollArea = React.forwardRef<
|
const ScrollArea = React.forwardRef<
|
||||||
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & {
|
||||||
>(({ className, children, ...props }, ref) => (
|
type?: "auto" | "always" | "scroll" | "hover";
|
||||||
|
showHorizontalScrollbar?: boolean;
|
||||||
|
}
|
||||||
|
>(({ className, children, type, showHorizontalScrollbar, ...props }, ref) => (
|
||||||
<ScrollAreaPrimitive.Root
|
<ScrollAreaPrimitive.Root
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn("relative overflow-hidden", className)}
|
className={cn("relative overflow-hidden", className)}
|
||||||
|
type={type}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
||||||
{children}
|
{children}
|
||||||
</ScrollAreaPrimitive.Viewport>
|
</ScrollAreaPrimitive.Viewport>
|
||||||
<ScrollBar />
|
<ScrollBar />
|
||||||
|
{showHorizontalScrollbar && <ScrollBar orientation="horizontal" />}
|
||||||
<ScrollAreaPrimitive.Corner />
|
<ScrollAreaPrimitive.Corner />
|
||||||
</ScrollAreaPrimitive.Root>
|
</ScrollAreaPrimitive.Root>
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ export function useTimelineZoom({
|
|||||||
const delta = e.deltaY > 0 ? -0.15 : 0.15;
|
const delta = e.deltaY > 0 ? -0.15 : 0.15;
|
||||||
setZoomLevel((prev) => Math.max(0.1, Math.min(10, prev + delta)));
|
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
|
// Otherwise, allow normal scrolling
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user