Skip to main content
Plugin is the abstract base class for extending drag and drop functionality. Plugins provide a way to add custom features and behaviors to the drag and drop system through a consistent, composable API.

Plugin Class

Constructor

Creates a new plugin instance.
T extends DragDropManager
required
The drag and drop manager that owns this plugin.
U extends PluginOptions
Optional configuration for the plugin.
extends DragDropManager<any, any>
default:"DragDropManager<any, any>"
Type parameter for the drag and drop manager.
extends PluginOptions
default:"PluginOptions"
Type parameter for plugin options.

Properties

manager

T
The drag and drop manager instance that this plugin is bound to.

options

U | undefined
The configuration options for this plugin instance.

disabled

boolean
Whether the plugin instance is disabled.
This property is reactive and triggers effects when accessed or modified.

Methods

enable()

Enables a disabled plugin instance.
This method triggers effects when called.

disable()

Disables an enabled plugin instance.
This method triggers effects when called.

isDisabled()

Checks if the plugin instance is disabled.
boolean
true if the plugin is disabled.
This method does not trigger effects when accessed.

configure()

Configures a plugin instance with new options.
U
The new options to apply.

destroy()

Destroys a plugin instance and cleans up its resources.
This method:
  • Calls all registered cleanup functions
  • Should be overridden by subclasses to clean up additional resources

Protected Methods

registerEffect()

Registers an effect that will be cleaned up when the plugin is destroyed.
() => void
required
The effect callback to register. Should be bound to this.
() => void
A function to dispose of the effect.

Static Methods

configure()

Configures a plugin constructor with default options.
PluginOptions
required
The options to configure the constructor with.
PluginDescriptor
A configured plugin descriptor that can be passed to the manager.
This method is used to configure the options that the plugin constructor will use to create plugin instances.

Types

PluginOptions

Base type for plugin options.

PluginConstructor

Constructor type for creating plugin instances.

PluginDescriptor

Descriptor type for configuring plugins.

Plugins

Array type for multiple plugin configurations.

InferPluginOptions

Infers the options type from a plugin constructor or instance.

InferManager

Infers the manager type from a plugin instance.

CorePlugin Class

Base class for core plugins that ship with the library.
Core plugins follow the same API as regular plugins but are marked as part of the library.

Utility Functions

configure()

Utility function to create a plugin descriptor.
PluginConstructor
required
The plugin constructor.
PluginOptions
required
The options to configure with.
PluginDescriptor
A plugin descriptor.

configurator()

Utility function to create a plugin configurator.

descriptor()

Utility function to extract plugin and options from a descriptor or constructor.
PluginConstructor | PluginDescriptor
required
The plugin constructor or descriptor.
{plugin: PluginConstructor, options?: PluginOptions}
An object containing the plugin constructor and optional options.

Implementing a Custom Plugin

Basic Implementation

With Event Listeners

With State Management

Advanced Plugin with Multiple Features

Usage Examples

Using Plugins with Manager

Configuring Plugins

Per-Draggable Plugins

Extending Defaults

Dynamic Plugin Management

Accessing Plugin Configuration

Plugin Registry

The PluginRegistry class manages plugin instances:
Access via manager:

Common Plugin Patterns

Logging Plugin

Analytics Plugin

Auto-Scroll Plugin

See Also