From 12b5658109c9534ed89e7d5b35e634cbbaf8de64 Mon Sep 17 00:00:00 2001 From: Monica Kozbial Date: Wed, 5 Aug 2020 12:25:35 -0700 Subject: [PATCH] Rename trashcan api calls for open/close lid. (#4110) * Rename trashcan api calls for open/close lid. * Update comments. --- core/block_dragger.js | 10 +++++----- core/bubble_dragger.js | 10 +++++----- core/trashcan.js | 24 ++++++++++++------------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/core/block_dragger.js b/core/block_dragger.js index c38f4425b..45d76ac87 100644 --- a/core/block_dragger.js +++ b/core/block_dragger.js @@ -287,15 +287,15 @@ Blockly.BlockDragger.prototype.maybeDeleteBlock_ = function() { if (this.wouldDeleteBlock_) { if (trashcan) { - setTimeout(trashcan.close.bind(trashcan), 100); + setTimeout(trashcan.closeLid.bind(trashcan), 100); } // Fire a move event, so we know where to go back to for an undo. this.fireMoveEvent_(); this.draggingBlock_.dispose(false, true); Blockly.draggingConnections = []; } else if (trashcan) { - // Make sure the trash can is closed. - trashcan.close(); + // Make sure the trash can lid is closed. + trashcan.closeLid(); } return this.wouldDeleteBlock_; }; @@ -311,12 +311,12 @@ Blockly.BlockDragger.prototype.updateCursorDuringBlockDrag_ = function() { if (this.wouldDeleteBlock_) { this.draggingBlock_.setDeleteStyle(true); if (this.deleteArea_ == Blockly.DELETE_AREA_TRASH && trashcan) { - trashcan.setOpen(true); + trashcan.setLidOpen(true); } } else { this.draggingBlock_.setDeleteStyle(false); if (trashcan) { - trashcan.setOpen(false); + trashcan.setLidOpen(false); } } }; diff --git a/core/bubble_dragger.js b/core/bubble_dragger.js index 11cbda32f..ee4bd9942 100644 --- a/core/bubble_dragger.js +++ b/core/bubble_dragger.js @@ -147,14 +147,14 @@ Blockly.BubbleDragger.prototype.maybeDeleteBubble_ = function() { if (this.wouldDeleteBubble_) { if (trashcan) { - setTimeout(trashcan.close.bind(trashcan), 100); + setTimeout(trashcan.closeLid.bind(trashcan), 100); } // Fire a move event, so we know where to go back to for an undo. this.fireMoveEvent_(); this.draggingBubble_.dispose(false, true); } else if (trashcan) { - // Make sure the trash can is closed. - trashcan.close(); + // Make sure the trash can lid is closed. + trashcan.closeLid(); } return this.wouldDeleteBubble_; }; @@ -170,12 +170,12 @@ Blockly.BubbleDragger.prototype.updateCursorDuringBubbleDrag_ = function() { if (this.wouldDeleteBubble_) { this.draggingBubble_.setDeleteStyle(true); if (this.deleteArea_ == Blockly.DELETE_AREA_TRASH && trashcan) { - trashcan.setOpen(true); + trashcan.setLidOpen(true); } } else { this.draggingBubble_.setDeleteStyle(false); if (trashcan) { - trashcan.setOpen(false); + trashcan.setLidOpen(false); } } }; diff --git a/core/trashcan.js b/core/trashcan.js index 9c0168eae..9502a1445 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -149,7 +149,7 @@ Blockly.Trashcan.prototype.SPRITE_TOP_ = 32; Blockly.Trashcan.prototype.HAS_BLOCKS_LID_ANGLE_ = 0.1; /** - * The length of the open/close animation in milliseconds. + * The length of the lid open/close animation in milliseconds. * @const {number} * @private */ @@ -188,7 +188,7 @@ Blockly.Trashcan.MAX_LID_ANGLE_ = 45; * Current open/close state of the lid. * @type {boolean} */ -Blockly.Trashcan.prototype.isOpen = false; +Blockly.Trashcan.prototype.isLidOpen = false; /** * The minimum openness of the lid. Used to indicate if the trashcan contains @@ -337,7 +337,7 @@ Blockly.Trashcan.prototype.init = function(verticalSpacing) { } this.verticalSpacing_ = this.MARGIN_BOTTOM_ + verticalSpacing; - this.setOpen(false); + this.setLidOpen(false); return this.verticalSpacing_ + this.BODY_HEIGHT_ + this.LID_HEIGHT_; }; @@ -473,12 +473,12 @@ Blockly.Trashcan.prototype.getClientRect = function() { * @param {boolean} state True if open. * @package */ -Blockly.Trashcan.prototype.setOpen = function(state) { - if (this.isOpen == state) { +Blockly.Trashcan.prototype.setLidOpen = function(state) { + if (this.isLidOpen == state) { return; } clearTimeout(this.lidTask_); - this.isOpen = state; + this.isLidOpen = state; this.animateLid_(); }; @@ -490,7 +490,7 @@ Blockly.Trashcan.prototype.animateLid_ = function() { var frames = Blockly.Trashcan.ANIMATION_FRAMES_; var delta = 1 / (frames + 1); - this.lidOpen_ += this.isOpen ? delta : -delta; + this.lidOpen_ += this.isLidOpen ? delta : -delta; this.lidOpen_ = Math.min(Math.max(this.lidOpen_, this.minOpenness_), 1); this.setLidAngle_(this.lidOpen_ * Blockly.Trashcan.MAX_LID_ANGLE_); @@ -530,7 +530,7 @@ Blockly.Trashcan.prototype.setLidAngle_ = function(lidAngle) { */ Blockly.Trashcan.prototype.setMinOpenness_ = function(newMin) { this.minOpenness_ = newMin; - if (!this.isOpen) { + if (!this.isLidOpen) { this.setLidAngle_(newMin * Blockly.Trashcan.MAX_LID_ANGLE_); } }; @@ -539,8 +539,8 @@ Blockly.Trashcan.prototype.setMinOpenness_ = function(newMin) { * Flip the lid shut. * Called externally after a drag. */ -Blockly.Trashcan.prototype.close = function() { - this.setOpen(false); +Blockly.Trashcan.prototype.closeLid = function() { + this.setLidOpen(false); }; /** @@ -582,7 +582,7 @@ Blockly.Trashcan.prototype.blockMouseDownWhenFull_ = function(e) { */ Blockly.Trashcan.prototype.mouseOver_ = function() { if (this.hasContents_()) { - this.setOpen(true); + this.setLidOpen(true); } }; @@ -594,7 +594,7 @@ Blockly.Trashcan.prototype.mouseOver_ = function() { Blockly.Trashcan.prototype.mouseOut_ = function() { // No need to do a .hasBlocks check here because if it doesn't the trashcan // won't be open in the first place, and setOpen won't run. - this.setOpen(false); + this.setLidOpen(false); }; /**