Skip to content

Commit e635e0d

Browse files
committed
refactor: Make block connection offset a constant
1 parent e1fb671 commit e635e0d

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

packages/blockly/core/dragging/block_drag_strategy.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export class BlockDragStrategy implements IDragStrategy {
8383
/** Used to persist an event group when snapping is done async. */
8484
private originalEventGroup = '';
8585

86+
protected readonly BLOCK_CONNECTION_OFFSET = 10;
87+
8688
constructor(private block: BlockSvg) {
8789
this.workspace = block.workspace;
8890
}
@@ -151,9 +153,15 @@ export class BlockDragStrategy implements IDragStrategy {
151153
let offset: Coordinate;
152154
if (neighbour.type === ConnectionType.PREVIOUS_STATEMENT) {
153155
const origin = this.block.getRelativeToSurfaceXY();
154-
offset = new Coordinate(origin.x + 10, origin.y - 10);
156+
offset = new Coordinate(
157+
origin.x + this.BLOCK_CONNECTION_OFFSET,
158+
origin.y - this.BLOCK_CONNECTION_OFFSET,
159+
);
155160
} else {
156-
offset = new Coordinate(neighbour.x + 10, neighbour.y + 10);
161+
offset = new Coordinate(
162+
neighbour.x + this.BLOCK_CONNECTION_OFFSET,
163+
neighbour.y + this.BLOCK_CONNECTION_OFFSET,
164+
);
157165
}
158166
this.block.moveDuringDrag(offset);
159167
}
@@ -291,7 +299,10 @@ export class BlockDragStrategy implements IDragStrategy {
291299
// Position the moving block down and slightly to the right of the
292300
// target connection.
293301
this.block.moveDuringDrag(
294-
new Coordinate(neighbour.x + 10, neighbour.y + 10),
302+
new Coordinate(
303+
neighbour.x + this.BLOCK_CONNECTION_OFFSET,
304+
neighbour.y + this.BLOCK_CONNECTION_OFFSET,
305+
),
295306
);
296307
}
297308
} else {

0 commit comments

Comments
 (0)