Class: Deck

Deck

new Deck(options)

Creates the Deck object, which is the top-level API for managing the decks system. Contains all of the coordinating objects for managing items, collections of items, viewports, layouts, etc.
Parameters:
Name Type Description
options Object Deck options
Properties
Name Type Argument Default Description
config Object <optional>
<nullable>
{} Deck configuration settings
Properties
Name Type Argument Default Description
debugEvents boolean <optional>
<nullable>
false Whether to log events to the console
debugDrawing boolean <optional>
<nullable>
false Whether to log drawing actions to the console
debugGestures boolean <optional>
<nullable>
false Whether to log gesture info to the console
emitter Object | Emitter <optional>
<nullable>
{} Emitter instance or options
animator Object Object with animate function (like VelocityJS)
itemCollection Object | ItemCollection <optional>
<nullable>
[] ItemCollection instance or options
layout Object | Layout Layout instance or options
frame Object | Frame Frame instance or options
canvas Object | Canvas <optional>
<nullable>
{} Canvas instance or options
viewport Object | Viewport <optional>
<nullable>
{} Viewport instance or options
Source:

Mixes In

Members

defaultOptions

Default global Deck options.
Source:

Methods

addItem(item, options) → {undefined}

Adds an Item to the ItemCollection
Parameters:
Name Type Description
item
options
Source:
Returns:
Type
undefined

addItems(items, options) → {undefined}

Adds Items to the ItemCollection
Parameters:
Name Type Description
items
options
Source:
Returns:
Type
undefined

bind() → {undefined}

Binds the Emitter and ItemCollection event handlers.
Source:
Returns:
Type
undefined

bindGestures() → {undefined}

Source:
Returns:
Type
undefined

bindLayout() → {undefined}

Binds the Layout Emitter events.
Source:
Returns:
Type
undefined

clear(options) → {undefined}

Clears all Items from the ItemCollection
Parameters:
Name Type Description
options
Source:
Returns:
Type
undefined

destroy() → {undefined}

Destroys the Deck and all sub-components. The Deck is no longer usable after calling this.
Source:
Returns:
Type
undefined

disableDrawing() → {undefined}

Disables drawing (re-enable by calling Viewport#enableDrawing
Source:
Returns:
Type
undefined

draw() → {undefined}

Requests a manual redraw and reload cycle on all the items. This is normally not needed, as decks will attempt to always redraw and reload whenever necessary, but can be used to force a redraw/reload to happen.
Source:
Returns:
Type
undefined

enableDrawing() → {undefined}

Enables drawing (if it had previously been disabled with Viewport#disableDrawing
Source:
Returns:
Type
undefined

getEmitterEvents()

Events to bind to on the shared Emitter.
Source:

getItem(id) → {undefined}

Gets an Item by Item id
Parameters:
Name Type Description
id
Source:
Returns:
Type
undefined

getItemCollectionEvents()

Events to bind to on the ItemCollection
Source:

getItems(filter) → {undefined}

Gets Items from the ItemCollection
Parameters:
Name Type Argument Default Description
filter function <optional>
<nullable>
undefined optional filter function which takes an Item
Source:
Returns:
Type
undefined

onAnyEmitterEvent(e) → {undefined}

Called on any Emitter event.
Parameters:
Name Type Description
e
Source:
Returns:
Type
undefined

onAnyItemCollectionEvent(e) → {undefined}

Called on any ItemCollection event.
Parameters:
Name Type Description
e
Source:
Returns:
Type
undefined

panToItem(itemOrItemId, renderIdOrIndex) → {undefined}

Pans the Canvas to the given Item, with an optional render id (defaults to the first render element).
Parameters:
Name Type Argument Default Description
itemOrItemId Item | string the item or item id to pan to
renderIdOrIndex string | number <optional>
<nullable>
0 the render id or index of the element to pan to * (defaults to the first render element for the item)
Source:
Returns:
Type
undefined

removeItem(item, options) → {undefined}

Removes an Item from the ItemCollection.
Parameters:
Name Type Description
item
options
Source:
Returns:
Type
undefined

resize() → {undefined}

Requests that the Frame re-calculate it's bounds. If the bounds have changed, it will trigger a redraw, which allows the Viewport to request new renders from the Layout which might result in renders moving to fit in the new Frame size.
Source:
Returns:
Type
undefined

setAnimator(animator) → {undefined}

Sets the animator object.
Parameters:
Name Type Description
animator
Source:
Returns:
Type
undefined

setCanvas(canvas) → {undefined}

Sets the Canvas
Parameters:
Name Type Description
canvas
Source:
Returns:
Type
undefined

setConfig(config) → {undefined}

Sets the config object.
Parameters:
Name Type Description
config
Source:
Returns:
Type
undefined

setFilter(filter) → {undefined}

Sets a filter function on the ItemCollection. Items that do not pass the filter function will have their Item index set to -1, which may cause the renders for the Item to be hidden on the next draw cycle.
Parameters:
Name Type Description
filter
Source:
Returns:
Type
undefined

setFrame(frame) → {undefined}

Sets the Frame
Parameters:
Name Type Description
frame
Source:
Returns:
Type
undefined

setItemCollection(itemCollection) → {undefined}

Sets the ItemCollection.
Parameters:
Name Type Description
itemCollection
Source:
Returns:
Type
undefined

setLayout(layout) → {undefined}

Sets the Layout
Parameters:
Name Type Description
layout
Source:
Returns:
Type
undefined

setLayoutAndPanToItem(layout, itemOrItemId, renderIdOrIndex) → {undefined}

Sets a new Layout, and pans to the given Item when the new layout draw cycle completes.
Parameters:
Name Type Argument Default Description
layout Layout new layout to set
itemOrItemId Item | string item or item id
renderIdOrIndex string | number <optional>
<nullable>
0 render id or index (defaults to the first render for the Item)
Source:
Returns:
Type
undefined

setReversed(isReversed) → {undefined}

Sets a reversed flag on the ItemCollection which reverses all the indices of the Items. This triggers a redraw if any Item indices change.
Parameters:
Name Type Description
isReversed
Source:
Returns:
Type
undefined

setSortBy(sortBy) → {undefined}

Sets a sort by function on the ItemCollection. The sort by function will be run over the ItemCollection and may cause the indices to change on zero or more Items. This triggers a redraw for any Item whose index changes.
Parameters:
Name Type Description
sortBy
Source:
Returns:
Type
undefined

setViewport(viewport) → {undefined}

Sets the Viewport
Parameters:
Name Type Description
viewport
Source:
Returns:
Type
undefined

unbind() → {undefined}

Unbinds the Emitter and ItemCollection event handlers.
Source:
Returns:
Type
undefined

unbindGestures() → {undefined}

Source:
Returns:
Type
undefined

unbindLayout() → {undefined}

Unbinds the Layout Emitter events.
Source:
Returns:
Type
undefined