Skip to content

Commit

Permalink
Don't fire events for ghost blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-fenichel committed Mar 15, 2016
1 parent 8fc4133 commit dd57be8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/block_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,11 @@ Blockly.BlockSvg.terminateDrag_ = function() {
// Terminate a drag operation.
if (selected) {
if (selected.ghostBlock_) {
Blockly.Events.disable();
selected.ghostBlock_.unplug(true /* healStack */);
selected.ghostBlock_.dispose();
selected.ghostBlock_ = null;
Blockly.Events.enable();
}
// Update the connection locations.
var xy = selected.getRelativeToSurfaceXY();
Expand Down Expand Up @@ -701,9 +703,12 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) {
if (Blockly.highlightedConnection_ &&
Blockly.highlightedConnection_ != closestConnection) {
if (this.ghostBlock_) {
// Don't fire events for ghost block creation or movement.
Blockly.Events.disable();
this.ghostBlock_.unplug(true /* healStack */);
this.ghostBlock_.dispose();
this.ghostBlock_ = null;
Blockly.Events.enable();
}
Blockly.highlightedConnection_.unhighlight();
Blockly.highlightedConnection_ = null;
Expand All @@ -715,6 +720,7 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) {
closestConnection.highlight();
Blockly.highlightedConnection_ = closestConnection;
Blockly.localConnection_ = localConnection;
Blockly.Events.disable();
if (!this.ghostBlock_){
this.ghostBlock_ = this.workspace.newBlock(this.type);
this.ghostBlock_.setGhost(true);
Expand All @@ -727,6 +733,7 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) {
this.ghostBlock_.previousConnection.connect(closestConnection);
}
this.ghostBlock_.render(true);
Blockly.Events.enable();
}
// Provide visual indication of whether the block will be deleted if
// dropped here.
Expand Down

0 comments on commit dd57be8

Please sign in to comment.