Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/pants migration #160

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion core/block_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,16 @@ Blockly.BlockSvg.prototype.onMouseUp_ = function(e) {
Blockly.selected.moveBy(
Blockly.highlightedConnection_.x_ - Blockly.localConnection_.x_,
Blockly.highlightedConnection_.y_ - Blockly.localConnection_.y_);
} else if (Blockly.localConnection_ ==
Blockly.selected.getFirstStatementConnection()) {
// Snap to match the position of the pre-existing stack. Since this is a
// C-block, shift to take into account how the block will stretch as it
// surrounds the internal blocks.
Blockly.selected.moveBy(
Blockly.highlightedConnection_.x_ - Blockly.localConnection_.x_,
Blockly.highlightedConnection_.y_ - Blockly.localConnection_.y_ -
(Blockly.highlightedConnection_.sourceBlock_.getHeightWidth().height -
Blockly.BlockSvg.MIN_BLOCK_Y));
}
// Connect two blocks together.
Blockly.localConnection_.connect(Blockly.highlightedConnection_);
Expand Down Expand Up @@ -878,7 +888,15 @@ Blockly.BlockSvg.prototype.updatePreviews = function(closestConnection,
var newX = closestConnection.x_ - connectionOffsetX;
var newY = closestConnection.y_ - connectionOffsetY;
var ghostPosition = ghostBlock.getRelativeToSurfaceXY();
ghostBlock.moveBy(newX - ghostPosition.x, newY - ghostPosition.y, true);

// If it's the first statement connection of a c-block, this block is
// going to get taller as soon as render() is called below.
if (localGhostConnection != ghostBlock.nextConnection) {
newY -= closestConnection.sourceBlock_.getHeightWidth().height -
Blockly.BlockSvg.MIN_BLOCK_Y;
}

ghostBlock.moveBy(newX - ghostPosition.x, newY - ghostPosition.y);

}
if (localGhostConnection.type == Blockly.PREVIOUS_STATEMENT &&
Expand Down
2 changes: 1 addition & 1 deletion core/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate,
// If this is a c-shaped block, statement blocks cannot be connected
// anywhere other than inside the first statement input.
if (firstStatementConnection) {
// Can't connect if there is alread a block inside the first statement
// Can't connect if there is already a block inside the first statement
// input.
if (this == firstStatementConnection) {
if (this.targetConnection) {
Expand Down