mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Add hook for clicking on trashcan.
This commit is contained in:
parent
b10ef6da48
commit
11ef9f2988
2 changed files with 25 additions and 0 deletions
|
@ -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}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue