ServerItemGroup

ServerItemGroup

The ServerItemGroup provides operations for the server to locate and move several different elements around.

Constructor

new ServerItemGroup(namespace, values)

Source:
Parameters:
Name Type Description
namespace Namespace Socket.io namespace for publishing changes.
values Object User-supplied data detailing the elements. Properties on this object that line up with module:shared.Element members will be stored. Any other properties will be ignored.

Extends

Members

(nullable) [@@holder] :module:mixins.Locker

Description:
  • If the Lockable is locked, stores a reference to the holder of the lock.
Source:
Overrides:
Mixes In:
Default Value:
  • undefined
If the Lockable is locked, stores a reference to the holder of the lock.
Type:

(nullable) [@@locked] :boolean

Description:
  • Whether this Lockable is locked.
Source:
Overrides:
Mixes In:
Default Value:
  • falsy
Whether this Lockable is locked.
Type:
  • boolean

(nullable) [@@scheduled] :boolean

Description:
  • Whether a publication has been scheduled.
Source:
Overrides:
Mixes In:
Default Value:
  • falsy
Whether a publication has been scheduled.
Type:
  • boolean

attributes :object

Description:
  • Additional attributes to set on the DOM element.
Source:
Overrides:
Default Value:
  • {}
See:
Additional attributes to set on the DOM element.
Type:
  • object
Example
{
 class: 'my-class',
 id: 'my-id',
 style: 'background-color: red;',
 ...
 // Any other attribute you want to set on the element
}

height :number

Source:
Overrides:
Default Value:
  • 300
Type:
  • number

(nullable) hitbox :module:shared.Hitbox

Description:
  • The hitbox for this Hittable instance. If it is null, hit detection will always return a falsy value.
Source:
Overrides:
Mixes In:
Default Value:
  • undefined
The hitbox for this Hittable instance. If it is null, hit detection will always return a falsy value.
Type:

(constant) id :number

Description:
  • Id to make Identifiables uniquely identifiable.
Source:
Overrides:
Mixes In:
Id to make Identifiables uniquely identifiable.
Type:
  • number

lockZ :boolean

Description:
  • Whether to raise item upon interaction or lock Z position instead.
Source:
Overrides:
Default Value:
  • false
Whether to raise item upon interaction or lock Z position instead.
Type:
  • boolean

namespace :Namespace

Description:
  • Socket.io namespace for publishing updates.
Source:
Socket.io namespace for publishing updates.
Type:
  • Namespace

rotation :number

Source:
Overrides:
Default Value:
  • 0
Type:
  • number

scale :number

Source:
Overrides:
Default Value:
  • 1
Type:
  • number

tagname :string

Description:
  • Type of DOM element this represents.
Source:
Overrides:
Default Value:
  • 'div'
Type of DOM element this represents.
Type:
  • string

type :string

Source:
Overrides:
Default Value:
  • 'item/polygonal'
Type:
  • string

width :number

Source:
Overrides:
Default Value:
  • 400
Type:
  • number

x :number

Source:
Overrides:
Default Value:
  • 0
Type:
  • number

y :number

Source:
Overrides:
Default Value:
  • 0
Type:
  • number

Methods

[@@emit]()

Description:
  • Emit the publication of this object and mark that it is no longer scheduled for publication.
Source:
Overrides:
Mixes In:

(protected) _emitPublication()

Description:
  • Emit the publication of this object. This method must be implemented by classes that use this mixin. It should never be called except by this mixin.
Source:
Overrides:
Mixes In:

containsPoint(px, py) → {boolean}

Description:
  • Checks whether a point with the given x,y coordinates is contained by this item.
Source:
Overrides:
Mixes In:
Parameters:
Name Type Description
px number x coordinate of the point to check.
py number y coordinate of the point to check.
Returns:
True if the (x,y) point is located inside this Item. False otherwise.
Type
boolean

isLocked() → {boolean}

Description:
  • Checks whether this lockable is locked.
Source:
Overrides:
Mixes In:
Returns:
True if the item is locked, false otherwise.
Type
boolean

lock(locker)

Description:
  • Lock this item.
Source:
Overrides:
Mixes In:
Parameters:
Name Type Description
locker module:mixins.Locker The holder of the lock.

moveBy(dxopt, dyopt)

Description:
  • Move the transformable by the given amounts.
Source:
Overrides:
Mixes In:
Parameters:
Name Type Attributes Default Description
dx number <optional>
0 Movement along the x axis.
dy number <optional>
0 Movement along the y ayis.

moveTo(xopt, yopt)

Description:
  • Move the transformable to the given coordinates.
Source:
Overrides:
Mixes In:
Parameters:
Name Type Attributes Default Description
x number <optional>
this.x x coordinate to move to.
y number <optional>
this.y y coordinate to move to.

publish()

Description:
  • Schedule a publication of this object for the end of this turn of the node.js event loop. This will have the effect of making sure that the object update is not emitted until after all transformations applied by the user have been completed (assuming they don't use async callbacks, of course), and that only one update will be emitted regardless of the number of transformations that are applied! All this and we don't even need to do any fancy software engineering!
Source:
Overrides:
Mixes In:

reversePoint(x, y) → {module:shared.Point2D}

Description:
  • Reverses "transformPoint"
Source:
Overrides:
Mixes In:
Parameters:
Name Type Description
x number x coordinate to transform.
y number y coordinate to transform.
Returns:
The transformed point.
Type
module:shared.Point2D

reversePointChange(dx, dy) → {module:shared.Point2D}

Description:
  • Reverses "transformPointChange"
Source:
Overrides:
Mixes In:
Parameters:
Name Type Description
dx number dx coordinate to transform.
dy number dy coordinate to transform.
Returns:
The transformed point.
Type
module:shared.Point2D

rotateBy(radiansopt, pxopt, pyopt)

Description:
  • Rotate the transformable by the given amount, in radians, around the given x,y point.
Source:
Overrides:
Mixes In:
Parameters:
Name Type Attributes Default Description
radians number <optional>
0 The amount of rotation to apply to the transformable, in radians.
px number <optional>
this.x The x coordinate of the point around which to rotate.
py number <optional>
this.y The y coordinate of the point around which to rotate.

scaleBy(dsopt, mxopt, myopt, deltaFnopt)

Description:
  • Adjust the transformable by the given scale.
Source:
Overrides:
Mixes In:
Parameters:
Name Type Attributes Default Description
ds number <optional>
1 Change in desired scale.
mx number <optional>
this.x The x coordinate of the point around which to scale.
my number <optional>
this.y The y coordinate of the point around which to scale.
deltaFn string <optional>
'times' The Point2D operation to apply to the delta point to extract the corrext this.x and this.y values. Should be one of 'times' or 'divideBy' depending on the use case.

setParentForItems()

Description:
  • Update children items to have parent property.
Source:

toJSON()

Source:
Overrides:
Returns:
object A serialized version of the item, ready for transmission.

transformPoint(x, y) → {module:shared.Point2D}

Description:
  • Transforms a point from the transformable space to the default space. That is, it applies to the point the same transformations that apply to this Transformable2D, but in reverse.
Source:
Overrides:
Mixes In:
Parameters:
Name Type Description
x number x coordinate to transform.
y number y coordinate to transform.
Returns:
The transformed point.
Type
module:shared.Point2D

transformPointChange(dx, dy) → {module:shared.Point2D}

Description:
  • Transforms a "change" point from the transformable space to the default space. Very much like the 'transformPoint' function, except that it does not apply translation.
Source:
Overrides:
Mixes In:
Parameters:
Name Type Description
dx number dx coordinate to transform.
dy number dy coordinate to transform.
Returns:
The transformed point.
Type
module:shared.Point2D

unlock()

Description:
  • Unlock this item.
Source:
Overrides:
Mixes In: