Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Drag Unoccupied

$
0
0

@Ab06100 wrote:

how we can implement this(https://gojs.net/latest/samples/dragUnoccupied.html) with floor planner palette.
i tried doing so but it gives Rect is not defined

var $ = go.GraphObject.make;
return $(go.Node, "Shape",
{
resizable: true,
rotatable: true,
toolTip: makeNodeToolTip(),
resizeAdornmentTemplate: makeFurnitureResizeAdornmentTemplate(),
rotateAdornmentTemplate: makeFurnitureRotateAdornmentTemplate(),
contextMenu: makeContextMenu(),
locationObjectName: "SHAPE",
resizeObjectName: "SHAPE",
rotateObjectName: "SHAPE",
minSize: new go.Size(5, 5),
dragComputation: avoidNodeOverlap,
locationSpot: go.Spot.Center,
selectionAdorned: false, // use a Binding on the Shape.stroke to show selection
doubleClick: function (e) {
if (e.diagram.floorplanUI) e.diagram.floorplanUI.hideShow("selectionInfoWindow")
}
}

function avoidNodeOverlap(node, pt, gridpt) {
var bnds = node.actualBounds;
var loc = node.location;
// see if the area at the proposed location is unoccupied
var x = pt.x - (loc.x - bnds.x);
var y = pt.y - (loc.y - bnds.y);
var r = new Rect(x, y, bnds.width, bnds.height);
if (isUnoccupied(r, node)) return pt; // OK
return loc; // give up -- don't allow the node to be moved to the new location
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles