Namespace: Collection

fabric.Collection

Source:

Methods

(static) add(…object) → {Self}

Adds objects to collection, Canvas or Group, then renders canvas (if `renderOnAddRemove` is not `false`). in case of Group no changes to bounding box are made. Objects should be instances of (or inherit from) fabric.Object Use of this function is highly discouraged for groups. you can add a bunch of objects with the add method but then you NEED to run a addWithUpdate call for the Group class or position/bbox will be wrong.
Parameters:
Name Type Attributes Description
object fabric.Object <repeatable>
Zero or more fabric instances
Source:
Returns:
thisArg
Type
Self

(static) complexity() → {Number}

Returns number representation of a collection complexity
Source:
Returns:
complexity
Type
Number

(static) contains(object) → {Boolean}

Returns true if collection contains an object
Parameters:
Name Type Description
object Object Object to check against
Source:
Returns:
`true` if collection contains an object
Type
Boolean

(static) forEachObject(callback, context) → {Self}

Executes given function for each object in this group
Parameters:
Name Type Description
callback function Callback invoked with current object as first argument, index - as second and an array of all objects - as third. Callback is invoked in a context of Global Object (e.g. `window`) when no `context` argument is given
context Object Context (aka thisObject)
Source:
Returns:
thisArg
Type
Self

(static) getObjects(typeopt) → {Array}

Returns an array of children objects of this instance Type parameter introduced in 1.3.10
Parameters:
Name Type Attributes Description
type String <optional>
When specified, only objects of this type are returned
Source:
Returns:
Type
Array

(static) insertAt(object, index, nonSplicing) → {Self}

Inserts an object into collection at specified index, then renders canvas (if `renderOnAddRemove` is not `false`) An object should be an instance of (or inherit from) fabric.Object Use of this function is highly discouraged for groups. you can add a bunch of objects with the insertAt method but then you NEED to run a addWithUpdate call for the Group class or position/bbox will be wrong.
Parameters:
Name Type Description
object Object Object to insert
index Number Index to insert object at
nonSplicing Boolean When `true`, no splicing (shifting) of objects occurs
Source:
Returns:
thisArg
Type
Self

(static) isEmpty() → {Boolean}

Returns true if collection contains no objects
Source:
Returns:
true if collection is empty
Type
Boolean

(static) item(index) → {Self}

Returns object at specified index
Parameters:
Name Type Description
index Number
Source:
Returns:
thisArg
Type
Self

(static) remove(…object) → {Self}

Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)
Parameters:
Name Type Attributes Description
object fabric.Object <repeatable>
Zero or more fabric instances
Source:
Returns:
thisArg
Type
Self

(static) size() → {Number}

Returns a size of a collection (i.e: length of an array containing its objects)
Source:
Returns:
Collection size
Type
Number