Connect

Vecta.Connect

new Vecta.Connect(node, [parent])

Vecta connection object

NameTypeAttributesDescription
nodeElement|String|Null

A node to be made into into a connection point, an ID or null to create a new connection point.

parentVecta.Shape|Elementoptional

The shape to add the connection point. Required only if creating new connection point.

Properties

.$jQuery

The jQuery wrapped node for the page.

NameTypeDescription
$jQuery

jQuery wrapper for page node.

Methods

.delete()

Delete a connection point from the parent shape.

.formula([field], [form]) Returns: string|Promise

Get or sets formula.

NameTypeAttributesDescription
fieldstringoptional

Accepts any method found in Vecta.Connect class. If not given, returns all formula

formstringoptional

Formula for given field. If not given, returns current formula null to remove or pass in a script to write into field as formula.

Returns:

If get, returns formula for given field. Otherwise, returns promise that resolves validity of the formula.

Examples:
var shape = Vecta.activePage.drawRect(0, 0, 50, 50),
     conn = new Vecta.Connect(null, shape);

     conn.formula('move.x', '10px').then(function() {
         console.log(conn.formula('move.x')); //10px
         console.log(conn.move().x); //10
     });

.id() Returns: string

Get the connection point id. Read only.

Returns:

Returns the connection point ID.

Examples:
var shape = Vecta.activePage.drawRect(0, 0, 50, 50),
     conn = new Vecta.Connect(null, shape);

console.log(conn.id()); //id of the connection point

.move([x], [y]) Returns: Object|Vecta.Connect

Get or set position of connection point, where x and y is local to the parent shape.

For get operations, both x and y must be undefined or not provided. If any one of the parameters is provided, then it is considered a set operation.

For set operations, if either x or y is not provided, then the current value is used in replacement.

If any of the provided parameters is an invalid length, then the operation fails with an error message in console.

NameTypeAttributesDescription
xnumber|stringoptional

X coordinate of connection point.

ynumber|stringoptional

Y coordinate of connection point.

Returns:

Returns the x and y coordinates if get or Vecta.Connect if set.

For get operations, the returned object will be in the following format:

{x: number|string, y: number|string}

Examples:
var shape = Vecta.activePage.drawRect(0, 0, 50, 50),
     conn = new Vecta.Connect(null, shape);

conn.move(10, 10); //move the connection point to 10px by 10px
console.log(conn.move()); //{x: 10, y: 10}

.parent() Returns: Vecta.Shape

Get the connection point's shape.

Returns:

Returns the connection point's parent shape.

Examples:
var shape = Vecta.activePage.drawRect(0, 0, 50, 50),
     conn = new Vecta.Connect(null, shape);

console.log(conn.parent().id());