Draggable UI

A draggable button written entirely in SwiftUI.

  • Long press the button to unlock dragging.
  • When dragging is unlocked a boundary box is displayed to show where the button can be dropped.
  • Drag the button anywhere in the boundary box.
  • Button snaps to the left and right edges.
  • Dragging the button outside the boundary box snaps it to the nearest point inside the boundary box.
  • The bottom corners of the boundary box are weighted. Dragging the button near the corner snaps to that corner.

Screen.Recording.2023-12-31.at.1.28.44.AM.mov

GitHub

View Github