From 1b2ec7230c482cc3d553316967ba6f1d0dd260cd Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Sun, 2 Dec 2018 12:34:34 -0800 Subject: [PATCH] Added randomness to bumping per Issue #2011 --- core/constants.js | 5 +++++ core/rendered_connection.js | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/constants.js b/core/constants.js index 7668989f7..622d3a473 100644 --- a/core/constants.js +++ b/core/constants.js @@ -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. */ diff --git a/core/rendered_connection.js b/core/rendered_connection.js index 8b786b26d..d972c60c2 100644 --- a/core/rendered_connection.js +++ b/core/rendered_connection.js @@ -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;