mirror of
https://github.com/google/blockly.git
synced 2026-01-27 10:40:09 +01:00
Fix trashcan hotspot in RTL.
This commit is contained in:
@@ -83,6 +83,20 @@ Blockly.Trashcan.prototype.MARGIN_SIDE_ = 20;
|
||||
*/
|
||||
Blockly.Trashcan.prototype.MARGIN_HOTSPOT_ = 10;
|
||||
|
||||
/**
|
||||
* Location of trashcan in sprite image.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Trashcan.prototype.SPRITE_LEFT_ = 0;
|
||||
|
||||
/**
|
||||
* Location of trashcan in sprite image.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Trashcan.prototype.SPRITE_TOP_ = 32;
|
||||
|
||||
/**
|
||||
* Current open/close state of the lid.
|
||||
* @type {boolean}
|
||||
@@ -161,7 +175,8 @@ Blockly.Trashcan.prototype.createDom = function() {
|
||||
'y': this.LID_HEIGHT_},
|
||||
clip);
|
||||
var body = Blockly.createSvgElement('image',
|
||||
{'width': Blockly.SPRITE.width, 'height': Blockly.SPRITE.height, 'y': -32,
|
||||
{'width': Blockly.SPRITE.width, 'x': -this.SPRITE_LEFT_,
|
||||
'height': Blockly.SPRITE.height, 'y': -this.SPRITE_TOP_,
|
||||
'clip-path': 'url(#blocklyTrashBodyClipPath' + rnd + ')'},
|
||||
this.svgGroup_);
|
||||
body.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href',
|
||||
@@ -173,7 +188,8 @@ Blockly.Trashcan.prototype.createDom = function() {
|
||||
Blockly.createSvgElement('rect',
|
||||
{'width': this.WIDTH_, 'height': this.LID_HEIGHT_}, clip);
|
||||
this.svgLid_ = Blockly.createSvgElement('image',
|
||||
{'width': Blockly.SPRITE.width, 'height': Blockly.SPRITE.height, 'y': -32,
|
||||
{'width': Blockly.SPRITE.width, 'x': -this.SPRITE_LEFT_,
|
||||
'height': Blockly.SPRITE.height, 'y': -this.SPRITE_TOP_,
|
||||
'clip-path': 'url(#blocklyTrashLidClipPath' + rnd + ')'},
|
||||
this.svgGroup_);
|
||||
this.svgLid_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href',
|
||||
@@ -250,10 +266,11 @@ Blockly.Trashcan.prototype.position = function() {
|
||||
*/
|
||||
Blockly.Trashcan.prototype.getClientRect = function() {
|
||||
var trashRect = this.svgGroup_.getBoundingClientRect();
|
||||
return new goog.math.Rect(trashRect.left - this.MARGIN_HOTSPOT_,
|
||||
trashRect.top - this.MARGIN_HOTSPOT_,
|
||||
trashRect.width + 2 * this.MARGIN_HOTSPOT_,
|
||||
trashRect.height + 2 * this.MARGIN_HOTSPOT_);
|
||||
var left = trashRect.left + this.SPRITE_LEFT_ - this.MARGIN_HOTSPOT_;
|
||||
var top = trashRect.top + this.SPRITE_TOP_ - this.MARGIN_HOTSPOT_;
|
||||
var width = this.WIDTH_ + 2 * this.MARGIN_HOTSPOT_;
|
||||
var height = this.LID_HEIGHT_ + this.BODY_HEIGHT_ + 2 * this.MARGIN_HOTSPOT_;
|
||||
return new goog.math.Rect(left, top, width, height);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user