From 54036a2b4d0ea44ffc44e5f54e3e85c446f82de3 Mon Sep 17 00:00:00 2001 From: TJKoury Date: Sun, 2 Oct 2016 17:45:49 -0400 Subject: [PATCH] Added parent containment option for draggable. (#1006) * added parent containment option for draggable * taking Nick's suggestion, #main-container it is --- editor/js/ui/palette.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/editor/js/ui/palette.js b/editor/js/ui/palette.js index 5ddba95b7..66872ded4 100644 --- a/editor/js/ui/palette.js +++ b/editor/js/ui/palette.js @@ -227,18 +227,20 @@ RED.palette = (function() { appendTo: 'body', revert: true, revertDuration: 50, + containment:'#main-container', start: function() {RED.view.focus();}, stop: function() { d3.select('.link_splice').classed('link_splice',false); if (spliceTimer) { clearTimeout(spliceTimer); spliceTimer = null;}}, 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 = 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() { var nodes = [];