blockly > DragTarget

DragTarget class

Abstract class for a component with custom behaviour when a block or bubble is dragged over or dropped on top of it.

Signature:

export declare class DragTarget implements IDragTarget 

Implements: IDragTarget

Constructors

Constructor Modifiers Description
(constructor)() Constructor for DragTarget. It exists to add the id property and should not be called directly, only by a subclass.

Properties

Property Modifiers Type Description
id string The unique id for this component that is used to register with the ComponentManager.

Methods

Method Modifiers Description
getClientRect() Returns the bounding rectangle of the drag target area in pixel units relative to the Blockly injection div.
onDragEnter(_dragElement) Handles when a cursor with a block or bubble enters this drag target.
onDragExit(_dragElement) Handles when a cursor with a block or bubble exits this drag target.
onDragOver(_dragElement) Handles when a cursor with a block or bubble is dragged over this drag target.
onDrop(_dragElement) Handles when a block or bubble is dropped on this component. Should not handle delete here.
shouldPreventMove(_dragElement) Returns whether the provided block or bubble should not be moved after being dropped on this component. If true, the element will return to where it was when the drag started.