Home Reference Source

Function

Static Public Summary
public

ExistsRequest(url: *): *

public

Prepares a GET request and initiates the communication.

public

ParseStringToXml(text: *): *

public

Prepares a POST request and initiates the communication.

public

TrueSizedLayoutDockHelper(context: LayoutContext, options: Object)

public

UrlParser(url: *): *

Parses a url

public

annotate(fn: *, annotation: *)

public

callbackToPromise(functionWithCallback: *, args: ...*): *

public

combineOptions(defaultOptions: *, options: *): *

public

createProviderFromFnOrClass(fnOrClass: *, annotations: *): *

public

event._subscribe(subscriptionType: String, eventName: String, callback: Function): Function

Internal function used by the event decorators to generalize the idea of on, once, and off.

public

event.on(eventName: *, callback: *): Function

Adds an event listener to the renderable when specific event happened.

public

event.once(eventName: *, callback: *): Function

Adds an event listener to the renderable when specific event happened once.

public

event.pipe(pipeToName: *): Function

Pipes events from one renderable to another.

public

Sets the default flow options for a View.

public

flow.defaultState(stateName: String, stateOptions: Object, transformations: Array.Function): Function

Functions the same as @flow.stateStep(), and additionally also immediately applies the decorators passed into the 'transformations' argument.

public

flow.multipleStateStep(stateName: String, states: Array.Object): Function

A wrapper around @flow.stateStep, to allow defining multiple steps with the same state name.

public

flow.stateStep(stateName: String, stateOptions: Object, transformations: Array.Function): Function

Used to define a state that the renderable is able to flow to.

public

Defines the View-level states, that exist of concurrently and sequentially executed renderable-level states.

public

hasAnnotation(fn: *, annotationClass: *): boolean

public

inject(tokens: ...*): *

public

isFunction(value: *): *

public

isObject(value: *): *

public

isUpperCase(char: *): *

public

layout._dockTo(dockMethod: *, size: *, space: *, zIndex: *): Function

Internal function to do docking

public

Translates the renderable by a proportion of the context size.

public

Creates an animation controller to show/hide the renderable.

public

layout.columnDockPadding(maxContentWidth: Number, defaultPadding: Array.Number): Function

Like @layout.dockPadding, sets the padding between this view and its docked content.

public

layout.custom(customLayoutFunction: *): Function

Adds a custom layout function to the view.

public

Docks the renderable to the bottom.

public

Fills the space that is left after the docking with this renderable.

public

Docks the renderable to the left.

public

Marks the renderable as not being docked anymore.

public

Docks the renderable to the right.

public

Docks the renderable to the top.

public

layout.dockPadding(firstMargin: Number, secondMargin: Number, thirdMargin: Number, fourthMargin: Number): Function

Sets the margins for the docked content.

public

Specifies the space that should come before the docked renderable.

public

Makes the renderable allowed to be dragged around.

public

Makes the view flow by tweening all intermediate stages of a changed attribute of any renderable.

public

Marks the renderable to cover the entire screen.

public

Experimental feature of scrolling natively.

public

Sets the opacity of a renderable.

public

Sets the point where the renderable has its anchor from where rotation and translation will be done.

public

Merely marks a view property as a decorated renderable, which allows it to be rendered.

public

Rotates the renderable around any of the three axes (in radians).

public

Rotates the renderable around any of the three axes (in radians) relatively to the current rotation

public

Specifies the scale of a renderable.

public

layout.scrollable(options: {}): Function

Makes the view as scrollable.

public

Specifies the size of the renderable.

public

Specifies the skew of a renderable.

public

Makes the renderable swipable with physics-like velocity after the dragging is released.

public

Specifies a translation of a renderable.

public

Specifies a relative translation of a renderable.

public

limit(min: *, value: *, max: *): *

@author: Tom Clement (tjclement)

public

provide(tokens: ...*): *

public

readAnnotations(fn: *): *

public
public

toString(token: *): *

public

waitMilliseconds(milliseconds: *): *

Static Public

public ExistsRequest(url: *): * source

import {ExistsRequest} from 'arva-js/utils/request/RequestClient.js'

Params:

NameTypeAttributeDescription
url *

Return:

*

public GetRequest(url: String): Promise source

import {GetRequest} from 'arva-js/utils/request/RequestClient.js'

Prepares a GET request and initiates the communication.

Params:

NameTypeAttributeDescription
url String

Return:

Promise

Returns an asynchronous response object which can be managed to read the response in an chaining proces.

public ParseStringToXml(text: *): * source

import {ParseStringToXml} from 'arva-js/utils/request/XmlParser.js'

@author: Hans van den Akker (mysim1)

Params:

NameTypeAttributeDescription
text *

Return:

*

public PostRequest(options: Object): Promise source

import {PostRequest} from 'arva-js/utils/request/RequestClient.js'

Prepares a POST request and initiates the communication.

Params:

NameTypeAttributeDescription
options Object

Provide properties: { headers: <Map>, data: <string>, url: <string> }

Return:

Promise

Returns an asynchronous response object which can be managed to read the response in an chaining proces.

public TrueSizedLayoutDockHelper(context: LayoutContext, options: Object) source

import {TrueSizedLayoutDockHelper} from 'arva-js/layout/TrueSizedLayoutDockHelper.js'

Params:

NameTypeAttributeDescription
context LayoutContext

layout-context

options Object
  • optional

additional options

options.margins Object
  • optional

margins to start out with (default: 0px)

options.translateZ Number
  • optional

z-index to use when translating objects (default: 0)

public UrlParser(url: *): * source

import {UrlParser} from 'arva-js/utils/request/UrlParser.js'

Parses a url

Params:

NameTypeAttributeDescription
url *

Return:

*

public annotate(fn: *, annotation: *) source

import {annotate} from 'arva-js/utils/di/Decorators.js'

Params:

NameTypeAttributeDescription
fn *
annotation *

public callbackToPromise(functionWithCallback: *, args: ...*): * source

import {callbackToPromise} from 'arva-js/utils/CallbackHelpers.js'

Params:

NameTypeAttributeDescription
functionWithCallback *
args ...*

Return:

*

public combineOptions(defaultOptions: *, options: *): * source

import {combineOptions} from 'arva-js/utils/CombineOptions.js'

Params:

NameTypeAttributeDescription
defaultOptions *
options *

Return:

*

public createProviderFromFnOrClass(fnOrClass: *, annotations: *): * source

import {createProviderFromFnOrClass} from 'arva-js/utils/di/providers.js'

Params:

NameTypeAttributeDescription
fnOrClass *
annotations *

Return:

*

public event._subscribe(subscriptionType: String, eventName: String, callback: Function): Function source

Internal function used by the event decorators to generalize the idea of on, once, and off.

Params:

NameTypeAttributeDescription
subscriptionType String

A type of subscription function, e.g. on

eventName String

The event name

callback Function

that is called when event has happened

Return:

Function

public event.on(eventName: *, callback: *): Function source

Adds an event listener to the renderable when specific event happened.

Params:

NameTypeAttributeDescription
eventName *
callback *

Return:

Function

A decorator function

Example:

@layout.on('click', function() {this._handleClick})
thing = new Surface({properties: {backgroundColor: 'red'}});

_handleClick() { ... }

public event.once(eventName: *, callback: *): Function source

Adds an event listener to the renderable when specific event happened once.

Params:

NameTypeAttributeDescription
eventName *
callback *

Return:

Function

A decorator function

Example:

@layout.size(100,100)
@layout.stick.center()
@layout.once('click', function() {this._handleClick})
thing = new Surface({properties: {backgroundColor: 'red'}});

_handleClick() { ... }

public event.pipe(pipeToName: *): Function source

Pipes events from one renderable to another. The other renderable has to be declared above the one that is doing the piping, otherwise an exception will be thrown.

Params:

NameTypeAttributeDescription
pipeToName *

Return:

Function

Example:

@layout.fullSize()
@layout.pipe('dbsv')
//Pipe events to another renderable declared above, called 'dbsv'
scrollableSurface = new Surface();

public flow.defaultOptions(flowOptions: Object): Function source

Sets the default flow options for a View. These options will be overridden by each of its renderables, if they have flow options defined through e.g. flow.stateStep()

Params:

NameTypeAttributeDescription
flowOptions Object

Options to set as default.

flowOptions.delay Object
  • optional

The amount of milliseconds to wait in between state transitions.

flowOptions.transition Object
  • optional

A Famo.us-compatible transition object defining the animation specifics.

flowOptions.transition.curve Object
  • optional

The animation curve to use when flowing from one state to another, e.g. Easing.outCubic.

flowOptions.transition.duration Object
  • optional

The amount of milliseconds a flow animation should take.

Return:

Function

Example:

@flow.defaultOptions({ transition: { curve: Easing.outCubic, duration: 200 } })
class MyView extends View {
}

public flow.defaultState(stateName: String, stateOptions: Object, transformations: Array.Function): Function source

Functions the same as @flow.stateStep(), and additionally also immediately applies the decorators passed into the 'transformations' argument. Used to define a state step, without having to also manually apply the same decorators to the renderable to ensure it is rendered this way on initial show.

Params:

NameTypeAttributeDescription
stateName String

The state name to assign to this state step.

stateOptions Object
  • optional

Flow options to use in the state step.

stateOptions.delay Object
  • optional

The amount of milliseconds to wait in between state transitions.

stateOptions.transition Object
  • optional

A Famo.us-compatible transition object defining the animation specifics.

stateOptions.transition.curve Object
  • optional

The animation curve to use when flowing from one state to another, e.g. Easing.outCubic.

stateOptions.transition.duration Object
  • optional

The amount of milliseconds a flow animation should take.

transformations Array.Function

Decorators to assign to this state, and to apply initially, passed in as regular comma-separated arguments.

Return:

Function

Example:

// Initial size is [100, 100], and rendered at center of parent.
@flow.defaultState('active', {}, layout.size(100, 100), layout.stick.center())
myRenderable = new Surface();

public flow.multipleStateStep(stateName: String, states: Array.Object): Function source

A wrapper around @flow.stateStep, to allow defining multiple steps with the same state name.

Params:

NameTypeAttributeDescription
stateName String

State name to assign states to.

states Array.Object

An array of {stateOptions: [..], transformations: [..]} objects, with stateOptions and transformations being the same usage as @flow.stateStep().

Return:

Function

public flow.stateStep(stateName: String, stateOptions: Object, transformations: Array.Function): Function source

Used to define a state that the renderable is able to flow to. When multiple state steps with the same state name are defined, flowing into that state will sequentially execute all defined steps with that state name.

Params:

NameTypeAttributeDescription
stateName String

The state name to assign to this state step.

stateOptions Object
  • optional

Flow options to use in the state step.

stateOptions.delay Object
  • optional

The amount of milliseconds to wait in between state transitions.

stateOptions.transition Object
  • optional

A Famo.us-compatible transition object defining the animation specifics.

stateOptions.transition.curve Object
  • optional

The animation curve to use when flowing from one state to another, e.g. Easing.outCubic.

stateOptions.transition.duration Object
  • optional

The amount of milliseconds a flow animation should take.

transformations Array.Function

Decorators to assign to this state, and to apply initially, passed in as regular comma-separated arguments.

Return:

Function

Example:

// Initial size is [0, 0], and rendered at top left of parent, because no @flow.defaultStep() was done,
// and no other decorators are applied to the renderable.
@flow.stateStep('active', {}, layout.size(100, 100), layout.stick.center())
myRenderable = new Surface();

public flow.viewStates(states: Object): Function source

Defines the View-level states, that exist of concurrently and sequentially executed renderable-level states. When e.g. View.setViewFlowState('active') is called, the renderable states defined in the view-level state 'active' are executed.

Params:

NameTypeAttributeDescription
states Object

An object keyed by View-level state names, with values of arrays of objects.

Return:

Function

Example:

// Calling setViewFlowState('active') will first hide the loader, and when that is completed, show both buttons at the same time.
@flow.viewStates({ 'active': [{loader: 'hidden'}, { button1: 'active', button2: 'active' }] })
class MyView extends View {

  @flow.defaultState('shown', {}, layout.opacity(1), layout.fullSize())
  @flow.stateStep('hidden', {}, layout.opacity(0))
  loader = new Surface();

  @flow.defaultState('inactive', {}, layout.opacity(0), layout.size(100, 100), layout.stick.top())
  @flow.stateStep('active', {}, layout.opacity(1))
  button1 = new Surface();

  @flow.defaultState('inactive', {}, layout.opacity(0), layout.size(100, 100), layout.stick.bottom())
  @flow.stateStep('active', {}, layout.opacity(1))
  button1 = new Surface();
}

public hasAnnotation(fn: *, annotationClass: *): boolean source

import {hasAnnotation} from 'arva-js/utils/di/Decorators.js'

Params:

NameTypeAttributeDescription
fn *
annotationClass *

Return:

boolean

public inject(tokens: ...*): * source

import {inject} from 'arva-js/utils/di/Decorators.js'

Params:

NameTypeAttributeDescription
tokens ...*

Return:

*

public isFunction(value: *): * source

import {isFunction} from 'arva-js/utils/di/util.js'

Params:

NameTypeAttributeDescription
value *

Return:

*

public isObject(value: *): * source

import {isObject} from 'arva-js/utils/di/util.js'

Params:

NameTypeAttributeDescription
value *

Return:

*

public isUpperCase(char: *): * source

import {isUpperCase} from 'arva-js/utils/di/util.js'

Params:

NameTypeAttributeDescription
char *

Return:

*

public layout._dockTo(dockMethod: *, size: *, space: *, zIndex: *): Function source

Internal function to do docking

Params:

NameTypeAttributeDescription
dockMethod *
size *
space *
zIndex *

Return:

Function

public layout.align(): Function source

Translates the renderable by a proportion of the context size.

Params:

NameTypeAttributeDescription
x. Number

The proportion of the context width that is going to be translated.

y. Number

The proportion of the context height that is going to be translated.

Return:

Function

A decorator function.

Example:

@layout.align(0.5, 0.5)
@layout.size(100,100)
//Displays a red box just below the vertical mid point and past the horizontal mid point
renderable = new Surface({properties: {backgroundColor: 'red'}});

public layout.animate(options: Object): Function source

Creates an animation controller to show/hide the renderable. Renderables can be shown by calling this.showRenderable(renderableName) and hidden using this.hideRenderable(renderableName) or this.showRenderable(renderableName, false). When a renderable has been shown, it will emit the event 'shown'.

Params:

NameTypeAttributeDescription
options Object
  • optional

The same as famous-flex Animation Controller, plus 2 more:

options.showInitially Boolean
  • optional

Whether to show the renderable when the view is created. (Default: true).

options.waitFor String
  • optional

If specified, it will wait for the renderable with the specified name to show before showing the renderable

options.transition Object
  • optional

Transition options.

options.animation Function
  • optional

Animation function (default: AnimationController.Animation.FadedZoom).

options.zIndexOffset Number
  • optional

Optional z-index difference between the hiding & showing renderable (default: 0).

options.keepHiddenViewsInDOMCount Number
  • optional

Keeps views in the DOM after they have been hidden (default: 0).

options.show Object
  • optional

Show specific options.

options.show.transition Object
  • optional

Show specific transition options.

options.show.animation Function
  • optional

Show specific animation function.

options.hide Object
  • optional

Hide specific options.

options.hide.transition Object
  • optional

Hide specific transition options.

options.hide.animation Function
  • optional

Hide specific animation function.

options.transfer Object
  • optional

Transfer options.

options.transfer.transition Object
  • optional

Transfer specific transition options.

options.transfer.zIndex Number
  • optional

Z-index the tranferables are moved on top while animating (default: 10).

options.transfer.fastResize Bool
  • optional

When enabled, scales the renderable i.s.o. resizing when doing the transfer animation (default: true).

options.transfer.items Array
  • optional

Ids (key/value) pairs (source-id/target-id) of the renderables that should be transferred.

Return:

Function

Example:

@layout.stick.center()
@layout.size(100,100)
@layout.animate({transition: {duration: 350}})
renderable = new Surface({properties: {backgroundColor: 'red'}});

public layout.columnDockPadding(maxContentWidth: Number, defaultPadding: Array.Number): Function source

Like @layout.dockPadding, sets the padding between this view and its docked content. When the screen width plus this padding exceeds maxContentWidth, the padding is increased, so that the content is never wider than maxContentWidth.

Params:

NameTypeAttributeDescription
maxContentWidth Number

Maximum width the content should be allowed to be.

defaultPadding Array.Number

A 1-D, 2-D, or 4-D array of padding numbers, just like the padding spec in CSS.

Return:

Function

Example:

@layout.columnDockPadding(720, [16])
//Creates a class with 16px margin on all sides for docked renderables
class myView extends View{

 //Will be displayed with margin to the top and sides, and will at max be 720px wide.
 @layout.dock.top(20)
 onTop = new Surface({content: "hello world"});

 //Will be displayed without margin since we're using @layout.stick instead of @layout.dock
 @layout.stick.bottom
 onButtom = new Surface({content: "hey hey"});
}

public layout.custom(customLayoutFunction: *): Function source

Adds a custom layout function to the view. This decorator works directly on the object so you shouldn't pass any arguments nor use parentheses.

Params:

NameTypeAttributeDescription
customLayoutFunction *

Return:

Function

A decorator function

Example:

@layout.custom((context) => {
 context.set('myRenderable', {
 size: [100, 100]
})
class MyView extends View {
 constructor(options) {
     super(options);
     this.renderables.myRenderable = new Surface({properties: {backgroundColor: 'red'}});
 }
}

public layout.dock.bottom(space: Number, zIndex: Number): Function source

Docks the renderable to the bottom. When using both a docked size and the layout.size decorator, then that layout.size becomes the actual inner size. The renderable can then be stickd within the docking area with origin and align. When combined with align, treats the context size the docking size. When using layout.size without specifying a docked size, it will use that size as docking size. Useful for automatic sizing when parent defines true size and orthogonal size (e.g. height for dock 'left') has to be defined.

Params:

NameTypeAttributeDescription
size]. Number | Function
  • optional

The size of the renderable in the one dimension that is being docked, e.g. dock left or right will be width, whereas dock top or bottom will result in height. For more information about different variations, see layout.size.

space Number
  • optional

= 0]. Any space that should be inserted before the docked renderable

zIndex Number
  • optional

= 0]. DEPRECATED: Use translate(0, 0, zIndex) instead.

Return:

Function

A decorator function

Example:

@layout.dock.bottom(30, 0, 10)
@layout.size(15, undefined)
@layout.origin(0.5, 0)
@layout.align(0.5, 0)
dockedRenderable = new Surface({properties: {backgroundColor: 'red'}});

public layout.dock.fill(): Function source

Fills the space that is left after the docking with this renderable. When using layout.size, it will use that size as an inner size. This works similarly to other docking, from where translate, size, origin, align, etc can be specified.

Return:

Function

A decorator function

Example:

@layout.dock.fill()
filledRenderable = new Surface({properties: {backgroundColor: 'red'}});

public layout.dock.left(): Function source

Docks the renderable to the left. When using both a docked size and the layout.size decorator, then that layout.size becomes the actual inner size. The renderable can then be stickd within the docking area with origin and align. When combined with align, treats the context size the docking size. When using layout.size without specifying a docked size, it will use that size as docking size. Useful for automatic sizing when parent defines true size and orthogonal size (e.g. height for dock 'left') has to be defined.

Params:

NameTypeAttributeDescription
size]. Number | Function
  • optional

The size of the renderable in the one dimension that is being docked, e.g. dock left or right will be width, whereas dock top or bottom will result in height. For more information about different variations, see layout.size.

space]. Number
  • optional

Any space that should be inserted before the docked renderable

zIndex]. Number
  • optional

DEPRECATED: Use translate(0, 0, zIndex) instead.

Return:

Function

A decorator function

Example:

@layout.dock.left(30, 0, 10)
@layout.size(15, undefined)
@layout.origin(0.5, 0)
@layout.align(0.5, 0)
dockedRenderable = new Surface({properties: {backgroundColor: 'red'}});

public layout.dock.none(): Function source

Marks the renderable as not being docked anymore. Useful when dynamically changing decorations through this.decorateRenderable or this.setRenderableFlowState

Return:

Function

A decorator function

Example:

@layout.dock.fill()
@flow.stateStep('nonFilled', layout.dock.none(), layout.size(100, 100))
filledRenderable = new Surface({properties: {backgroundColor: 'red'}});

public layout.dock.right(): Function source

Docks the renderable to the right. When using both a docked size and the layout.size decorator, then that layout.size becomes the actual inner size. The renderable can then be stickd within the docking area with origin and align. When combined with align, treats the context size the docking size. When using layout.size without specifying a docked size, it will use that size as docking size. Useful for automatic sizing when parent defines true size and orthogonal size (e.g. height for dock 'left') has to be defined.

Params:

NameTypeAttributeDescription
size]. Number | Function
  • optional

The size of the renderable in the one dimension that is being docked, e.g. dock left or right will be width, whereas dock top or bottom will result in height. For more information about different variations, see layout.size.

space]. Number
  • optional

Any space that should be inserted before the docked renderable

zIndex]. Number
  • optional

DEPRECATED: Use translate(0, 0, zIndex) instead.

Return:

Function

A decorator function

Example:

@layout.dock.right(30, 0, 10)
@layout.size(15, undefined)
@layout.origin(0.5, 0)
@layout.align(0.5, 0)
dockedRenderable = new Surface({properties: {backgroundColor: 'red'}});

public layout.dock.top(space: Number, zIndex: Number): Function source

Docks the renderable to the top. When using both a docked size and the layout.size decorator, then that layout.size becomes the actual inner size. The renderable can then be stickd within the docking area with origin and align. When combined with align, treats the context size the docking size. When using layout.size without specifying a docked size, it will use that size as docking size. Useful for automatic sizing when parent defines true size and orthogonal size (e.g. height for dock 'left') has to be defined.

Params:

NameTypeAttributeDescription
size]. Number | Function
  • optional

The size of the renderable in the one dimension that is being docked, e.g. dock left or right will be width, whereas dock top or bottom will result in height. For more information about different variations, see layout.size.

space Number
  • optional

= 0]. Any space that should be inserted before the docked renderable

zIndex Number
  • optional

= 0]. DEPRECATED: Use translate(0, 0, zIndex) instead.

Return:

Function

A decorator function

Example:

@layout.dock.top(30, 0, 10)
@layout.size(15, undefined)
@layout.origin(0.5, 0)
@layout.align(0.5, 0)
dockedRenderable = new Surface({properties: {backgroundColor: 'red'}});

public layout.dockPadding(firstMargin: Number, secondMargin: Number, thirdMargin: Number, fourthMargin: Number): Function source

Sets the margins for the docked content. This can be applied both to a child and a class. When in conflict, the parent will override the child's setting. If the margin is set on a Surface, then CSS padding will be set. margins can be 1, 2, or 4, parameters, which can be specified as shorthand in the same way as CSS does it.

Params:

NameTypeAttributeDescription
firstMargin Number
secondMargin Number
  • optional
thirdMargin Number
  • optional
fourthMargin Number
  • optional

Return:

Function

A decorator function

Example:

@layout.dockPadding(15)
//Creates a class with 15px margin on all sides for docked renderables
class myView extends View{

 //Will be displayed with margin
 @layout.dock.top(20)
 onTop = new Surface({content: "hello world"});

 //Will be displayed without margin since we're using @layout.stick
 @layout.stick.bottom
 onButtom = new Surface({content: "hey hey"});
}

public layout.dockSpace(space: Number): Function source

Specifies the space that should come before the docked renderable. Useful when not specifying the size in the layout.dock function. Note that the space does not appear if there isn't any renderable with a size greater than zero before it.

Params:

NameTypeAttributeDescription
space Number

The space that is inserted before the renderable.

Return:

Function

A decorator function

Example:

// there's a 20px space before this box
@layout.dockSpace(20)
@layout.size(100, 100)
@layout.dock.left()
box = new Surface({properties: {backgroundColor: 'red'}});

public layout.draggable(): Function source

Makes the renderable allowed to be dragged around. this.renderables[name] refers to a RenderNode containing this draggable along with the renderable itself.

Params:

NameTypeAttributeDescription
draggableOptions]. Object
  • optional

Same options that can be passed to a Famous Draggable.

options.snapX Number
  • optional

grid width for snapping during drag

options.snapY Number
  • optional

grid height for snapping during drag

options.xRange Array.Number
  • optional

maxmimum [negative, positive] x displacement from start of drag

options.yRange Array.Number
  • optional

maxmimum [negative, positive] y displacement from start of drag

options.scale Number
  • optional

one pixel of input motion translates to this many pixels of output drag motion

options.projection Number
  • optional

User should set to Draggable._direction.x or Draggable._direction.y to constrain to one axis.

Return:

Function

Example:

@layout.draggable({xRange: [0, 100}, yRange: [0, 200]})
@layout.size(100, 100)
// Makes a draggable square that is red
draggableRenderable = new Surface({properties: {backgroundColor: 'red'});

public layout.flow(Options: Object): Function source

Makes the view flow by tweening all intermediate stages of a changed attribute of any renderable.

Params:

NameTypeAttributeDescription
Options Object

to pass as flowOptions to the LayoutController

flowOptions.transition Bool
  • optional

If specified, sets the default transition to use

flowOptions.reflowOnResize Bool
  • optional

Smoothly reflows renderables on resize (only used when flow = true) (default: true).

flowOptions.spring Object
  • optional

Spring options used by nodes when reflowing (default: {dampingRatio: 0.8, period: 300}).

flowOptions.properties Object
  • optional

Properties which should be enabled or disabled for flowing.

flowOptions.insertSpec Spec
  • optional

Size, transform, opacity... to use when inserting new renderables into the scene (default: {}).

flowOptions.removeSpec Spec
  • optional

Size, transform, opacity... to use when removing renderables from the scene (default: undefined).

Return:

Function

A decorator function

Example:

@layout.flow({spring: {dampingRatio: 0.8, period: 1000}})
class myView extends View{
...
}

public layout.fullSize(): Function source

Marks the renderable to cover the entire screen. Translate can also be specified on such a renderable.

Return:

Function

A decorator function

Example:

@layout.fullSize()
// View will have a red background
background = new Surface({properties: {backgroundColor: 'red'}});

public layout.nativeScrollable(options: Object): Function source

Experimental feature of scrolling natively.

Params:

NameTypeAttributeDescription
options Object
  • optional

Options on how to scroll

options.scrollY Boolean
  • optional

Defaults to true

options.scrollX Boolean
  • optional

Defaults to false

Return:

Function

A decorator function

public layout.opacity(opacity: Number): Function source

Sets the opacity of a renderable.

Params:

NameTypeAttributeDescription
opacity Number

The opacity, between 0 and 1

Return:

Function

A decorator function

Example:

@layout.opacity(0.5)
@layout.size(100, 10)
@layout.place.center()
// Writes text that is half invisible
renderable = new Surface({content: 'Half invisible'});

public layout.origin(): Function source

Sets the point where the renderable has its anchor from where rotation and translation will be done. You could consider it as translating the negative of the proportion times its size. The arguments are always between and including 0 and 1.

Params:

NameTypeAttributeDescription
x. Number

The x of the origin.

y. Number

The y of the origin.

Return:

Function

A decorator function.

Example:

@layout.origin(0.5, 0)
@layout.align(0.5, 0.5)
@layout.size(100,100)
//Displays a red box horizontically centered and displays just below the vertical mid point
renderable = new Surface({properties: {backgroundColor: 'red'}});

public layout.renderable(): Function source

Merely marks a view property as a decorated renderable, which allows it to be rendered. Use this in combination with a @layout.custom decorator on the view in which this renderable resides.

Return:

Function

A decorator function

Example:

@layout.renderable
renderable = new Surface();

public layout.rotate(x: Number, y: Number, z: Number): Function source

Rotates the renderable around any of the three axes (in radians).

Params:

NameTypeAttributeDescription
x Number

The rotation around the x axis (flips vertically)

y Number

The rotation around the y axis (flips horizontally)

z Number

The rotation around the z axis (rotatesin in the more intuitive sense)

Return:

Function

A decorator function

Example:

@layout.size(100,100)
@layout.rotate(0, 0, Math.PI)
// Writes text upside down
renderable = new Surface({content: 'upside down text'});

public layout.rotateFrom(x: Number, y: Number, z: Number): Function source

Rotates the renderable around any of the three axes (in radians) relatively to the current rotation

Params:

NameTypeAttributeDescription
x Number

The rotation around the x axis (flips vertically)

y Number

The rotation around the y axis (flips horizontally)

z Number

The rotation around the z axis (rotatesin in the more intuitive sense)

Return:

Function

A decorator function

Example:

@layout.size(100,100)
@layout.rotate(0, 0, Math.PI)
// Writes text upside down
renderable = new Surface({content: 'upside down text'});

public layout.scale(x: Number, y: Number, z: Number): Function source

Specifies the scale of a renderable. Can be applied to every kind of renderable.

Params:

NameTypeAttributeDescription
x Number

Scales the renderable along the x axis.

y Number

Scales the renderable along the y axis.

z Number

Scales the renderable along the z axis.

Return:

Function

A decorator function.

Example:

 class myView extends View{
 @layout.scale(2, 2, 2)
 @layout.fullscreen
 // Will scale the renderable by 2 in the x,y,z dimension
 myBackground = new Surface({properties: {backgroudColor: 'red'}});
}

public layout.scrollable(options: {}): Function source

Makes the view as scrollable. This will put the entire content in a ReflowingScrollView that uses getSize on the view to determine scrolling size. If the size cannot be determined, you might consider declaring your own getSize() on the View.

Params:

NameTypeAttributeDescription
options {}
  • optional
  • default: {}

Return:

Function

A decorator function

Example:

@layout.scrollable()
class myView extends View{
...
}

public layout.size(x: Number | Function, y: Number | Function): Function source

Specifies the size of the renderable. For both of the parameters, sizes can be interpreted as follows:

If specified as a function, then the argument passed is the context size of the specified dimension (width or height). Note that if an arrow function is used, this scoping cannot be used when inside a decorator, since the scope will be the global scope.

If true is specified or a tilde with a size (e.g. ~300), then the renderable will be automatically sized. If a tilde is used to indicate the size, then the size after the tilde will be used when/if the renderable doesn't have a size, or turn into the actual size if it can be determined. This is useful when wanting to reduce the flickering of surfaces who's size cannot be determined the first render tick. Beware that true sizing of surfaces or other raw dom elements (input surfaces, image surfaces, text boxes etc) often comes with a perfomance penalty and should only be used when necessary. Also beware that any negative size will be interpreted as a tilde, since ~x = 1 - x

If undefined is specified, then the size of that dimension will equal the entire context size.

If a size between 0 and 1 is specified, then that will be interpreted as a proportion of the context size. For example if 0.5 is specified, then the size will be half of the context size (the parent's size). Instead of specifying 1 to cover the entire context size, use undefined instead.

Params:

NameTypeAttributeDescription
x Number | Function
y Number | Function

Return:

Function

A decorator function

Example:

@layout.size(function(contextWidth) {return Math.max(contextWidth, this.options.maxWidth)}, ~300)
// Creates a renderable where the width is equal to the text width and the height is whatever is bigger,
// options.maxWidth, or the context size
text = new Surface({content: 'This is some text', properties: {backgroundColor: 'red'}});

public layout.skew(x: Number, y: Number, z: Number): Function source

Specifies the skew of a renderable. Can be applied to every kind of renderable.

Params:

NameTypeAttributeDescription
x Number

Skews the renderable along the x axis.

y Number

Skews the renderable along the y axis.

z Number

Skews the renderable along the z axis.

Return:

Function

A decorator function.

Example:

 class myView extends View{
 @layout.skew(2, 2, 2)
 @layout.fullscreen
 // Will skew the renderable by 2 in the x,y,z dimension
 myBackground = new Surface({properties: {backgroudColor: 'red'}});
}

public layout.swipable(options: Object): Function source

Makes the renderable swipable with physics-like velocity after the dragging is released. Emits event 'thresholdReached' with arguments ('x'|'y', 0|1) when any thresholds have been reached. this.renderables[name] now refers to a a RenderNode containing a positionModifier along with the renderable itself.

Params:

NameTypeAttributeDescription
options Object
options.snapX Boolean
  • optional

Whether to snap to the x axis

options.snapY Boolean
  • optional

Whether to snap to the Y axis

options.enabled Boolean
  • optional

Whether the swipable should be initially enabled

options.xThreshold Array.Number
  • optional

Two values of the thresholds that trigger the thresholdReached event with argument 'x' and second argument 0 or 1, depending on the direction. Specify undefined in one of them to disable threshold to that direction.

options.yThreshold Array.Number
  • optional

Two values of the thresholds that trigger the thresholdReached event with argument 'y' and second argument 0 or 1, depending on the direction. Specify undefined in one of them to disable threshold to that direction.

Return:

Function

A decorator function

Example:

@layout.size(100, 100)
@layout.swipable({xRange: [0, 100], snapX: true})
//Make a red box that can slide to the right
swipable = new Surface({properties: {backgroundColor: 'red'});

public layout.translate(x: Number, y: Number, z: Number): Function source

Specifies a translation of a renderable. Can be applied to every kind of renderable (docked, fullSize, and normal). Can also be applied on view level to translate every renderable of that view. The view wide translation defaults to [0, 0, 10] in order to always increase the z space of every level of the Famous rendering tree.

Params:

NameTypeAttributeDescription
x Number

Moves the renderable along the x axis.

y Number

Moves the renderable along the y axis.

z Number

Moves the renderable along the z axis.

Return:

Function

A decorator function.

Example:

@layout.translate(0, 0, 20)
class myView extends View{
 @layout.translate(0, 0, -20)
 @layout.fullSize()
 // Will display relatively at z level 0 (20 minus 20)
 myBackground = new Surface({properties: {backgroudColor: 'red'}});
}

public layout.translateFrom(x: Number, y: Number, z: Number): Function source

Specifies a relative translation of a renderable. Can be applied to every kind of renderable (docked, fullSize, and normal). Can also be applied on view level to translate every renderable of that view. The view wide translation defaults to [0, 0, 10] in order to always increase the z space of every level of the Famous rendering tree.

Params:

NameTypeAttributeDescription
x Number

Moves the renderable along the x axis.

y Number

Moves the renderable along the y axis.

z Number

Moves the renderable along the z axis.

Return:

Function

A decorator function.

Example:

@layout.translateFrom(0, 0, 20)
class myView extends View{
 @layout.translateFrom(0, 0, -20)
 @layout.fullSize()
 // Will display relatively at z level 0 (20 minus 20)
 myBackground = new Surface({properties: {backgroudColor: 'red'}});
}

public limit(min: *, value: *, max: *): * source

import {limit} from 'arva-js/utils/Limiter.js'

@author: Tom Clement (tjclement)

Params:

NameTypeAttributeDescription
min *
value *
max *

Return:

*

public provide(tokens: ...*): * source

import {provide} from 'arva-js/utils/di/Decorators.js'

Params:

NameTypeAttributeDescription
tokens ...*

Return:

*

public readAnnotations(fn: *): * source

import {readAnnotations} from 'arva-js/utils/di/Decorators.js'

Params:

NameTypeAttributeDescription
fn *

Return:

*

public successAndErrorToPromise(): * source

import {successAndErrorToPromise} from 'arva-js/utils/CallbackHelpers.js'

Return:

*

public toString(token: *): * source

import {toString} from 'arva-js/utils/di/util.js'

Params:

NameTypeAttributeDescription
token *

Return:

*

public waitMilliseconds(milliseconds: *): * source

import {waitMilliseconds} from 'arva-js/utils/CallbackHelpers.js'

Params:

NameTypeAttributeDescription
milliseconds *

Return:

*