Skip to main content

blockly > dragging > BlockDragStrategy

dragging.BlockDragStrategy class

Signature:

export declare class BlockDragStrategy implements IDragStrategy

Implements: IDragStrategy

Constructors

Constructor

Modifiers

Description

(constructor)(block)

Constructs a new instance of the BlockDragStrategy class

Properties

Property

Modifiers

Type

Description

BLOCK_CONNECTION_OFFSET

protected

readonly

(not declared)

block

protected

BlockSvg

connectionPreviewer

protected

IConnectionPreviewer | null

moveMode

protected

MoveMode

The current movement mode.

startLoc

protected

Coordinate | null

WORKSPACE_MARGIN

protected

readonly

(not declared)

How far in from the edges of the workspace to position newly placed blocks.

workspace

protected

WorkspaceSvg

Methods

Method

Modifiers

Description

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.

drag(newLoc, e)

Moves the block and updates any connection previews.

endDrag(_e, disposition)

Cleans up any state at the end of the drag. Applies any pending connections.

findTraversalCandidate(delta)

Get the nearest valid candidate connection in traversal order.

getSearchRadius()

protected

Get the radius to use when searching for a nearby valid connection.

getTargetBlock()

protected

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.

isMovable()

Returns true if the block is currently movable. False otherwise.

positionNewBlock(oldBlock, newBlock)

protected

Positions a cloned block on its new workspace.

revertDrag()

Moves the block back to where it was at the beginning of the drag, including reconnecting connections.

shouldDisconnect(healStack)

protected

Whether or not we should disconnect the block when a drag is started.

shouldHealStack(e)

protected

Get whether the drag should act on a single block or a block stack.

startDrag(e)

Handles any setup for starting the drag, including disconnecting the block from any parent blocks.