feat: add basic render queueing (#6851)

* feat: add basic render queueing

* feat: change connecting and disconnecting to queue renders

* feat: delay bringToFront

* chore: format

* chore: fix build

* fix: stop updating connections when setting the parent.

This was causing erroneous block bumps because the connection locations
were changed before the blocks were actually rerendered.

* fix: connection highlight positioning
This commit is contained in:
Beka Westberg
2023-03-01 10:29:01 -08:00
committed by GitHub
parent ae2e6b23c5
commit f2b75fb877
5 changed files with 107 additions and 24 deletions

View File

@@ -230,7 +230,7 @@ export class BlockDragger implements IBlockDragger {
// These are expensive and don't need to be done if we're deleting.
this.draggingBlock_.setDragging(false);
if (delta) { // !preventMove
this.updateBlockAfterMove_(delta);
this.updateBlockAfterMove_();
} else {
// Blocks dragged directly from a flyout may need to be bumped into
// bounds.
@@ -283,18 +283,14 @@ export class BlockDragger implements IBlockDragger {
/**
* Updates the necessary information to place a block at a certain location.
*
* @param delta The change in location from where the block started the drag
* to where it ended the drag.
*/
protected updateBlockAfterMove_(delta: Coordinate) {
this.draggingBlock_.moveConnections(delta.x, delta.y);
protected updateBlockAfterMove_() {
this.fireMoveEvent_();
if (this.draggedConnectionManager_.wouldConnectBlock()) {
// Applying connections also rerenders the relevant blocks.
this.draggedConnectionManager_.applyConnections();
} else {
this.draggingBlock_.render();
this.draggingBlock_.queueRender();
}
this.draggingBlock_.scheduleSnapAndBump();
}