canvas-ui icon indicating copy to clipboard operation
canvas-ui copied to clipboard

feat(events): implement pointer capture API for drag-and-drop interactions

Open myers opened this issue 2 months ago • 2 comments

Hello! 您好

This PR builds on the work in #35 (HeadlessCanvas). It depends on BridgeEventBinding from #32.

This PR adds DOM-standard pointer capture API to enable proper event routing during drag-and-drop and similar interactions. When a pointer is captured, events are routed directly to the capturing component instead of using hit testing, allowing components to continue receiving events even when the pointer moves outside their bounds.

This is useful for implementing slider components where you want to track pointer movement even when the cursor goes outside the slider's bounds.

Changes:

  • Add setPointerCapture/releasePointerCapture/hasPointerCapture to RenderObject
  • Update SyntheticEventManager to check for captured pointers before hit testing
  • Support independent capture tracking for multiple pointers (multi-touch)
  • Add comprehensive test suite covering capture scenarios
  • Clean up BridgeEventBinding by removing deprecated element capture stubs

myers avatar Oct 28 '25 12:10 myers