Skip to content

Commit f78d28e

Browse files
Revert "fix: bypass get cur block when move scroll into view"
This reverts commit 9657acd.
1 parent 9019851 commit f78d28e

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/actions/mover.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ export class Mover {
5555
*/
5656
private oldDragStrategy: IDragStrategy | null = null;
5757

58-
/**
59-
* The current block being moved, which is set at the start of a move and
60-
* reset at the end of a move.
61-
*/
62-
private currentBlock: BlockSvg | null = null;
63-
6458
constructor(protected navigation: Navigation) {}
6559

6660
/**
@@ -107,7 +101,6 @@ export class Mover {
107101
const cursor = workspace?.getCursor();
108102
const block = this.getCurrentBlock(workspace);
109103
if (!cursor || !block) throw new Error('precondition failure');
110-
this.currentBlock = block;
111104

112105
// Select and focus block.
113106
common.setSelected(block);
@@ -148,13 +141,11 @@ export class Mover {
148141
new utils.Coordinate(0, 0),
149142
);
150143

151-
// Scroll into view after block has finished moving.
152-
setTimeout(() => this.scrollCurrentBlockIntoView(workspace), 0);
153-
154144
this.unpatchWorkspace(workspace);
155145
this.unpatchDragStrategy(info.block);
156146
this.moves.delete(workspace);
157-
this.currentBlock = null;
147+
// Delay scroll until after block has finished moving.
148+
setTimeout(() => this.scrollCurrentBlockIntoView(workspace), 0);
158149
return true;
159150
}
160151

@@ -183,13 +174,11 @@ export class Mover {
183174
new utils.Coordinate(0, 0),
184175
);
185176

186-
// Scroll into view after block has finished moving.
187-
setTimeout(() => this.scrollCurrentBlockIntoView(workspace), 0);
188-
189177
this.unpatchWorkspace(workspace);
190178
this.unpatchDragStrategy(info.block);
191179
this.moves.delete(workspace);
192-
this.currentBlock = null;
180+
// Delay scroll until after block has finished moving.
181+
setTimeout(() => this.scrollCurrentBlockIntoView(workspace), 0);
193182
return true;
194183
}
195184

@@ -328,14 +317,15 @@ export class Mover {
328317
/**
329318
* Scrolls the current block into view if one exists.
330319
*
331-
* @param workspace The workspace to scroll the given bounds into view in.
320+
* @param workspace The workspace to get current block from.
332321
* @param padding Amount of spacing to put between the bounds and the edge of
333322
* the workspace's viewport.
334323
*/
335324
private scrollCurrentBlockIntoView(workspace: WorkspaceSvg, padding = 10) {
336-
if (this.currentBlock) {
325+
const blockToView = this.getCurrentBlock(workspace);
326+
if (blockToView) {
337327
workspace.scrollBoundsIntoView(
338-
this.currentBlock.getBoundingRectangleWithoutChildren(),
328+
blockToView.getBoundingRectangleWithoutChildren(),
339329
padding,
340330
);
341331
}

0 commit comments

Comments
 (0)