Function

useTimelineKeyframeDrag

Headless keyframe drag behavior shared by canvas and custom timeline UIs.

Usage notes

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 useTimelineKeyframes for keyframe geometry.

Signature

Type Definition
useTimelineKeyframeDrag(options: UseTimelineKeyframeDragOptions = {}): UseTimelineKeyframeDragResult

Parameters

NameTypeDescription
optionsUseTimelineKeyframeDragOptionsDrag geometry aligned with the renderer and hit-test layer.

Returns

Keyframe drag state and pointer command helpers.

Examples

tsx Example
import { useTimelineKeyframeDrag } from '#react/hooks';
export function KeyframeHandle({ clipId, keyframeId }: { clipId: string; keyframeId: string }) {
const drag = useTimelineKeyframeDrag();
return (
<button
type="button"
aria-pressed={drag.dragging}
onPointerDown={(event) =>
drag.startKeyframeDrag({
clipId,
keyframeId,
clientX: event.clientX,
viewportY: event.nativeEvent.offsetY,
})
}
>
Move keyframe
</button>
);
}