Skip to main content

Interceptors

Interceptors are events from which you can return values that affect what jsPlumb does next, for instance preventing the detachment of a connection, or preventing a connection from being dropped.

beforeDrop#

This interceptor is fired when a new or existing connection has been dropped on a target endpoint or element.

instance.bind(INTERCEPTOR_DEFORE_DROP, (params:BeforeDropParams) => {   ...});

The callback method is defined as:

Home > @jsplumb/browser-ui > BeforeConnectionDropInterceptor

BeforeConnectionDropInterceptor type#

Defines the method signature for the callback to the beforeDrop interceptor.

Signature:

export declare type BeforeConnectionDropInterceptor = (params: BeforeDropParams) => boolean;

References: BeforeDropParams

BeforeDropParams has this definition:

Home > @jsplumb/browser-ui > BeforeDropParams

BeforeDropParams interface#

Definition of the parameters passed to the beforeDrop interceptor.

Signature:

export interface BeforeDropParams 

Properties#

PropertyTypeDescription
connectionConnection
dropEndpointEndpoint
scopestring
sourceIdstring
targetIdstring

Any return value other than boolean true will result in the new Connection being aborted and removed from the UI.


beforeDetach#

Fired prior to an existing connection being detached. Returning false from this method prevents the connection from being detached. The interceptor is fired by the core, meaning that it will be invoked regardless of whether the detach occurred programmatically, or via the mouse.

instance.bind(INTERCEPTOR_BEFORE_DETACH, (connection:Connection) => {   ...});

This event is fired when a Connection is about to be detached, for whatever reason. Your callback function is passed the Connection that the user has just detached. Returning false from this interceptor aborts the Connection detach.

The callback method is defined as:

Home > @jsplumb/browser-ui > BeforeConnectionDetachInterceptor

BeforeConnectionDetachInterceptor type#

Defines the method signature for the callback to the beforeDetach interceptor. Returning false from this method prevents the connection from being detached. The interceptor is fired by the core, meaning that it will be invoked regardless of whether the detach occurred programmatically, or via the mouse.

Signature:

export declare type BeforeConnectionDetachInterceptor = (c: Connection) => boolean;

References: Connection


beforeDrag#

Fired prior to a new connection being dragged. You can either abort the connection, ignore it, or provide a payload to use as the connection's data.

instance.bind(INTERCEPTOR_BEFORE_DRAG, (params:BeforeDragParams) => {   ...});

The callback method is defined as:

Home > @jsplumb/browser-ui > BeforeDragInterceptor

BeforeDragInterceptor type#

Defines the method signature for the callback to the beforeDrag interceptor. This method can return boolean false to abort the connection drag, or it can return an object containing values that will be used as the data for the connection that is created.

Signature:

export declare type BeforeDragInterceptor<E = any> = (params: BeforeDragParams<E>) => boolean | Record<string, any>;

References: BeforeDragParams

and the payload to the method is:

Home > @jsplumb/browser-ui > BeforeDragParams

BeforeDragParams interface#

The parameters passed to a beforeDrag interceptor.

Signature:

export interface BeforeDragParams<E> 

Properties#

PropertyTypeDescription
connectionConnection
endpointEndpoint
sourceE
sourceIdstring

beforeStartDetach#

Fired prior to an existing connection being detached. Returning false from your interceptor will result in the connection not being detached.

instance.bind(INTERCEPTOR_BEFORE_START_DETACH, (params:BeforeStartDetachParams) => {   ...});

The callback method is defined as:

Home > @jsplumb/browser-ui > BeforeStartConnectionDetachInterceptor

BeforeStartConnectionDetachInterceptor type#

Defines the method signature for the callback to the beforeStartDetach interceptor.

Signature:

export declare type BeforeStartConnectionDetachInterceptor<E = any> = (params: BeforeStartConnectionDetachParams<E>) => boolean;

References: BeforeStartConnectionDetachParams

and the payload to the method is:

Home > @jsplumb/browser-ui > BeforeStartConnectionDetachParams

BeforeStartConnectionDetachParams interface#

The parameters passed to a beforeStartDetach interceptor.

Signature:

export interface BeforeStartConnectionDetachParams<E> extends BeforeDragParams<E> 

Extends: BeforeDragParams<E>