chore: cleanup render management (#6883)

This commit is contained in:
Beka Westberg
2023-03-13 09:27:21 -07:00
committed by GitHub
parent 67dd6dfe00
commit 435b0b92ee
3 changed files with 15 additions and 13 deletions

View File

@@ -194,9 +194,13 @@ export class InsertionMarkerManager {
blockAnimations.connectionUiEffect(inferiorConnection.getSourceBlock());
// Bring the just-edited stack to the front.
const rootBlock = this.topBlock.getRootBlock();
setTimeout(() => {
rootBlock.bringToFront();
}, 0);
// bringToFront is incredibly expensive. Delay by at least a frame.
requestAnimationFrame(() => {
setTimeout(() => {
rootBlock.bringToFront();
}, 0);
});
}
}

View File

@@ -66,8 +66,8 @@ function doRenders() {
}
/**
* Recursively renders all of the children of the given block, and then renders
* the block.
* Recursively renders all of the dirty children of the given block, and
* then renders the block.
*
* @param block The block to rerender.
*/

View File

@@ -187,27 +187,25 @@ export class RenderedConnection extends Connection {
* was updated.
*/
moveTo(x: number, y: number): boolean {
const dx = this.x - x;
const dy = this.y - y;
let moved = false;
const moved = this.x !== x || this.y !== y;
let updated = false;
if (this.trackedState_ === RenderedConnection.TrackedState.WILL_TRACK) {
this.db_.addConnection(this, y);
this.trackedState_ = RenderedConnection.TrackedState.TRACKED;
moved = true;
updated = true;
} else if (
this.trackedState_ === RenderedConnection.TrackedState.TRACKED &&
(dx !== 0 || dy !== 0)) {
moved) {
this.db_.removeConnection(this, this.y);
this.db_.addConnection(this, y);
moved = true;
updated = true;
}
this.x = x;
this.y = y;
return moved;
return updated;
}
/**