From f0143b6d6c0124a43048b2f2ceada55f39ac253d Mon Sep 17 00:00:00 2001 From: Maribeth Bottorff Date: Thu, 10 Jun 2021 16:12:48 -0700 Subject: [PATCH 1/2] Add a clone method to Coordinate --- core/utils/coordinate.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/utils/coordinate.js b/core/utils/coordinate.js index da196acea..edf513b28 100644 --- a/core/utils/coordinate.js +++ b/core/utils/coordinate.js @@ -100,6 +100,14 @@ Blockly.utils.Coordinate.sum = function(a, b) { return new Blockly.utils.Coordinate(a.x + b.x, a.y + b.y); }; +/** + * Creates a new copy of this coordinate. + * @return {!Blockly.utils.Coordinate} A copy of this coordinate. + */ +Blockly.utils.Coordinate.prototype.clone = function() { + return new Blockly.utils.Coordinate(this.x, this.y); +}; + /** * Scales this coordinate by the given scale factor. * @param {number} s The scale factor to use for both x and y dimensions. From 777b3f46d63b4a873cba34b4b1c8547c1aa4b176 Mon Sep 17 00:00:00 2001 From: Maribeth Bottorff Date: Thu, 10 Jun 2021 16:17:12 -0700 Subject: [PATCH 2/2] use clone --- core/block_drag_surface.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/block_drag_surface.js b/core/block_drag_surface.js index e394ab7d5..5e2e121c7 100644 --- a/core/block_drag_surface.js +++ b/core/block_drag_surface.js @@ -232,8 +232,7 @@ Blockly.BlockDragSurfaceSvg.prototype.getCurrentBlock = function() { */ Blockly.BlockDragSurfaceSvg.prototype.getWsTranslation = function() { // Returning a copy so the coordinate can not be changed outside this class. - return new Blockly.utils.Coordinate( - this.childSurfaceXY_.x, this.childSurfaceXY_.y); + return this.childSurfaceXY_.clone(); }; /**