mirror of
https://github.com/google/blockly.git
synced 2026-03-09 23:00:10 +01:00
Make updating the connection locations called the same way for both renderers
This commit is contained in:
@@ -333,7 +333,6 @@ Blockly.BlockSvg.prototype.renderInternal = function() {
|
||||
|
||||
var inputRows = this.renderCompute_(cursorX);
|
||||
this.renderDraw_(cursorX, inputRows);
|
||||
this.renderMoveConnections_();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -615,41 +614,6 @@ Blockly.BlockSvg.prototype.setPaths_ = function(pathObject) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Update all of the connections on this block with the new locations calculated
|
||||
* in renderCompute. Also move all of the connected blocks based on the new
|
||||
* connection locations.
|
||||
* @private
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.renderMoveConnections_ = function() {
|
||||
var blockTL = this.getRelativeToSurfaceXY();
|
||||
// Don't tighten previous or output connections because they are inferior
|
||||
// connections.
|
||||
if (this.previousConnection) {
|
||||
this.previousConnection.moveToOffset(blockTL);
|
||||
}
|
||||
if (this.outputConnection) {
|
||||
this.outputConnection.moveToOffset(blockTL);
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.inputList.length; i++) {
|
||||
var conn = this.inputList[i].connection;
|
||||
if (conn) {
|
||||
conn.moveToOffset(blockTL);
|
||||
if (conn.isConnected()) {
|
||||
conn.tighten_();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.nextConnection) {
|
||||
this.nextConnection.moveToOffset(blockTL);
|
||||
if (this.nextConnection.isConnected()) {
|
||||
this.nextConnection.tighten_();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Render the top edge of the block.
|
||||
* @param {!Blockly.BlockSvg.PathObject} pathObject The object containing
|
||||
|
||||
@@ -1547,6 +1547,8 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) {
|
||||
} else {
|
||||
this.renderInternal();
|
||||
}
|
||||
// No matter how we rendered, connections locations should now be correct.
|
||||
this.updateConnectionLocations_();
|
||||
if (opt_bubble !== false) {
|
||||
// Render all blocks above this one (propagate a reflow).
|
||||
var parentBlock = this.getParent();
|
||||
@@ -1559,3 +1561,38 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) {
|
||||
}
|
||||
Blockly.Field.stopCache();
|
||||
};
|
||||
|
||||
/**
|
||||
* Update all of the connections on this block with the new locations calculated
|
||||
* during rendering. Also move all of the connected blocks based on the new
|
||||
* connection locations.
|
||||
* @private
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.updateConnectionLocations_ = function() {
|
||||
var blockTL = this.getRelativeToSurfaceXY();
|
||||
// Don't tighten previous or output connections because they are inferior
|
||||
// connections.
|
||||
if (this.previousConnection) {
|
||||
this.previousConnection.moveToOffset(blockTL);
|
||||
}
|
||||
if (this.outputConnection) {
|
||||
this.outputConnection.moveToOffset(blockTL);
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.inputList.length; i++) {
|
||||
var conn = this.inputList[i].connection;
|
||||
if (conn) {
|
||||
conn.moveToOffset(blockTL);
|
||||
if (conn.isConnected()) {
|
||||
conn.tighten_();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.nextConnection) {
|
||||
this.nextConnection.moveToOffset(blockTL);
|
||||
if (this.nextConnection.isConnected()) {
|
||||
this.nextConnection.tighten_();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -47,7 +47,4 @@ Blockly.blockRendering.render = function(block) {
|
||||
}
|
||||
var info = new Blockly.blockRendering.RenderInfo(block);
|
||||
new Blockly.blockRendering.Drawer(block, info).draw_();
|
||||
|
||||
// TODO: Fix moving connections in the new rendering code.
|
||||
block.renderMoveConnections_();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user