import { RationalTime, TimecodeFrameRate } from "@techsquidtv/canvas-timeline-utils"; import { TimelineCommandResult, TimelineInteractionGeometry, TimelineKeyframeRect } from "@techsquidtv/canvas-timeline-core"; //#region src/hooks/keyframes/useTimelineKeyframeDrag.d.ts /** Pointer data needed to begin a keyframe drag. */ interface TimelineKeyframeDragStartInput { /** Clip owning the keyframe. */ clipId: string; /** Keyframe being dragged. */ keyframeId: string; /** Pointer client X captured at drag start. */ clientX: number; /** Pointer Y in timeline viewport coordinates, including the ruler area. */ viewportY: number; /** Optional keyframe rect from the initiating hit test. */ keyframeRect?: TimelineKeyframeRect; } /** Pointer data needed to update a keyframe drag. */ interface TimelineKeyframeDragMoveInput { /** Constrain movement to one axis. */ axis?: 'time' | 'value'; /** Reduce movement to one tenth for precision edits. */ fine?: boolean; /** Temporarily bypass snapping. */ snap?: boolean; /** Current pointer client X. */ clientX: number; /** Current pointer Y in timeline viewport coordinates, including the ruler area. */ viewportY: number; } /** * Options accepted by `useTimelineKeyframeDrag`. * * @remarks * * Geometry must match the renderer or keyframe interaction layer so horizontal * pointer movement maps to timeline time and vertical movement maps to property * value consistently. The hook edits values in preview mode while dragging and * settles history when the drag ends. * * @see {@link useTimelineKeyframes} * @see {@link https://canvastimeline.com/docs/keyframes | Keyframes} */ interface UseTimelineKeyframeDragOptions extends TimelineInteractionGeometry { /** Frame grid; defaults to the engine frame rate, or 30 fps when unset. */ frameRate?: TimecodeFrameRate; /** Keyframe affordance size in CSS pixels. Defaults to engine geometry. */ keyframeSize?: number; /** Vertical padding used when mapping property values into a clip row. Defaults to engine geometry. */ keyframeValuePadding?: number; } /** Result returned by `useTimelineKeyframeDrag`. */ interface UseTimelineKeyframeDragResult { /** Whether a keyframe drag is currently active. */ dragging: boolean; /** Starts a keyframe drag. */ startKeyframeDrag: (input: TimelineKeyframeDragStartInput) => TimelineCommandResult; /** Updates the active keyframe drag preview. */ moveKeyframeDrag: (input: TimelineKeyframeDragMoveInput) => TimelineCommandResult; /** Ends the active keyframe drag and settles history. */ endKeyframeDrag: () => TimelineCommandResult; /** Cancels the drag and restores the committed state without an undo entry. */ cancelKeyframeDrag: () => TimelineCommandResult; } /** Successful keyframe drag update payload. */ interface TimelineKeyframeDragUpdate { /** Clip owning the keyframe. */ clipId: string; /** Keyframe being dragged. */ keyframeId: string; /** Updated timeline time. */ time: RationalTime; /** Updated property value. */ value: number; } /** * Headless keyframe drag behavior shared by canvas and custom timeline UIs. * * @remarks * * Use this hook when building custom DOM or canvas hit targets for keyframe * points. The hook owns drag lifecycle, preview updates, value mapping, and * settle behavior. It intentionally does not render handles; pair it with * {@link useTimelineKeyframeGeometry} for keyframe geometry. * * @param options - Drag geometry aligned with the renderer and hit-test layer. * @returns Keyframe drag state and pointer command helpers. * * @example * ```tsx * import { useTimelineKeyframeDrag } from '@techsquidtv/canvas-timeline-react'; * * export function KeyframeHandle({ clipId, keyframeId }: { clipId: string; keyframeId: string }) { * const drag = useTimelineKeyframeDrag(); * * return ( * * ); * } * ``` * * @see {@link useTimelineKeyframes} * @see {@link https://canvastimeline.com/demos/keyframe-opacity | Keyframe opacity demo} */ declare function useTimelineKeyframeDrag(options?: UseTimelineKeyframeDragOptions): UseTimelineKeyframeDragResult; //#endregion export { TimelineKeyframeDragMoveInput, TimelineKeyframeDragStartInput, TimelineKeyframeDragUpdate, UseTimelineKeyframeDragOptions, UseTimelineKeyframeDragResult, useTimelineKeyframeDrag }; //# sourceMappingURL=useTimelineKeyframeDrag.d.mts.map