From 321f5e615bf9e70ca2910718beb4feabdee98352 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sun, 17 Apr 2016 21:28:56 +0100 Subject: [PATCH] Activate link splice on node centre not mouse position --- editor/js/ui/palette.js | 6 ++++-- editor/js/ui/view.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/editor/js/ui/palette.js b/editor/js/ui/palette.js index 789502de8..a7bd2ee6d 100644 --- a/editor/js/ui/palette.js +++ b/editor/js/ui/palette.js @@ -232,10 +232,12 @@ RED.palette = (function() { drag: function(e,ui) { // TODO: this is the margin-left of palette node. Hard coding // it here makes me sad + //console.log(ui.helper.position()); ui.position.left += 17.5; if (def.inputs > 0 && def.outputs > 0) { - mouseX = e.clientX - chartOffset.left+chart.scrollLeft(); - mouseY = e.clientY-chartOffset.top +chart.scrollTop(); + mouseX = ui.position.left+(ui.helper.width()/2) - chartOffset.left + chart.scrollLeft(); + mouseY = ui.position.top+(ui.helper.height()/2) - chartOffset.top + chart.scrollTop(); + if (!spliceTimer) { spliceTimer = setTimeout(function() { diff --git a/editor/js/ui/view.js b/editor/js/ui/view.js index b96b25890..7296d3849 100644 --- a/editor/js/ui/view.js +++ b/editor/js/ui/view.js @@ -655,8 +655,8 @@ RED.view = (function() { var nodes = []; var bestDistance = Infinity; var bestLink = null; - var mouseX = mousePos[0]; - var mouseY = mousePos[1]; + var mouseX = node.n.x; + var mouseY = node.n.y; if (outer[0][0].getIntersectionList) { var svgRect = outer[0][0].createSVGRect(); svgRect.x = mouseX;