Don't create a move event or call recordNew() if events are disabled

This commit is contained in:
Rachel Fenichel 2016-04-26 12:49:25 -07:00
parent 69b28276e1
commit 8312553a1c

View file

@ -391,12 +391,17 @@ 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.Move(this);
var eventsEnabled = Blockly.Events.isEnabled();
if (eventsEnabled) {
var event = new Blockly.Events.Move(this);
}
var xy = this.getRelativeToSurfaceXY();
this.translate(xy.x + dx, xy.y + dy);
this.moveConnections_(dx, dy);
event.recordNew();
Blockly.Events.fire(event);
if (eventsEnabled) {
event.recordNew();
Blockly.Events.fire(event);
}
};
/**