Live Interactive Demo Model
Drag the Ball
A ball you can grab and drag around a box with mouse coordinates that never goes outside the borders.
Drag the Ball
Acceptance Criteria
Tracking mouse movements with onMouseMove
Clamping coordinates so the ball stays inside bounds
Handling mouse down and mouse up drag lifecycle
Target APIs & Concepts
Mouse CoordinatesBoundary LimitsCSS Transforms
Ready to code this yourself? Switch to the Candidate Code Studio to write your implementation in React 19 and run automated test evaluations!