A.ImageViewerBase Class
The base class for Image Viewer.
Constructor
A.ImageViewerBase
-
config
Parameters:
-
config
ObjectObject literal specifying widget configuration properties.
Index
Methods
- _afterCurrentIndexChange
- _afterPreloadAllImagesChange
- _afterResponsive
- _afterShowControlsChange
- _afterSourcesChange
- _afterUISetVisible
- _bindControls
- _calculateOriginalDimensions
- _canChangeHeight
- _canChangeWidth
- _defAnimateFn
- _defResponsiveFn
- _getCurrentImage
- _getCurrentImageContainer
- _getImageContainer
- _getImageContainerAtIndex
- _handleResponsive
- _loadImage
- _onClickControl
- _onCurrentImageReady
- _onImageLoad
- _onResponsive
- _preloadAll
- _renderControls
- _renderImage
- _renderImageContainers
- _renderImageListNode
- _renderImages
- _renderImagesForFirstTime
- _setCurrentIndex
- _setImageAnim
- _showCurrentImage
- _syncAriaCurrentImageUI
- _syncAriaCurrentImageUI
- _syncControlsUI
- _updateCurrentImageCSS
- bindUI
- destructor
- hasNext
- hasPrev
- initializer
- next
- prev
- renderUI
- updateDimensions
- updateDimensionsWithNewRatio
Properties
- ATTRS static
- CSS_PREFIX static
- HTML_PARSER static
Attributes
Events
Methods
_afterCurrentIndexChange
-
event
Fired after the currentIndex
attribute is set.
Parameters:
-
event
EventFacade
_afterPreloadAllImagesChange
()
protected
Fired after the preloadAllImages
attribute is changed.
_afterResponsive
()
protected
Fired after the responsive
event.
_afterShowControlsChange
()
protected
Fired after the showControls
attribute is changed.
_afterSourcesChange
()
protected
Fired after the sources
attribute is changed.
_afterUISetVisible
()
protected
Fired after the visible
attribute is set.
_bindControls
()
protected
Binds the events related to the viewer's controls.
_calculateOriginalDimensions
()
Object
protected
Calculates the original width and height of the widget, which will be used when changing its dimensions to preserve its ratio.
Returns:
<p>An object with the original dimensions</p>
_canChangeHeight
()
Boolean
Checks if the height can be manually changed.
Returns:
_canChangeWidth
()
Boolean
Checks if the width can be manually changed.
Returns:
_defAnimateFn
()
protected
Default behavior for animating the current image in the viewer.
_defResponsiveFn
-
event
Default behavior for the responsive
event. It updates the dimensions of
the widget so it will respect the preserveRatio
, maxHeight
and maxWidth
attributes.
Parameters:
-
event
EventFacade
_getCurrentImageContainer
()
protected
Returns the container node for the current image.
_getImageContainer
()
protected
Returns the image container node.
_getImageContainerAtIndex
-
index
Returns the container node at the requested index.
Parameters:
-
index
Number
_handleResponsive
()
protected
Fires the responsive
event.
_loadImage
-
index
Fires the necessary events to load the requested image.
Parameters:
-
index
Number<p>The index of the image to load.</p>
_onClickControl
-
event
Fired when one of the viewer's controls is clicked.
Parameters:
-
event
EventFacade
_onCurrentImageReady
()
protected
This should be called when the current image is ready to be displayed.
_onImageLoad
()
protected
Fired when an image has finished loading.
_onResponsive
()
protected
Fired on the responsive
event.
_preloadAll
()
protected
Preloads all the images if the preloadAllImages
attribute is true.
_renderControls
()
protected
Renders the viewer's controls.
_renderImage
-
index
-
container
Renders the requested image and registers it to be loaded when used.
_renderImageContainers
()
Array
protected
Renders all image containers and returns them in an array.
Returns:
<p>list of image containers</p>
_renderImageListNode
()
Node
protected
Renders the image list node inside the image viewer.
Returns:
<p>the image list node</p>
_renderImages
()
protected
Renders the images indicated in the sources
attribute.
_renderImagesForFirstTime
()
protected
Renders the images indicated in the sources
attribute for
the first time. If the images were already present before the widget
is rendered, we'll mark these images as having already been loaded.
_setImageAnim
-
val
Sets imageAnim
attribute.
Parameters:
-
val
Object
_showCurrentImage
()
protected
Shows the current image in the viewer.
_syncAriaCurrentImageUI
()
protected
Update the aria attributes for image.
_syncAriaCurrentImageUI
-
container
Update the aria attributes for image container.
Parameters:
-
container
Node<p>The container for the images</p>
_syncControlsUI
()
protected
Updates the controls, showing or hiding them as necessary.
_updateCurrentImageCSS
()
protected
Sets the CSS class that indicates the current image.
bindUI
()
protected
Bind the events for the A.ImageViewerBase
UI. Lifecycle.
destructor
()
protected
Destructor implementation for the A.ImageViewerBase
class. Lifecycle.
hasNext
()
Boolean
Checks if there is a next element to navigate.
Returns:
hasPrev
()
Boolean
Checks if there is a previous element to navigate.
Returns:
initializer
()
protected
Constructor for the A.ImageViewerBase
. Lifecycle.
next
()
Loads the next image.
prev
()
Loads the previous image.
renderUI
()
protected
Create the DOM structure for the A.ImageViewerBase
. Lifecycle.
updateDimensions
()
Updates the widget's dimensions so that it will fit the page better.
updateDimensionsWithNewRatio
()
Updates the widget's dimensions like the updateDimensions
method, but
also recalculates the ratio to be preserved. Useful if the visible content
of the widget has changed causing the ratio to change as well.
Properties
ATTRS
Object
static
Static property used to define the default attribute configuration
for the A.ImageViewerBase
.
CSS_PREFIX
String
static
Static property provides a string to identify the CSS prefix.
HTML_PARSER
Object
static
Object hash, defining how attribute values are to be parsed from markup contained in the widget's content box.
Attributes
gutter
Array
Vertical and horizontal values in pixels that should not be counted when preserving the widget's ratio. widget.
Default: [0, 0]
imageAnim
Boolean | Object
Configuration attributes passed to the Anim class, or false if there should be no animation.
Default: Predefined [Anim](Anim.html) configuration.
Events
animate
Fired when the current image will be animated in.
responsive
Fired when the widget will be updated to be responsive.