fix: make insertion markers use new render management system (#7307)

This commit is contained in:
Beka Westberg
2023-07-26 14:52:10 -07:00
committed by GitHub
parent 435e854b8e
commit c8be2f2538
2 changed files with 16 additions and 13 deletions

View File

@@ -25,6 +25,7 @@ import type {IDragTarget} from './interfaces/i_drag_target.js';
import type {RenderedConnection} from './rendered_connection.js';
import type {Coordinate} from './utils/coordinate.js';
import type {WorkspaceSvg} from './workspace_svg.js';
import * as renderManagement from './render_management.js';
/** Represents a nearby valid connection. */
interface CandidateConnection {
@@ -608,18 +609,17 @@ export class InsertionMarkerManager {
// Render disconnected from everything else so that we have a valid
// connection location.
insertionMarker.render();
insertionMarker.rendered = true;
insertionMarker.getSvgRoot().setAttribute('visibility', 'visible');
insertionMarker.queueRender();
renderManagement.triggerQueuedRenders();
if (imConn && closest) {
// Position so that the existing block doesn't move.
insertionMarker.positionNearConnection(imConn, closest);
}
if (closest) {
// Connect() also renders the insertion marker.
imConn.connect(closest);
}
// Position so that the existing block doesn't move.
insertionMarker.positionNearConnection(imConn, closest);
// Connect() also renders the insertion marker.
imConn.connect(closest);
renderManagement.finishQueuedRenders().then(() => {
insertionMarker?.getSvgRoot().setAttribute('visibility', 'visible');
});
this.markerConnection = imConn;
}

View File

@@ -77,6 +77,7 @@ import {WorkspaceCommentSvg} from './workspace_comment_svg.js';
import * as Xml from './xml.js';
import {ZoomControls} from './zoom_controls.js';
import {ContextMenuOption} from './contextmenu_registry.js';
import * as renderManagement from './render_management.js';
/** Margin around the top/bottom/left/right after a zoomToFit call. */
const ZOOM_TO_FIT_MARGIN = 20;
@@ -1251,11 +1252,13 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
if (this.currentGesture_) {
const imList = this.currentGesture_.getInsertionMarkers();
for (let i = 0; i < imList.length; i++) {
imList[i].render(false);
imList[i].queueRender();
}
}
this.markerManager.updateMarkers();
renderManagement
.finishQueuedRenders()
.then(() => void this.markerManager.updateMarkers());
}
/**