Skip to main content

Drag Bounds

Demonstrates dragBoundsRef — constraining a dragged view within a parent boundary.

Key Concepts

  • dragBoundsRef — ref to the constraining view
  • Clamped on UI thread — bounds enforced in the gesture worklet
  • Full view inside bounds — accounts for view dimensions

Features Shown

FeatureHow
dragBoundsRefConstrains drag within the referenced view
Bounded vs freeSide-by-side comparison
Visual boundaryVisible border showing the constraint area

Source Code

example/app/(tabs)/bounded-drag.tsx
// Full source available at:
// https://github.com/nuclearpasta/react-native-drax/blob/main/example/app/(tabs)/bounded-drag.tsx