new Canvas(options)
Canvas - manages the main DOM element in which items are rendered, and where
UI/touch/gesture events are first handled.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | additional options |
Mixes In
Members
-
defaultGestureHandlerOptions
-
Default options for the canvas GestureHandler
-
defaultOptions
-
Default Canvas constructor options
Methods
-
addRender(render) → {undefined}
-
Adds a render (element) to the canvas, if not already added
Parameters:
Name Type Description render
Object render to remove Returns:
- Type
- undefined
-
bind() → {undefined}
-
Binds Canvas event handlers.
Returns:
- Type
- undefined
-
bindGestures() → {undefined}
-
Binds the GestureHandler managed by the Canvas
Returns:
- Type
- undefined
-
configureGestures() → {undefined}
-
Configures the Canvas GestureHandler options. This is used to configure how the user can interact with the canvas through touch gestures, or natural scrolling, and other Hammer.js or DOM events. The Canvas specifies default options, which can be overridden via Layout#getCanvasGestureOptions per Layout.
Returns:
- Type
- undefined
-
destroy() → {undefined}
-
Destroys the Canvas
Returns:
- Type
- undefined
-
getEmitterEvents()
-
Events to bind to on the main emitter
-
getRenderElements() → {HTMLElement[]}
-
Gets the .decks-item elements inside the canvas as plain array.
Returns:
- Type
- HTMLElement[]
-
getRenderElementsBounds() → {Object}
-
Gets a rect that is the union of all the bounding client rects for all render elements.
Returns:
- the union of all element rects, or null if there are no elements.- Type
- Object
-
getWindowEvents()
-
Events to bind to on the window
-
panToElement(element) → {undefined}
-
Moves the Canvas to bring the specified element into view. This is handled by GestureHandler#animateMoveToElement
Parameters:
Name Type Description element
Returns:
- Type
- undefined
-
removeRender(render) → {undefined}
-
Removes a render (element) from the Canvas, if present.
Parameters:
Name Type Description render
Object render to remove Returns:
- Type
- undefined
-
resetPosition() → {undefined}
-
Resets the postiion of the Canvas (top/left or scrollTop/scrollLeft) to the default position (0, 0). This is handled by GestureHandler#resetPosition
Returns:
- Type
- undefined
-
resizeToFitAllElements() → {undefined}
-
Resizes the canvas to fit all of the .decks-item elements currently in the Canvas.
Returns:
- Type
- undefined
-
resizeToFitElement(element) → {undefined}
-
Resizes the Canvas to fit the specified Element.
Parameters:
Name Type Description element
Returns:
- Type
- undefined
-
setAnimator(animator) → {undefined}
-
Sets the animator instance
Parameters:
Name Type Description animator
Returns:
- Type
- undefined
-
setBounds(bounds) → {undefined}
-
Sets the bounds of the Canvas (width and height). This uses the Layout#getCanvasBoundsOptions to apply some post-processing to the bounds. E.g. if the Layout wants extra padding at the right or bottom, or wants to prevent overflow (so the Canvas doesn't create vertical or horizontal scrollbars on the Frame).
Parameters:
Name Type Description bounds
Returns:
- Type
- undefined
-
setConfig(config) → {undefined}
-
Sets the config object
Parameters:
Name Type Description config
Returns:
- Type
- undefined
-
setElement(element, options) → {undefined}
-
Sets the main container element, where items are rendered. Creates a div if no element is provided
Parameters:
Name Type Argument Description element
HTMLElement <nullable>
element for the container options
Object <nullable>
additional options Returns:
- Type
- undefined
-
setFrame(frame) → {undefined}
-
Sets the Frame instance on the Canvas
Parameters:
Name Type Description frame
Returns:
- Type
- undefined
-
setFrameBounds(frameBounds) → {undefined}
-
Sets the Frame bounds
Parameters:
Name Type Description frameBounds
Returns:
- Type
- undefined
-
setLayout(layout) → {undefined}
-
Sets the Layout instance, and reconfigures the Canvas based on Layout options
Parameters:
Name Type Description layout
Returns:
- Type
- undefined
-
unbind() → {undefined}
-
Unbinds Canvas event handlers.
Returns:
- Type
- undefined
-
unbindGestures() → {undefined}
-
Unbinds the GestureHandler managed by the Canvas
Returns:
- Type
- undefined