# shopify/draggable architecture

> Architecture diagram of the GitHub repository shopify/draggable, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shopify/draggable
- Repository: https://github.com/shopify/draggable

## Overview

Draggable is a browser drag-and-drop library: input sensors detect native, mouse, touch, or force-touch gestures; the Draggable engine turns sensor activity into drag lifecycle events and manages mirrors and plugins; higher-level modules add sorting, dropping, and swapping. The README documents the broader plugin capabilities. Some plugin and sensor implementations were not sampled, so their links are included only where the README or SOURCE INDEX supports them; no storage or external service is involved.

Main entry points: [`src/Draggable/Draggable.js`](https://github.com/shopify/draggable/blob/main/src/Draggable/Draggable.js) (Draggable engine), [`src/Draggable/DragEvent/DragEvent.ts`](https://github.com/shopify/draggable/blob/main/src/Draggable/DragEvent/DragEvent.ts) (Drag lifecycle events), [`src/index.js`](https://github.com/shopify/draggable/blob/main/src/index.js) (Public API exports), [`src/Sortable/Sortable.js`](https://github.com/shopify/draggable/blob/main/src/Sortable/Sortable.js) (Sortable behavior)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Gesture input"]
  node_mouse["Mouse sensor<br/>[MouseSensor.js]"]
  node_touch["Touch sensor<br/>[TouchSensor.js]"]
  node_native["Native drag sensor<br/>[DragSensor.js]"]
  node_force["Force-touch sensor"]
  node_sensorbase["Sensor base and events<br/>[Sensor.js]"]
end

subgraph group_engine["Drag engine"]
  node_draggable["Draggable engine<br/>[Draggable.js]"]
  node_drag_events["Drag lifecycle events<br/>[DragEvent.ts]"]
  node_draggable_events["Engine events<br/>[DraggableEvent.ts]"]
  node_emitter["Event emitter<br/>[Emitter.ts]"]
  node_mirror["Drag mirror<br/>[Mirror.js]"]
  node_builtin_plugins["Built-in plugins"]
end

subgraph group_behaviors["Drag behaviors"]
  node_sortable["Sortable behavior<br/>[Sortable.js]"]
  node_droppable["Droppable behavior<br/>[Droppable.js]"]
  node_swappable["Swappable behavior<br/>[Swappable.js]"]
end

subgraph group_extensions["Plugins and extensions"]
  node_collidable["Collision detection<br/>[Collidable.js]"]
  node_snappable["Snap behavior<br/>[Snappable.js]"]
  node_resize["Mirror resizing<br/>[ResizeMirror.ts]"]
  node_sort_anim["Sort animation<br/>[SortAnimation.js]"]
  node_swap_anim["Swap animation<br/>[SwapAnimation.ts]"]
end

subgraph group_foundation["Shared foundation"]
  node_abstract_event["Base event<br/>[AbstractEvent.ts]"]
  node_abstract_plugin["Base plugin<br/>[AbstractPlugin.ts]"]
  node_exports["Public API exports<br/>[index.js]"]
end

node_user(("Browser user"))

node_user -->|"uses"| node_mouse
node_user -->|"uses"| node_touch
node_user -->|"uses"| node_native
node_user -->|"uses"| node_force
node_mouse -.->|"extends"| node_sensorbase
node_touch -.->|"extends"| node_sensorbase
node_native -->|"extends"| node_sensorbase
node_force -.->|"extends"| node_sensorbase
node_draggable -->|"attaches"| node_mouse
node_draggable -->|"attaches"| node_touch
node_native -->|"emits sensor events"| node_draggable
node_draggable -->|"creates"| node_drag_events
node_draggable -->|"dispatches through"| node_emitter
node_draggable -->|"creates"| node_draggable_events
node_draggable -->|"manages"| node_mirror
node_draggable -->|"supports"| node_builtin_plugins
node_sortable -->|"extends"| node_draggable
node_sortable -->|"handles"| node_drag_events
node_droppable -->|"extends"| node_draggable
node_droppable -->|"handles"| node_drag_events
node_swappable -->|"extends"| node_draggable
node_swappable -->|"handles"| node_drag_events
node_collidable -.->|"extends collision events"| node_drag_events
node_snappable -.->|"extends behavior"| node_draggable
node_resize -.->|"resizes"| node_mirror
node_sort_anim -.->|"animates sorting"| node_sortable
node_swap_anim -.->|"animates swapping"| node_swappable
node_draggable -.->|"uses base events"| node_abstract_event
node_builtin_plugins -.->|"uses base plugin"| node_abstract_plugin
node_exports -->|"exports"| node_draggable
node_exports -->|"exports"| node_sortable
node_exports -->|"exports"| node_droppable
node_exports -->|"exports"| node_swappable

click node_mouse "https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/MouseSensor/MouseSensor.js"
click node_touch "https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/TouchSensor/TouchSensor.js"
click node_native "https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/DragSensor/DragSensor.js"
click node_force "https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/ForceTouchSensor/ForceTouchSensor.js"
click node_sensorbase "https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/Sensor/Sensor.js"
click node_draggable "https://github.com/shopify/draggable/blob/main/src/Draggable/Draggable.js"
click node_drag_events "https://github.com/shopify/draggable/blob/main/src/Draggable/DragEvent/DragEvent.ts"
click node_draggable_events "https://github.com/shopify/draggable/blob/main/src/Draggable/DraggableEvent/DraggableEvent.ts"
click node_emitter "https://github.com/shopify/draggable/blob/main/src/Draggable/Emitter/Emitter.ts"
click node_mirror "https://github.com/shopify/draggable/blob/main/src/Draggable/Plugins/Mirror/Mirror.js"
click node_builtin_plugins "https://github.com/shopify/draggable/tree/main/src/Draggable/Plugins"
click node_sortable "https://github.com/shopify/draggable/blob/main/src/Sortable/Sortable.js"
click node_droppable "https://github.com/shopify/draggable/blob/main/src/Droppable/Droppable.js"
click node_swappable "https://github.com/shopify/draggable/blob/main/src/Swappable/Swappable.js"
click node_collidable "https://github.com/shopify/draggable/blob/main/src/Plugins/Collidable/Collidable.js"
click node_snappable "https://github.com/shopify/draggable/blob/main/src/Plugins/Snappable/Snappable.js"
click node_resize "https://github.com/shopify/draggable/blob/main/src/Plugins/ResizeMirror/ResizeMirror.ts"
click node_sort_anim "https://github.com/shopify/draggable/blob/main/src/Plugins/SortAnimation/SortAnimation.js"
click node_swap_anim "https://github.com/shopify/draggable/blob/main/src/Plugins/SwapAnimation/SwapAnimation.ts"
click node_abstract_event "https://github.com/shopify/draggable/blob/main/src/shared/AbstractEvent/AbstractEvent.ts"
click node_abstract_plugin "https://github.com/shopify/draggable/blob/main/src/shared/AbstractPlugin/AbstractPlugin.ts"
click node_exports "https://github.com/shopify/draggable/blob/main/src/index.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mouse,node_touch,node_native,node_force,node_sensorbase,node_user toneBlue
class node_draggable,node_drag_events,node_draggable_events,node_emitter,node_mirror,node_builtin_plugins toneAmber
class node_sortable,node_droppable,node_swappable toneMint
class node_collidable,node_snappable,node_resize,node_sort_anim,node_swap_anim toneRose
class node_abstract_event,node_abstract_plugin,node_exports toneIndigo
```

## Components

### Gesture input

- [Mouse sensor](https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/MouseSensor/MouseSensor.js): `src/Draggable/Sensors/MouseSensor/MouseSensor.js`
- [Touch sensor](https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/TouchSensor/TouchSensor.js): `src/Draggable/Sensors/TouchSensor/TouchSensor.js`
- [Native drag sensor](https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/DragSensor/DragSensor.js): `src/Draggable/Sensors/DragSensor/DragSensor.js`
- [Force-touch sensor](https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/ForceTouchSensor/ForceTouchSensor.js): `src/Draggable/Sensors/ForceTouchSensor/ForceTouchSensor.js`
- [Sensor base and events](https://github.com/shopify/draggable/blob/main/src/Draggable/Sensors/Sensor/Sensor.js): `src/Draggable/Sensors/Sensor/Sensor.js`

### Drag engine

- [Draggable engine](https://github.com/shopify/draggable/blob/main/src/Draggable/Draggable.js): `src/Draggable/Draggable.js`
- [Drag lifecycle events](https://github.com/shopify/draggable/blob/main/src/Draggable/DragEvent/DragEvent.ts): `src/Draggable/DragEvent/DragEvent.ts`
- [Engine events](https://github.com/shopify/draggable/blob/main/src/Draggable/DraggableEvent/DraggableEvent.ts): `src/Draggable/DraggableEvent/DraggableEvent.ts`
- [Event emitter](https://github.com/shopify/draggable/blob/main/src/Draggable/Emitter/Emitter.ts): `src/Draggable/Emitter/Emitter.ts`
- [Drag mirror](https://github.com/shopify/draggable/blob/main/src/Draggable/Plugins/Mirror/Mirror.js): `src/Draggable/Plugins/Mirror/Mirror.js`
- [Built-in plugins](https://github.com/shopify/draggable/tree/main/src/Draggable/Plugins): `src/Draggable/Plugins`

### Drag behaviors

- [Sortable behavior](https://github.com/shopify/draggable/blob/main/src/Sortable/Sortable.js): `src/Sortable/Sortable.js`
- [Droppable behavior](https://github.com/shopify/draggable/blob/main/src/Droppable/Droppable.js): `src/Droppable/Droppable.js`
- [Swappable behavior](https://github.com/shopify/draggable/blob/main/src/Swappable/Swappable.js): `src/Swappable/Swappable.js`

### Plugins and extensions

- [Collision detection](https://github.com/shopify/draggable/blob/main/src/Plugins/Collidable/Collidable.js): `src/Plugins/Collidable/Collidable.js`
- [Snap behavior](https://github.com/shopify/draggable/blob/main/src/Plugins/Snappable/Snappable.js): `src/Plugins/Snappable/Snappable.js`
- [Mirror resizing](https://github.com/shopify/draggable/blob/main/src/Plugins/ResizeMirror/ResizeMirror.ts): `src/Plugins/ResizeMirror/ResizeMirror.ts`
- [Sort animation](https://github.com/shopify/draggable/blob/main/src/Plugins/SortAnimation/SortAnimation.js): `src/Plugins/SortAnimation/SortAnimation.js`
- [Swap animation](https://github.com/shopify/draggable/blob/main/src/Plugins/SwapAnimation/SwapAnimation.ts): `src/Plugins/SwapAnimation/SwapAnimation.ts`

### Shared foundation

- [Base event](https://github.com/shopify/draggable/blob/main/src/shared/AbstractEvent/AbstractEvent.ts): `src/shared/AbstractEvent/AbstractEvent.ts`
- [Base plugin](https://github.com/shopify/draggable/blob/main/src/shared/AbstractPlugin/AbstractPlugin.ts): `src/shared/AbstractPlugin/AbstractPlugin.ts`
- [Public API exports](https://github.com/shopify/draggable/blob/main/src/index.js): `src/index.js`

### Other components

- **Browser user**

## Connections

- Browser user → Mouse sensor: uses (evidence: `README.md`)
- Browser user → Touch sensor: uses (evidence: `README.md`)
- Browser user → Native drag sensor: uses (evidence: `README.md`)
- Browser user → Force-touch sensor: uses (evidence: `README.md`)
- Mouse sensor → Sensor base and events: extends
- Touch sensor → Sensor base and events: extends
- Native drag sensor → Sensor base and events: extends (evidence: `src/Draggable/Sensors/DragSensor/DragSensor.js`)
- Force-touch sensor → Sensor base and events: extends
- Draggable engine → Mouse sensor: attaches (evidence: `src/Draggable/Draggable.js`)
- Draggable engine → Touch sensor: attaches (evidence: `src/Draggable/Draggable.js`)
- Native drag sensor → Draggable engine: emits sensor events (evidence: `src/Draggable/Sensors/DragSensor/DragSensor.js`)
- Draggable engine → Drag lifecycle events: creates (evidence: `src/Draggable/Draggable.js`)
- Draggable engine → Event emitter: dispatches through (evidence: `src/Draggable/Draggable.js`)
- Draggable engine → Engine events: creates (evidence: `src/Draggable/Draggable.js`)
- Draggable engine → Drag mirror: manages (evidence: `README.md`)
- Draggable engine → Built-in plugins: supports (evidence: `README.md`)
- Sortable behavior → Draggable engine: extends (evidence: `src/Sortable/Sortable.js`)
- Sortable behavior → Drag lifecycle events: handles (evidence: `src/Sortable/Sortable.js`)
- Droppable behavior → Draggable engine: extends (evidence: `src/Droppable/Droppable.js`)
- Droppable behavior → Drag lifecycle events: handles (evidence: `src/Droppable/Droppable.js`)
- Swappable behavior → Draggable engine: extends (evidence: `src/Swappable/Swappable.js`)
- Swappable behavior → Drag lifecycle events: handles (evidence: `src/Swappable/Swappable.js`)
- Collision detection → Drag lifecycle events: extends collision events
- Snap behavior → Draggable engine: extends behavior
- Mirror resizing → Drag mirror: resizes
- Sort animation → Sortable behavior: animates sorting
- Swap animation → Swappable behavior: animates swapping
- Draggable engine → Base event: uses base events
- Built-in plugins → Base plugin: uses base plugin
- Public API exports → Draggable engine: exports (evidence: `src/index.js`)
- Public API exports → Sortable behavior: exports (evidence: `src/index.js`)
- Public API exports → Droppable behavior: exports (evidence: `src/index.js`)
- Public API exports → Swappable behavior: exports (evidence: `src/index.js`)
