A library that allows UI to be draggable in/and snappable to the viewport
ts
// Typescript
import { createDragController } from "@rbxts/snapdragon";
const controller = createDragController(gui, {SnapEnabled: true});
controller.Connect() // Attaches the controller to the gui you specify
controller.Disconnect() // Will disconnect the drag controller from the Gui
`
`lua
-- Lua
local Snapdragon = require(snapdragonModule)
local controller = Snapdragon.createDragController(gui, {SnapEnabled = true})
controller:Connect() -- Attaches the controller to the gui you specify
controller:Disconnect() -- Will disconnect the drag controller from the Gui
`
Usage with Roact
If you want to use Snapdragon with Roact, simply use Roact.Ref with the object you want to be draggable, and create and assign a controller in the didMount method to the ref's instance.
FAQ
Why not just use
GuiObject.Draggable?
Draggable` is deprecated. It never worked well and isn't flexible - as discussed here.