Prevent uncessary add/remove class calls on cursor during drag (#4885)

This commit is contained in:
Monica Kozbial
2021-06-09 19:20:47 -07:00
committed by GitHub
parent 11390341b1
commit d2c61d5735
2 changed files with 13 additions and 10 deletions

View File

@@ -217,9 +217,12 @@ Blockly.BlockDragger.prototype.dragBlock = function(e, currentDragDeltaXY) {
}
this.draggedConnectionManager_.update(delta, this.dragTarget_);
this.wouldDeleteBlock_ = this.draggedConnectionManager_.wouldDeleteBlock();
this.updateCursorDuringBlockDrag_();
var wouldDeleteBlock = this.draggedConnectionManager_.wouldDeleteBlock();
if (wouldDeleteBlock != this.wouldDeleteBlock_) {
// Prevent unnecessary add/remove class calls.
this.updateCursorDuringBlockDrag_();
}
this.wouldDeleteBlock_ = wouldDeleteBlock;
};
/**

View File

@@ -140,9 +140,13 @@ Blockly.BubbleDragger.prototype.dragBubble = function(e, currentDragDeltaXY) {
oldDragTarget && oldDragTarget.onDragExit();
this.dragTarget_ && this.dragTarget_.onDragEnter();
}
this.wouldDeleteBubble_ = this.shouldDelete_(this.dragTarget_);
this.updateCursorDuringBubbleDrag_();
var wouldDeleteBubble = this.shouldDelete_(this.dragTarget_);
if (wouldDeleteBubble != this.wouldDeleteBubble_) {
// Prevent unnecessary add/remove class calls.
this.updateCursorDuringBubbleDrag_();
}
this.wouldDeleteBubble_ = wouldDeleteBubble;
};
/**
@@ -177,11 +181,7 @@ Blockly.BubbleDragger.prototype.shouldDelete_ = function(dragTarget) {
* @private
*/
Blockly.BubbleDragger.prototype.updateCursorDuringBubbleDrag_ = function() {
if (this.wouldDeleteBubble_) {
this.draggingBubble_.setDeleteStyle(true);
} else {
this.draggingBubble_.setDeleteStyle(false);
}
this.draggingBubble_.setDeleteStyle(this.wouldDeleteBubble_);
};
/**