mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
prevennt node from moving out of workspace
This commit is contained in:
parent
f760354e82
commit
02308f9e2f
@ -105,6 +105,8 @@ RED.view.tools = (function() {
|
|||||||
$(document).one('keyup',endKeyboardMove);
|
$(document).one('keyup',endKeyboardMove);
|
||||||
endMoveSet = true;
|
endMoveSet = true;
|
||||||
}
|
}
|
||||||
|
var space_width = 5000;
|
||||||
|
var space_height = 5000;
|
||||||
var minX = 0;
|
var minX = 0;
|
||||||
var minY = 0;
|
var minY = 0;
|
||||||
var node;
|
var node;
|
||||||
@ -120,6 +122,12 @@ RED.view.tools = (function() {
|
|||||||
node.n.dirty = true;
|
node.n.dirty = true;
|
||||||
node.n.x += dx;
|
node.n.x += dx;
|
||||||
node.n.y += dy;
|
node.n.y += dy;
|
||||||
|
if ((node.n.x +node.n.w/2) >= space_width) {
|
||||||
|
node.n.x = space_width -node.n.w/2;
|
||||||
|
}
|
||||||
|
if ((node.n.y +node.n.h/2) >= space_height) {
|
||||||
|
node.n.y = space_height -node.n.h/2;
|
||||||
|
}
|
||||||
node.n.dirty = true;
|
node.n.dirty = true;
|
||||||
if (node.n.type === "group") {
|
if (node.n.type === "group") {
|
||||||
RED.group.markDirty(node.n);
|
RED.group.markDirty(node.n);
|
||||||
@ -130,6 +138,7 @@ RED.view.tools = (function() {
|
|||||||
minY = Math.min(node.n.y-node.n.h/2-5,minY);
|
minY = Math.min(node.n.y-node.n.h/2-5,minY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log("; mS:", dx, dy, minX, minY);
|
||||||
if (minX !== 0 || minY !== 0) {
|
if (minX !== 0 || minY !== 0) {
|
||||||
for (var n = 0; n<moving_set.length; n++) {
|
for (var n = 0; n<moving_set.length; n++) {
|
||||||
node = moving_set[n];
|
node = moving_set[n];
|
||||||
|
Loading…
Reference in New Issue
Block a user