align to grid in canvas

This commit is contained in:
tamat
2021-03-12 16:27:55 +01:00
parent e6147b7217
commit 41f779c3f8
3 changed files with 663 additions and 645 deletions

View File

@@ -4683,6 +4683,7 @@ LGraphNode.prototype.executeAction = function(action)
this.allow_interaction = true; //allow to control widgets, buttons, collapse, etc
this.allow_searchbox = true;
this.allow_reconnect_links = false; //allows to change a connection with having to redo it again
this.align_to_grid = false; //snap to grid
this.drag_mode = false;
this.dragging_rectangle = null;
@@ -5973,7 +5974,7 @@ LGraphNode.prototype.executeAction = function(action)
this.dirty_bgcanvas = true;
this.node_dragged.pos[0] = Math.round(this.node_dragged.pos[0]);
this.node_dragged.pos[1] = Math.round(this.node_dragged.pos[1]);
if (this.graph.config.align_to_grid) {
if (this.graph.config.align_to_grid || this.align_to_grid ) {
this.node_dragged.alignToGrid();
}
if( this.onNodeMoved )