Modifier is the base class for transforming drag operation coordinates. Modifiers enable features like snapping to grids, restricting movement to specific boundaries, applying physics-based constraints, and implementing custom drag behaviors.
Modifier Class
Constructor
Creates a new modifier instance.T extends DragDropManager
required
The drag and drop manager that owns this modifier.
U extends ModifierOptions
Optional configuration for the modifier.
extends DragDropManager<any, any>
default:"DragDropManager<any, any>"
Type parameter for the drag and drop manager.
extends ModifierOptions
default:"ModifierOptions"
Type parameter for modifier options.
Properties
manager
T
The drag and drop manager instance that this modifier is bound to.
options
U | undefined
The configuration options for this modifier instance.
disabled
boolean
Whether the modifier instance is disabled.Inherited from
Plugin.Methods
apply()
Applies the modifier to the current drag operation.DragOperationSnapshot<any, any>
required
The current state of the drag operation.
Coordinates
The transformed coordinates.
Inherited from Plugin
enable()
Enables a disabled modifier instance.disable()
Disables an enabled modifier instance.isDisabled()
Checks if the modifier instance is disabled.boolean
true if the modifier is disabled.configure()
Configures a modifier instance with new options.U
The new options to apply.
destroy()
Destroys a modifier instance and cleans up its resources.Static Methods
configure()
Configures a modifier constructor with default options.PluginOptions
required
The options to configure the constructor with.
ModifierDescriptor
A configured modifier descriptor that can be passed to the manager or draggable.
Types
ModifierOptions
Base type for modifier options.ModifierConstructor
Constructor type for creating modifier instances.ModifierDescriptor
Descriptor type for configuring modifiers.Modifiers
Array type for multiple modifier configurations.Implementing a Custom Modifier
Basic Implementation
Advanced Implementation
Chaining Modifiers
Modifiers are applied in sequence, with each modifier receiving the output of the previous one:Usage Examples
Using Modifiers with Manager
Per-Draggable Modifiers
Dynamic Modifier Configuration
Conditional Modification
Accessing Operation State
Disable/Enable Modifiers
Common Modifier Patterns
Grid Snapping
Restrict to Container
Axis Lock
Resistance
Snap to Elements
See Also
- DragDropManager - Using modifiers with the manager
- Draggable - Attaching modifiers to draggables
- Sensors - Detecting drag interactions
- Plugins - Base plugin architecture