Skip to content

Commit

Permalink
fix: make insertion markers use new render management system
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Jul 19, 2023
1 parent aedf2b9 commit f0d230c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
22 changes: 11 additions & 11 deletions core/insertion_marker_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions core/workspace_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}

/**
Expand Down

0 comments on commit f0d230c

Please sign in to comment.