Small changes

This commit is contained in:
Rachel Fenichel
2018-05-16 12:52:12 -07:00
parent 9ab746e143
commit f623004b3a
3 changed files with 16 additions and 7 deletions

View File

@@ -259,6 +259,10 @@ Blockly.Block.prototype.dispose = function(healStack) {
// well as corruption of the connection database. Therefore we must
// methodically step through the blocks and carefully disassemble them.
if (Blockly.selected == this) {
Blockly.selected = null;
}
// First, dispose of all my children.
for (var i = this.childBlocks_.length - 1; i >= 0; i--) {
this.childBlocks_[i].dispose(false);
@@ -365,7 +369,7 @@ Blockly.Block.prototype.getConnections_ = function(_all) {
* @return {Blockly.Connection} The last next connection on the stack, or null.
* @package
*/
Blockly.Block.prototype.lastConnectionInStack_ = function() {
Blockly.Block.prototype.lastConnectionInStack = function() {
var nextConnection = this.nextConnection;
while (nextConnection) {
var nextBlock = nextConnection.targetBlock();
@@ -1282,7 +1286,6 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
case 'input_dummy':
input = this.appendDummyInput(element['name']);
break;
default:
field = Blockly.Field.fromJson(element);

View File

@@ -36,6 +36,7 @@ goog.require('Blockly.RenderedConnection');
goog.require('Blockly.Tooltip');
goog.require('Blockly.Touch');
goog.require('Blockly.utils');
goog.require('goog.Timer');
goog.require('goog.asserts');
goog.require('goog.dom');
@@ -320,13 +321,18 @@ Blockly.BlockSvg.prototype.getRelativeToSurfaceXY = function() {
*/
Blockly.BlockSvg.prototype.moveBy = function(dx, dy) {
goog.asserts.assert(!this.parentBlock_, 'Block has parent.');
var event = new Blockly.Events.BlockMove(this);
var eventsEnabled = Blockly.Events.isEnabled();
if (eventsEnabled) {
var event = new Blockly.Events.BlockMove(this);
}
var xy = this.getRelativeToSurfaceXY();
this.translate(xy.x + dx, xy.y + dy);
this.moveConnections_(dx, dy);
event.recordNew();
if (eventsEnabled) {
event.recordNew();
Blockly.Events.fire(event);
}
this.workspace.resizeContents();
Blockly.Events.fire(event);
};
/**
@@ -570,7 +576,7 @@ Blockly.BlockSvg.prototype.createTabList_ = function() {
* @private
*/
Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
var gesture = this.workspace.getGesture(e);
var gesture = this.workspace && this.workspace.getGesture(e);
if (gesture) {
gesture.handleBlockStart(e, this);
}

View File

@@ -215,7 +215,7 @@ Blockly.DraggedConnectionManager.prototype.addHighlighting_ = function() {
Blockly.DraggedConnectionManager.prototype.initAvailableConnections_ = function() {
var available = this.topBlock_.getConnections_(false);
// Also check the last connection on this stack
var lastOnStack = this.topBlock_.lastConnectionInStack_();
var lastOnStack = this.topBlock_.lastConnectionInStack();
if (lastOnStack && lastOnStack != this.topBlock_.nextConnection) {
available.push(lastOnStack);
}