diff --git a/core/trashcan.js b/core/trashcan.js index ef491a016..b7a0781d8 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -179,6 +179,7 @@ Blockly.Trashcan.prototype.createDom = function() { this.svgLid_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); + Blockly.bindEvent_(this.svgGroup_, 'mouseup', this, this.click); this.animateLid_(); return this.svgGroup_; }; @@ -282,3 +283,15 @@ Blockly.Trashcan.prototype.animateLid_ = function() { Blockly.Trashcan.prototype.close = function() { this.setOpen_(false); }; + +/** + * Inspect the contents of the trash. + */ +Blockly.Trashcan.prototype.click = function() { + var dx = this.workspace_.startScrollX - this.workspace_.scrollX; + var dy = this.workspace_.startScrollY - this.workspace_.scrollY; + if (Math.sqrt(dx * dx + dy * dy) > Blockly.DRAG_RADIUS) { + return; + } + console.log('TODO: Inspect trash.'); +}; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 34157ce15..d9493a2b5 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -99,6 +99,18 @@ Blockly.WorkspaceSvg.prototype.scrollX = 0; */ Blockly.WorkspaceSvg.prototype.scrollY = 0; +/** + * Horizontal scroll value when scrolling started. + * @type {number} + */ +Blockly.WorkspaceSvg.prototype.startScrollX = 0; + +/** + * Vertical scroll value when scrolling started. + * @type {number} + */ +Blockly.WorkspaceSvg.prototype.startScrollY = 0; + /** * Horizontal distance from mouse to object being dragged. * @type {number}