API Docs for: 0.0.2
Show:

layout.Relative Class

Class for relative positioning of child views. This is the most powerful layout in ludoJS. An instance of this class is created dynamically when layout.type for a View is set to "relative". This layout uses ideas from Android's relative layout. When using a relative layout, all layout properties should be defined inside a layout config object. That also includes width and height.

Constructor

layout.Relative

()

Methods

addChildEvents

(
  • child
)
private

Add events to child view

Parameters:

  • child ludo.View

arrangeChildren

() private

Before first resize, the internal children array is arranged so that views dependent of other views are resized after the view it's depending on. example: if view "a" has leftOf property set to view "b", then view "b" should be resized and positioned first. This method rearranges the internal children array according to this

assignDefaultCoordinates

(
  • child
)
private

Creates empty newChildCoordinates and lastChildCoordinates for a child view

Parameters:

  • child ludo.View | ludo.layout.Resizer

beforeResize

(
  • resize
  • child
)
private

Before resize function executed for a resize handle

Parameters:

  • resize ludo.layout.Resizer
  • child ludo.View

clearChildren

() private

Clear internal children array. When this is done, resize function will be recreated. This happens when a child is removed or when a new child is added

createResizables

() private

Create resize handles for resizable children

createResizeFunctions

() private

Create/Compile resize functions for each child

fixLayoutReferences

() private

Convert layout id references to direct view reference for optimal performance

getAlignmentFn

(
  • child
  • alignment
  • property
)
Function private

Return special resize function for the properties alignLeft, alignRight, alignTop and alignBottom

Parameters:

Returns:

getChildren

() Array private

Return internal children array

Returns:

getDependencies

(
  • child
)
Array private

Return all the siblings a child is depending on for layout

Parameters:

  • child ludo.View

Returns:

getLayoutFn

(
  • property
  • child
)
Function | Undefined private

Return one resize function for a child

Parameters:

  • property String
  • child ludo.View

Returns:

Function | Undefined:

Example:

getLayoutFn(left, view) may return function(){ this.newChildCoordinates[view.id]['left'] = 20; } The resize functions are created before first resize is made. For second resize, the layout functions for each view will simply be called. This is done for optimal performance so that we don't need to calculate more than we have to(Only first time).

getLayoutFnsFor

(
  • child
)
Array private

Return array of resize function to call when view is resized.

Parameters:

  • child ludo.View

Returns:

getLayoutLayoutFn

(
  • child
)
Function private

Final resize function for each child. All the other dynamically created layout function stores values for the left,width,top,bottom, width and height properties. This function call the resize function for each view with the values of these previously set properties

Parameters:

  • child ludo.View

Returns:

getPropertyFn

(
  • child
  • property
)
Function | Undefined private

Returns layout function for the width and height layout properties

Parameters:

  • child ludo.View
  • property String

Returns:

Function | Undefined:

getReference

(
  • child
)
ludo.View private

Return direct reference to child

Parameters:

Returns:

ludo.View:

getResizableFor

(
  • child
  • direction
)
ludo.layout.Resizer private

Return resizable handle for a child view

Parameters:

  • child ludo.View
  • direction String

Returns:

ludo.layout.Resizer:

getResizeFnFor

(
  • child
)
Function private

Return resize function for a child

Parameters:

  • child ludo.View

Returns:

getResizerLayout

(
  • child
  • resize
)
ludo.layout.RelativeSpec private

Return layout config for a resize handle

Parameters:

  • child ludo.View
  • resize String

Returns:

ludo.layout.RelativeSpec:

getSiblingForResize

(
  • child
  • direction
)
ludo.View | Undefined private

Return sibling which may be affected when a child is resized

Parameters:

  • child ludo.View
  • direction String

Returns:

ludo.View | Undefined:

getWronglyArrangedChild

() ludo.View | Undefined private

Return a child which should be rearrange because it's layout depends on a next sibling

Returns:

ludo.View | Undefined:

isArrangedBefore

(
  • child
  • of
)
Boolean private

Returns true if a child is previous sibling of another child

Parameters:

  • child ludo.View
  • of ludo.View

Returns:

isChildResizable

(
  • child
)
Boolean private

Returns true if a child is resizable

Parameters:

  • child ludo.View

Returns:

onNewChild

(
  • child
)
private

Validate and set required layout properties of new children

Parameters:

  • child ludo.View

positionChild

(
  • child
  • property
  • value
)
private

Position child at this coordinates

Parameters:

prepareResize

() private

No resize done yet, create resize functions

updateLastCoordinatesFor

(
  • child
)
private

Update lastChildCoordinates properties for a child after resize is completed

Parameters:

  • child ludo.View

updateReferences

(
  • property
  • child
  • resizer
)
private

Update layout references when a resize handle has been created. example: When a resize handle is added to the left of a child view. The leftOf view of this child is now the resize handle and not another view

Parameters:

  • property String
  • child ludo.View
  • resizer ludo.layout.Resizer

Properties

depKeys

Unknown private

All the layout options where value is a reference to another child

lastChildCoordinates

Object private

Internal storage of child coordinates for last resize

layoutFnProperties

Array private

Array of valid layout properties

newChildCoordinates

Object private

Internal child coordinates set during resize