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