mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Add hook for clicking on trashcan.
This commit is contained in:
@@ -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.');
|
||||
};
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user