Merge pull request #438 from rachel-fenichel/feature/cache_delete_areas

Cache delete areas
This commit is contained in:
rachel-fenichel
2016-06-17 14:56:10 -07:00
committed by GitHub
5 changed files with 15 additions and 1 deletions

View File

@@ -535,7 +535,6 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
Blockly.terminateDrag_();
this.select();
Blockly.hideChaff();
this.workspace.recordDeleteAreas();
if (Blockly.isRightButton(e)) {
// Right-click.
this.showContextMenu_(e);

View File

@@ -952,6 +952,10 @@ Blockly.Flyout.prototype.filterForCapacity_ = function() {
* @return {goog.math.Rect} Rectangle in which to delete.
*/
Blockly.Flyout.prototype.getClientRect = function() {
if (!this.svgGroup_) {
return null;
}
var flyoutRect = this.svgGroup_.getBoundingClientRect();
// BIG_NUM is offscreen padding so that blocks dragged beyond the shown flyout
// area are still deleted. Must be larger than the largest screen size,

View File

@@ -390,6 +390,10 @@ Blockly.Toolbox.prototype.clearSelection = function() {
* @return {goog.math.Rect} Rectangle in which to delete.
*/
Blockly.Toolbox.prototype.getClientRect = function() {
if (!this.HtmlDiv) {
return null;
}
// BIG_NUM is offscreen padding so that blocks dragged beyond the toolbox
// area are still deleted. Must be smaller than Infinity, but larger than
// the largest screen size.

View File

@@ -265,6 +265,10 @@ Blockly.Trashcan.prototype.position = function() {
* @return {goog.math.Rect} Rectangle in which to delete.
*/
Blockly.Trashcan.prototype.getClientRect = function() {
if (!this.svgGroup_) {
return null;
}
var trashRect = this.svgGroup_.getBoundingClientRect();
var left = trashRect.left + this.SPRITE_LEFT_ - this.MARGIN_HOTSPOT_;
var top = trashRect.top + this.SPRITE_TOP_ - this.MARGIN_HOTSPOT_;

View File

@@ -211,6 +211,7 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
this.addFlyout_();
}
this.updateGridPattern_();
this.recordDeleteAreas();
return this.svgGroup_;
};
@@ -355,6 +356,8 @@ Blockly.WorkspaceSvg.prototype.resize = function() {
if (this.scrollbar) {
this.scrollbar.resize();
}
this.recordDeleteAreas();
};
/**