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

Restrict objects in dynamically created rectangle

$
0
0

@AB wrote:

Hi Team,

I am working with floor planner app.
Problem Statement

Requied Output

I am able to achieve for only single wall
when in “FloorPalnner-Templates-Furniture.js”
following function

function stayInViewport(part, pt, gridpt) {

** var diagram = part.diagram;**
** if (diagram === null) return pt;**
** // compute the area inside the viewport**
** var v = diagram.fixedBounds.copy();**
** v.subtractMargin(diagram.padding);**
** var b = part.actualBounds;**
** var loc = part.location;**
** // get the bounds of the part being dragged**
** var x = pt.x - (loc.x - b.x);**
** var y = pt.y - (loc.y - b.y);**
** var r = new go.Rect(x, y, b.width, b.height);**
** // now limit the location appropriately**
** var xa = Math.max(v.x + 1, Math.min(pt.x, v.right - b.width - 1)) + (loc.x - b.x);**
** var ya = Math.max(v.y + 1, Math.min(pt.y, v.bottom - b.height - 1)) + (loc.y - b.y);**

** return new go.Point(xa, ya);**

}

at dragComputation: stayInViewport, of makeDefaultNode Function

fixedBounds is set when showrectangle function is called on right click.

I am not able to achieve(object should not move outside the rectangle) for all wall dynamically can you please help me out how can i achieve for every wall.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles