Adding parameter to dragEnter and dragExit (#4890)

* introduce IDraggable interface
* Add parameter to drag methods in IDragTarget
* combines bubble/drag methods on IDragTarget and IDeleteArea to take an IDraggable element
This commit is contained in:
Monica Kozbial
2021-06-11 12:58:26 -07:00
committed by GitHub
parent fb170b9052
commit a17cb7f12e
14 changed files with 321 additions and 335 deletions

View File

@@ -144,11 +144,12 @@ Blockly.BubbleDragger.prototype.dragBubble = function(e, currentDragDeltaXY) {
this.updateCursorDuringBubbleDrag_();
}
// Call drag enter/exit/over after wouldDeleteBlock is called in shouldDelete_
if (this.dragTarget_ !== oldDragTarget) {
oldDragTarget && oldDragTarget.onDragExit();
this.dragTarget_ && this.dragTarget_.onDragEnter();
oldDragTarget && oldDragTarget.onDragExit(this.draggingBubble_);
this.dragTarget_ && this.dragTarget_.onDragEnter(this.draggingBubble_);
}
this.dragTarget_ && this.dragTarget_.onDragOver();
this.dragTarget_ && this.dragTarget_.onDragOver(this.draggingBubble_);
};
/**
@@ -166,7 +167,7 @@ Blockly.BubbleDragger.prototype.shouldDelete_ = function(dragTarget) {
Blockly.ComponentManager.Capability.DELETE_AREA);
if (isDeleteArea) {
return (/** @type {!Blockly.IDeleteArea} */ (dragTarget))
.wouldDeleteBubble(this.draggingBubble_);
.wouldDelete(this.draggingBubble_, false);
}
}
return false;
@@ -194,7 +195,7 @@ Blockly.BubbleDragger.prototype.endBubbleDrag = function(
this.dragBubble(e, currentDragDeltaXY);
var preventMove = this.dragTarget_ &&
this.dragTarget_.shouldPreventBubbleMove(this.draggingBubble_);
this.dragTarget_.shouldPreventMove(this.draggingBubble_);
if (preventMove) {
var newLoc = this.startXY_;
} else {
@@ -205,7 +206,7 @@ Blockly.BubbleDragger.prototype.endBubbleDrag = function(
this.draggingBubble_.moveTo(newLoc.x, newLoc.y);
if (this.dragTarget_) {
this.dragTarget_.onBubbleDrop(this.draggingBubble_);
this.dragTarget_.onDrop(this.draggingBubble_);
}
if (this.wouldDeleteBubble_) {