mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
chore: cleanup render management (#6883)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user