mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3731 from node-red-hitachi/fix-node-move
Fix to prevent node from moving out of workspace
This commit is contained in:
commit
a38d3981df
@ -105,6 +105,9 @@ RED.view.tools = (function() {
|
||||
$(document).one('keyup',endKeyboardMove);
|
||||
endMoveSet = true;
|
||||
}
|
||||
var dim = RED.view.dimensions();
|
||||
var space_width = dim.width;
|
||||
var space_height = dim.height;
|
||||
var minX = 0;
|
||||
var minY = 0;
|
||||
var node;
|
||||
@ -120,6 +123,12 @@ RED.view.tools = (function() {
|
||||
node.n.dirty = true;
|
||||
node.n.x += dx;
|
||||
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;
|
||||
if (node.n.type === "group") {
|
||||
RED.group.markDirty(node.n);
|
||||
|
@ -6236,6 +6236,12 @@ RED.view = (function() {
|
||||
showQuickAddDialog:showQuickAddDialog,
|
||||
calculateNodeDimensions: calculateNodeDimensions,
|
||||
getElementPosition:getElementPosition,
|
||||
showTooltip:showTooltip
|
||||
showTooltip:showTooltip,
|
||||
dimensions: function() {
|
||||
return {
|
||||
width: space_width,
|
||||
height: space_height
|
||||
};
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user