ES Drager

Event Handlers

ES Drager provides a rich set of event handlers to help you build interactive interfaces.

Basic Events

EventTypeDescription
onClick() => voidCalled when the element is clicked
onBlur() => voidCalled when the element loses focus

Drag Events

EventTypeDescription
onDragStart() => voidCalled when dragging begins
onDrag(position: { x: number; y: number }) => voidCalled continuously while dragging with current position
onDragEnd(position: { x: number; y: number }) => voidCalled when dragging ends with final position

Transform Events

EventTypeDescription
onRotate(rotation: number) => voidCalled when rotation changes with current angle in degrees
onScale(scale: number) => voidCalled when scale changes with current scale factor
onResize(size: { width: number; height: number }) => voidCalled when size changes with new dimensions

Connection Events

EventTypeDescription
onConnect(connection: { sourceId: string; sourceAnchor: string; targetId: string; targetAnchor: string }) => voidCalled when a connection is established between two elements

Usage Example

<Drager
  onClick={() => console.log('clicked')}
  onDragStart={() => console.log('drag started')}
  onDrag={(pos) => console.log('dragging at:', pos)}
  onDragEnd={(pos) => console.log('dropped at:', pos)}
  onRotate={(angle) => console.log('rotated to:', angle)}
  onResize={(size) => console.log('resized to:', size)}
  onConnect={(connection) => console.log('connected:', connection)}
>
  Content
</Drager>