Commit 4d2aac4f authored by Neil Fraser's avatar Neil Fraser

Bug-fixes to background grid.

parent 612b190e
This diff is collapsed.
...@@ -295,14 +295,15 @@ Blockly.Block.prototype.getConnections_ = function(all) { ...@@ -295,14 +295,15 @@ Blockly.Block.prototype.getConnections_ = function(all) {
* @private * @private
*/ */
Blockly.Block.prototype.bumpNeighbours_ = function() { Blockly.Block.prototype.bumpNeighbours_ = function() {
if (!this.workspace) {
return; // Deleted block.
}
if (Blockly.dragMode_ != 0) { if (Blockly.dragMode_ != 0) {
// Don't bump blocks during a drag. return; // Don't bump blocks during a drag.
return;
} }
var rootBlock = this.getRootBlock(); var rootBlock = this.getRootBlock();
if (rootBlock.isInFlyout) { if (rootBlock.isInFlyout) {
// Don't move blocks around in a flyout. return; // Don't move blocks around in a flyout.
return;
} }
// Loop though every connection on this block. // Loop though every connection on this block.
var myConnections = this.getConnections_(false); var myConnections = this.getConnections_(false);
......
...@@ -277,9 +277,18 @@ Blockly.BlockSvg.prototype.moveBy = function(dx, dy) { ...@@ -277,9 +277,18 @@ Blockly.BlockSvg.prototype.moveBy = function(dx, dy) {
* @private * @private
*/ */
Blockly.BlockSvg.prototype.snapToGrid_ = function() { Blockly.BlockSvg.prototype.snapToGrid_ = function() {
if (!this.workspace) {
return; // Deleted block.
}
if (Blockly.dragMode_ != 0) {
return; // Don't bump blocks during a drag.
}
if (this.getParent()) { if (this.getParent()) {
return; // Only snap top-level blocks. return; // Only snap top-level blocks.
} }
if (this.isInFlyout) {
return; // Don't move blocks around in a flyout.
}
var spacing = Blockly.gridOptions['spacing']; var spacing = Blockly.gridOptions['spacing'];
var half = spacing / 2; var half = spacing / 2;
var xy = this.getRelativeToSurfaceXY(); var xy = this.getRelativeToSurfaceXY();
......
...@@ -285,7 +285,7 @@ Blockly.onMouseDown_ = function(e) { ...@@ -285,7 +285,7 @@ Blockly.onMouseDown_ = function(e) {
Blockly.selected.unselect(); Blockly.selected.unselect();
} }
if ((e.target == Blockly.svg || if ((e.target == Blockly.svg ||
e.target == Blockly.mainWorkspace.svgGridRect_) && e.target == Blockly.mainWorkspace.svgBackground_) &&
Blockly.isRightButton(e)) { Blockly.isRightButton(e)) {
// Right-click on main workspace (not in a mutator). // Right-click on main workspace (not in a mutator).
Blockly.showContextMenu_(e); Blockly.showContextMenu_(e);
......
...@@ -146,7 +146,6 @@ Blockly.parseOptions_ = function(options) { ...@@ -146,7 +146,6 @@ Blockly.parseOptions_ = function(options) {
} else { } else {
grid['length'] = parseFloat(grid['length']); grid['length'] = parseFloat(grid['length']);
} }
grid['length'] = Math.min(grid['length'], grid['spacing']);
grid['snap'] = !!grid['snap']; grid['snap'] = !!grid['snap'];
var enableRealtime = !!options['realtime']; var enableRealtime = !!options['realtime'];
var realtimeOptions = enableRealtime ? options['realtimeOptions'] : undefined; var realtimeOptions = enableRealtime ? options['realtimeOptions'] : undefined;
......
...@@ -64,8 +64,8 @@ function start() { ...@@ -64,8 +64,8 @@ function start() {
collapse: true, collapse: true,
grid: grid:
{spacing: 25, {spacing: 25,
colour: '#ccc',
length: 3, length: 3,
colour: '#ccc',
snap: true}, snap: true},
realtime: false, realtime: false,
realtimeOptions: realtimeOptions:
......
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