Class: DragTarget
Defined in: packages/blockly/core/drag_target.ts:23
Abstract class for a component with custom behaviour when a block or bubble is dragged over or dropped on top of it.
Extended by
Implements
Properties index
| Property | Description |
|---|---|
| id | The unique id for this component that is used to register with the ComponentManager. |
Methods index
| Method | Description |
|---|---|
| onDragEnter | Handles when a cursor with a block or bubble enters this drag target. |
| onDragOver | Handles when a cursor with a block or bubble is dragged over this drag target. |
| onDragExit | Handles when a cursor with a block or bubble exits this drag target. |
| onDrop | Handles when a block or bubble is dropped on this component. Should not handle delete here. |
| getClientRect | Returns the bounding rectangle of the drag target area in pixel units relative to the Blockly injection div. |
| shouldPreventMove | 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. |
Constructors
Constructor
new DragTarget(): DragTarget;
Defined in: packages/blockly/core/drag_target.ts:35
Constructor for DragTarget. It exists to add the id property and should not be called directly, only by a subclass.
Returns
DragTarget
Properties
id
id: string;
Defined in: packages/blockly/core/drag_target.ts:29
The unique id for this component that is used to register with the ComponentManager.
Implementation of
Methods
onDragEnter()
onDragEnter(_dragElement): void;
Defined in: packages/blockly/core/drag_target.ts:42
Handles when a cursor with a block or bubble enters this drag target.
Parameters
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The block or bubble currently being dragged. |
Returns
void
Implementation of
onDragOver()
onDragOver(_dragElement): void;
Defined in: packages/blockly/core/drag_target.ts:52
Handles when a cursor with a block or bubble is dragged over this drag target.
Parameters
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The block or bubble currently being dragged. |
Returns
void
Implementation of
onDragExit()
onDragExit(_dragElement): void;
Defined in: packages/blockly/core/drag_target.ts:61
Handles when a cursor with a block or bubble exits this drag target.
Parameters
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The block or bubble currently being dragged. |
Returns
void
Implementation of
onDrop()
onDrop(_dragElement): void;
Defined in: packages/blockly/core/drag_target.ts:70
Handles when a block or bubble is dropped on this component. Should not handle delete here.
Parameters
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The block or bubble currently being dragged. |
Returns
void
Implementation of
getClientRect()
getClientRect(): Rect | null;
Defined in: packages/blockly/core/drag_target.ts:81
Returns the bounding rectangle of the drag target area in pixel units relative to the Blockly injection div.
Returns
Rect | null
The component's bounding box. Null if drag target area should be ignored.
Implementation of
shouldPreventMove()
shouldPreventMove(_dragElement): boolean;
Defined in: packages/blockly/core/drag_target.ts:94
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.
Parameters
| Parameter | Type | Description |
|---|---|---|
_dragElement | IDraggable | The block or bubble currently being dragged. |
Returns
boolean
Whether the block or bubble provided should be returned to drag start.