1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Added parent containment option for draggable. (#1006)

* added parent containment option for draggable

* taking Nick's suggestion, #main-container it is
This commit is contained in:
TJKoury 2016-10-02 17:45:49 -04:00 committed by Nick O'Leary
parent 15f1e2c85c
commit 54036a2b4d

View File

@ -227,18 +227,20 @@ RED.palette = (function() {
appendTo: 'body', appendTo: 'body',
revert: true, revert: true,
revertDuration: 50, revertDuration: 50,
containment:'#main-container',
start: function() {RED.view.focus();}, start: function() {RED.view.focus();},
stop: function() { d3.select('.link_splice').classed('link_splice',false); if (spliceTimer) { clearTimeout(spliceTimer); spliceTimer = null;}}, stop: function() { d3.select('.link_splice').classed('link_splice',false); if (spliceTimer) { clearTimeout(spliceTimer); spliceTimer = null;}},
drag: function(e,ui) { drag: function(e,ui) {
// TODO: this is the margin-left of palette node. Hard coding // TODO: this is the margin-left of palette node. Hard coding
// it here makes me sad // it here makes me sad
//console.log(ui.helper.position()); //console.log(ui.helper.position());
ui.position.left += 17.5; ui.position.left += 17.5;
if (def.inputs > 0 && def.outputs > 0) { if (def.inputs > 0 && def.outputs > 0) {
mouseX = ui.position.left+(ui.helper.width()/2) - chartOffset.left + chart.scrollLeft(); mouseX = ui.position.left+(ui.helper.width()/2) - chartOffset.left + chart.scrollLeft();
mouseY = ui.position.top+(ui.helper.height()/2) - chartOffset.top + chart.scrollTop(); mouseY = ui.position.top+(ui.helper.height()/2) - chartOffset.top + chart.scrollTop();
if (!spliceTimer) { if (!spliceTimer) {
spliceTimer = setTimeout(function() { spliceTimer = setTimeout(function() {
var nodes = []; var nodes = [];