Update mutator workspace delete areas when bubble is moved. (#3355)

* Update mutator workspace delete areas when its moved
This commit is contained in:
Sam El-Husseini
2019-10-29 09:10:43 -07:00
committed by GitHub
parent e7752e6ea2
commit 6df85b9ff3
4 changed files with 55 additions and 8 deletions

View File

@@ -81,6 +81,20 @@ Blockly.Bubble = function(workspace, content, shape, anchorXY,
this.resizeGroup_, 'mousedown', this, this.resizeMouseDown_);
}
}
/**
* Method to call on resize of bubble.
* @type {?function()}
* @private
*/
this.resizeCallback_ = null;
/**
* Method to call on move of bubble.
* @type {?function()}
* @private
*/
this.moveCallback_ = null;
};
/**
@@ -123,13 +137,6 @@ Blockly.Bubble.onMouseUpWrapper_ = null;
*/
Blockly.Bubble.onMouseMoveWrapper_ = null;
/**
* Function to call on resize of bubble.
* @type {Function}
* @private
*/
Blockly.Bubble.prototype.resizeCallback_ = null;
/**
* Stop binding to the global mouseup and mousemove events.
* @private
@@ -371,6 +378,14 @@ Blockly.Bubble.prototype.registerResizeEvent = function(callback) {
this.resizeCallback_ = callback;
};
/**
* Register a function as a callback event for when the bubble is moved.
* @param {!Function} callback The function to call on move.
*/
Blockly.Bubble.prototype.registerMoveEvent = function(callback) {
this.moveCallback_ = callback;
};
/**
* Move this bubble to the top of the stack.
* @return {boolean} Whether or not the bubble has been moved.
@@ -620,6 +635,17 @@ Blockly.Bubble.prototype.moveTo = function(x, y) {
this.bubbleGroup_.setAttribute('transform', 'translate(' + x + ',' + y + ')');
};
/**
* Triggers a move callback if one exists at the end of a drag.
* @param {boolean} adding True if adding, false if removing.
* @package
*/
Blockly.Bubble.prototype.setDragging = function(adding) {
if (!adding && this.moveCallback_) {
this.moveCallback_();
}
};
/**
* Get the dimensions of this bubble.
* @return {!Blockly.utils.Size} The height and width of the bubble.