mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
Add onDragOver and wouldDelete_ to DeleteArea (#4888)
* keep track of state for whether the block or bubble would be deleted for use with drag enter exit * Check if block and bubble is deletable in IDeleteArea * Add to jsdoc of IDeleteArea
This commit is contained in:
@@ -132,15 +132,10 @@ Blockly.BubbleDragger.prototype.startBubbleDrag = function() {
|
||||
Blockly.BubbleDragger.prototype.dragBubble = function(e, currentDragDeltaXY) {
|
||||
var delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY);
|
||||
var newLoc = Blockly.utils.Coordinate.sum(this.startXY_, delta);
|
||||
|
||||
this.draggingBubble_.moveDuringDrag(this.dragSurface_, newLoc);
|
||||
|
||||
var oldDragTarget = this.dragTarget_;
|
||||
this.dragTarget_ = this.workspace_.getDragTarget(e);
|
||||
if (this.dragTarget_ !== oldDragTarget) {
|
||||
oldDragTarget && oldDragTarget.onDragExit();
|
||||
this.dragTarget_ && this.dragTarget_.onDragEnter();
|
||||
}
|
||||
|
||||
var oldWouldDeleteBubble = this.wouldDeleteBubble_;
|
||||
this.wouldDeleteBubble_ = this.shouldDelete_(this.dragTarget_);
|
||||
@@ -148,6 +143,12 @@ Blockly.BubbleDragger.prototype.dragBubble = function(e, currentDragDeltaXY) {
|
||||
// Prevent unnecessary add/remove class calls.
|
||||
this.updateCursorDuringBubbleDrag_();
|
||||
}
|
||||
|
||||
if (this.dragTarget_ !== oldDragTarget) {
|
||||
oldDragTarget && oldDragTarget.onDragExit();
|
||||
this.dragTarget_ && this.dragTarget_.onDragEnter();
|
||||
}
|
||||
this.dragTarget_ && this.dragTarget_.onDragOver();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -159,9 +160,7 @@ Blockly.BubbleDragger.prototype.dragBubble = function(e, currentDragDeltaXY) {
|
||||
* @private
|
||||
*/
|
||||
Blockly.BubbleDragger.prototype.shouldDelete_ = function(dragTarget) {
|
||||
var couldDeleteBubble = this.draggingBubble_.isDeletable();
|
||||
|
||||
if (couldDeleteBubble && dragTarget) {
|
||||
if (dragTarget) {
|
||||
var componentManager = this.workspace_.getComponentManager();
|
||||
var isDeleteArea = componentManager.hasCapability(dragTarget.id,
|
||||
Blockly.ComponentManager.Capability.DELETE_AREA);
|
||||
|
||||
Reference in New Issue
Block a user