From b0cd8032119c817f955d56e7c415fb9000436751 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 31 Jan 2020 13:15:03 -0800 Subject: [PATCH] Added empty trashcan function. --- core/trashcan.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/trashcan.js b/core/trashcan.js index f2ee3bf41..1534b92e7 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -347,6 +347,29 @@ Blockly.Trashcan.prototype.dispose = function() { clearTimeout(this.lidTask_); }; +/** + * Returns true if the trashcan contents-flyout is currently open. + * @return {boolean} True if the trashcan contents-flyout is currently open. + */ +Blockly.Trashcan.prototype.contentsIsOpen = function() { + return this.flyout.isVisible(); +}; + +/** + * Empties the trashcan's contents. If the contents-flyout is currently open + * it will be closed. + */ +Blockly.Trashcan.prototype.emptyContents = function() { + if (!this.contents_.length) { + return; + } + this.contents_.length = 0; + this.setMinOpenness_(0); + if (this.contentsIsOpen()) { + this.flyout.hide(); + } +}; + /** * Position the trashcan. * It is positioned in the opposite corner to the corner the