Commit 11ef9f29 authored by Neil Fraser's avatar Neil Fraser

Add hook for clicking on trashcan.

parent b10ef6da
...@@ -179,6 +179,7 @@ Blockly.Trashcan.prototype.createDom = function() { ...@@ -179,6 +179,7 @@ Blockly.Trashcan.prototype.createDom = function() {
this.svgLid_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', this.svgLid_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href',
this.workspace_.options.pathToMedia + Blockly.SPRITE.url); this.workspace_.options.pathToMedia + Blockly.SPRITE.url);
Blockly.bindEvent_(this.svgGroup_, 'mouseup', this, this.click);
this.animateLid_(); this.animateLid_();
return this.svgGroup_; return this.svgGroup_;
}; };
...@@ -282,3 +283,15 @@ Blockly.Trashcan.prototype.animateLid_ = function() { ...@@ -282,3 +283,15 @@ Blockly.Trashcan.prototype.animateLid_ = function() {
Blockly.Trashcan.prototype.close = function() { Blockly.Trashcan.prototype.close = function() {
this.setOpen_(false); 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.');
};
...@@ -99,6 +99,18 @@ Blockly.WorkspaceSvg.prototype.scrollX = 0; ...@@ -99,6 +99,18 @@ Blockly.WorkspaceSvg.prototype.scrollX = 0;
*/ */
Blockly.WorkspaceSvg.prototype.scrollY = 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. * Horizontal distance from mouse to object being dragged.
* @type {number} * @type {number}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment