Show:

The base class for Image Viewer.

Constructor

A.ImageViewerBase

(
  • config
)

Parameters:

  • config Object

    Object literal specifying widget configuration properties.

Methods

_afterCurrentIndexChange

(
  • event
)
protected

Fired after the currentIndex attribute is set.

Parameters:

_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:

Object:

<p>An object with the original dimensions</p>

_canChangeHeight

() Boolean

Checks if the height can be manually changed.

Returns:

Boolean:

_canChangeWidth

() Boolean

Checks if the width can be manually changed.

Returns:

Boolean:

_defAnimateFn

() protected

Default behavior for animating the current image in the viewer.

_defResponsiveFn

(
  • event
)
protected

Default behavior for the responsive event. It updates the dimensions of the widget so it will respect the preserveRatio, maxHeight and maxWidth attributes.

Parameters:

_getCurrentImage

() Node protected

Gets the current image node.

Returns:

Node:

_getCurrentImageContainer

() protected

Returns the container node for the current image.

_getImageContainerAtIndex

(
  • index
)
protected

Returns the container node at the requested index.

Parameters:

_handleResponsive

() protected

Fires the responsive event.

_loadImage

(
  • index
)
protected

Fires the necessary events to load the requested image.

Parameters:

  • index Number

    <p>The index of the image to load.</p>

_onClickControl

(
  • event
)
protected

Fired when one of the viewer's controls is clicked.

Parameters:

_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
)
protected

Renders the requested image and registers it to be loaded when used.

Parameters:

  • index Number

    <p>The index of the image to be loaded.</p>

  • container Node

    <p>The container where the image should be added.</p>

_renderImageContainers

() Array protected

Renders all image containers and returns them in an array.

Returns:

Array:

<p>list of image containers</p>

_renderImageListNode

() Node protected

Renders the image list node inside the image viewer.

Returns:

Node:

<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.

_setCurrentIndex

(
  • val
)
protected

Sets currentIndex attribute.

Parameters:

_setImageAnim

(
  • val
)
protected

Sets imageAnim attribute.

Parameters:

  • val Object

_showCurrentImage

() protected

Shows the current image in the viewer.

_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:

Boolean:

hasPrev

() Boolean

Checks if there is a previous element to navigate.

Returns:

Boolean:

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

circular

Boolean

If the image list will be circular or not.

Default: false

controlNext

Node

The node for the control that shows the next image.

Default: null

controlPrevious

Node

The node for the control that shows the previous image.

Default: null

currentIndex

Number | String

Index of the current image.

Default: 0

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.

maxHeight

Number

The maximum height of the widget.

Default: Infinity

maxWidth

Number

The maximum width of the widget.

Default: Infinity

preloadAllImages

Boolean

Preloads the neighbor image (i.e., the previous and next image based on the current load one).

Default: false

preloadAllImages

Boolean

Preloads all images listed in the sources attribute.

Default: false

preserveRatio

Boolean

Flag to indicate if the width/height ratio should be preserved.

Default: true

showControls

Boolean

Shows the controls.

Default: true

sources

Array

The source links for the images to be shown.

Default: []

Events

animate

Fired when the current image will be animated in.

responsive

Fired when the widget will be updated to be responsive.