Class: BlockDragStrategy
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:66
Implements
Properties index
| Property | Description |
|---|---|
| workspace | - |
| startLoc | - |
| connectionPreviewer | - |
| moveMode | The current movement mode. |
| BLOCK_CONNECTION_OFFSET | - |
| WORKSPACE_MARGIN | How far in from the edges of the workspace to position newly placed blocks. |
| block | - |
Methods index
| Method | Description |
|---|---|
| isMovable | Returns true if the block is currently movable. False otherwise. |
| positionNewBlock | Positions a cloned block on its new workspace. |
| getTargetBlock | Returns the block to use for the current drag operation. This may create and return a newly instantiated block when e.g. dragging from a flyout. |
| startDrag | Handles any setup for starting the drag, including disconnecting the block from any parent blocks. |
| cacheAllConnectionPairs | Caches a list of all valid connection pairs between the dragging block and any other blocks on the workspace. This is used to determine the closest valid connection during keyboard-driven moves and to determine the need to disambiguate between multiple compatible connections when announcing moves to assistive technologies. |
| shouldHealStack | Get whether the drag should act on a single block or a block stack. |
| shouldDisconnect | Whether or not we should disconnect the block when a drag is started. |
| drag | Moves the block and updates any connection previews. |
| getSearchRadius | Get the radius to use when searching for a nearby valid connection. |
| endDrag | Cleans up any state at the end of the drag. Applies any pending connections. |
| revertDrag | Moves the block back to where it was at the beginning of the drag, including reconnecting connections. |
| findTraversalCandidate | Get the nearest valid candidate connection in traversal order. |
Constructors
Constructor
new BlockDragStrategy(block): BlockDragStrategy;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:117
Parameters
| Parameter | Type |
|---|---|
block | BlockSvg |
Returns
BlockDragStrategy
Properties
workspace
protected workspace: WorkspaceSvg;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:67
startLoc
protected startLoc: Coordinate | null = null;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:78
connectionPreviewer
protected connectionPreviewer:
| IConnectionPreviewer
| null = null;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:82
moveMode
protected moveMode: MoveMode = MoveMode.UNCONSTRAINED;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:90
The current movement mode.
BLOCK_CONNECTION_OFFSET
protected readonly BLOCK_CONNECTION_OFFSET: 10 = 10;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:110
WORKSPACE_MARGIN
protected readonly WORKSPACE_MARGIN: 10 = 10;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:115
How far in from the edges of the workspace to position newly placed blocks.
block
protected block: BlockSvg;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:117
Methods
isMovable()
isMovable(): boolean;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:122
Returns true if the block is currently movable. False otherwise.
Returns
boolean
Implementation of
positionNewBlock()
protected positionNewBlock(oldBlock, newBlock): void;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:139
Positions a cloned block on its new workspace.
Parameters
| Parameter | Type | Description |
|---|---|---|
oldBlock | BlockSvg | The flyout block that was cloned. |
newBlock | BlockSvg | The new block to position. |
Returns
void
getTargetBlock()
protected getTargetBlock(): BlockSvg;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:242
Returns the block to use for the current drag operation. This may create and return a newly instantiated block when e.g. dragging from a flyout.
Returns
startDrag()
startDrag(e?): IDraggable;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:344
Handles any setup for starting the drag, including disconnecting the block from any parent blocks.
Parameters
| Parameter | Type |
|---|---|
e? | PointerEvent | KeyboardEvent |
Returns
Implementation of
cacheAllConnectionPairs()
cacheAllConnectionPairs(): void;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:431
Caches a list of all valid connection pairs between the dragging block and any other blocks on the workspace. This is used to determine the closest valid connection during keyboard-driven moves and to determine the need to disambiguate between multiple compatible connections when announcing moves to assistive technologies.
Returns
void
shouldHealStack()
protected shouldHealStack(e): boolean;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:486
Get whether the drag should act on a single block or a block stack.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | PointerEvent | KeyboardEvent | undefined | The instigating pointer or keyboard event, if any. |
Returns
boolean
True if just the initial block should be dragged out, false if all following blocks should also be dragged.
shouldDisconnect()
protected shouldDisconnect(healStack): boolean;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:506
Whether or not we should disconnect the block when a drag is started.
Parameters
| Parameter | Type | Description |
|---|---|---|
healStack | boolean | Whether or not to heal the stack after disconnecting. |
Returns
boolean
True to disconnect the block, false otherwise.
drag()
drag(newLoc, e?): void;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:607
Moves the block and updates any connection previews.
Parameters
| Parameter | Type |
|---|---|
newLoc | Coordinate |
e? | PointerEvent | KeyboardEvent |
Returns
void
Implementation of
getSearchRadius()
protected getSearchRadius(): number;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:876
Get the radius to use when searching for a nearby valid connection.
Returns
number
endDrag()
endDrag(_e, disposition): void;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:921
Cleans up any state at the end of the drag. Applies any pending connections.
Parameters
| Parameter | Type |
|---|---|
_e | PointerEvent | KeyboardEvent | undefined |
disposition | DragDisposition |
Returns
void
Implementation of
revertDrag()
revertDrag(): void;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:1015
Moves the block back to where it was at the beginning of the drag, including reconnecting connections.
Returns
void
Implementation of
findTraversalCandidate()
findTraversalCandidate(delta): ConnectionCandidate | null;
Defined in: packages/blockly/core/dragging/block_drag_strategy.ts:1070
Get the nearest valid candidate connection in traversal order.
Parameters
| Parameter | Type | Description |
|---|---|---|
delta | Coordinate | The distance the block has moved since this drag began. |
Returns
ConnectionCandidate | null
A candidate connection and radius, or null if none was found.