mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
Added randomness to bumping per Issue #2011
This commit is contained in:
@@ -68,6 +68,11 @@ Blockly.INSERTION_MARKER_COLOUR = '#000000';
|
||||
*/
|
||||
Blockly.BUMP_DELAY = 250;
|
||||
|
||||
/**
|
||||
* Maximum randomness in workspace units for bumping a block.
|
||||
*/
|
||||
Blockly.BUMP_RANDOMNESS = 10;
|
||||
|
||||
/**
|
||||
* Number of characters to truncate a collapsed block to.
|
||||
*/
|
||||
|
||||
@@ -97,8 +97,10 @@ Blockly.RenderedConnection.prototype.bumpAwayFrom_ = function(staticConnection)
|
||||
// Raise it to the top for extra visibility.
|
||||
var selected = Blockly.selected == rootBlock;
|
||||
selected || rootBlock.addSelect();
|
||||
var dx = (staticConnection.x_ + Blockly.SNAP_RADIUS) - this.x_;
|
||||
var dy = (staticConnection.y_ + Blockly.SNAP_RADIUS) - this.y_;
|
||||
var dx = (staticConnection.x_ + Blockly.SNAP_RADIUS +
|
||||
Math.floor(Math.random() * Blockly.BUMP_RANDOMNESS)) - this.x_;
|
||||
var dy = (staticConnection.y_ + Blockly.SNAP_RADIUS +
|
||||
Math.floor(Math.random() * Blockly.BUMP_RANDOMNESS)) - this.y_;
|
||||
if (reverse) {
|
||||
// When reversing a bump due to an uneditable block, bump up.
|
||||
dy = -dy;
|
||||
|
||||
Reference in New Issue
Block a user