Class YAHOO.extension.Carousel
The carousel class manages a content list (a set of LI elements within an UL list) that can be displayed horizontally or vertically. The content can be scrolled back and forth with or without animation. The content can reference static HTML content or the list items can be created dynamically on-the-fly (with or without Ajax). The navigation and event handling can be externalized from the class.
Defined in: carousel.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
YAHOO.extension.Carousel(carouselElementID, carouselCfg)
|
| Field Attributes | Field Name and Description |
|---|---|
|
For deprecation.
|
|
|
Constant denoting that the carousel size is unbounded (no limits set on scrolling)
|
| Method Attributes | Method Name and Description |
|---|---|
|
_areAllItemsLoaded(first, last)
|
|
|
_calculateSize(me)
|
|
|
_calculateVisibleExtent(start, end)
|
|
|
_createItem(idx, innerHTMLOrElem)
|
|
|
_getStyleVal(li, style, returnFloat)
|
|
|
_handleAnimationComplete(type, args, argList)
|
|
|
_insertAfterItem(refIdx, innerHTMLOrElem)
|
|
|
_insertBeforeItem(refIdx, innerHTMLOrElem)
|
|
|
_isValidObj(obj)
|
|
|
_loadInitial looks at firstItemVisible for the start (not necessarily 1)
|
|
|
_position(newStart, showAnimation)
|
|
|
_prebuildItems(first, last)
|
|
|
_prebuildLiElem(idx)
|
|
|
_removeChildrenFromNode(node)
|
|
|
_scrollNext(e, carousel)
|
|
|
_scrollNextInc(inc, showAnimation)
|
|
|
_scrollPrev(e, carousel)
|
|
|
_scrollPrevInc(dec, showAnimation)
|
|
|
addItem(idx, innerHTML, itemClass)
With patch from Dan Hobbs for handling unordered loading.
|
|
|
clear()
Clears all items from the list and resets to the carousel to its original initial state.
|
|
|
getItem(idx)
Lookup the element object for a carousel list item by index.
|
|
|
getProperty(property)
|
|
|
hide()
|
|
|
init(carouselElementID, carouselCfg)
Initializes the carousel object and all of its local members.
|
|
|
insertAfter(refIdx, innerHTML)
Inserts a new LI item after the index specified.
|
|
|
insertAfterEnd(innerHTMLOrElem)
|
|
|
insertBefore(refIdx, innerHTML)
Inserts a new LI item before the index specified.
|
|
|
isItemLoaded(idx)
Check to see if an element (by index) has been loaded or not.
|
|
|
Returns whether the carousel's orientation is set to vertical.
|
|
|
load()
|
|
|
moveTo(newStart)
Moves the content to place itemNum as the start item in the view
(if size is specified, the last element will not scroll past the end.
|
|
|
reload(numVisible)
Clears all items from the list and calls the loadInitHandler to load new items into the list.
|
|
|
Simulates a next button event.
|
|
|
Simulates a prev button event.
|
|
|
scrollTo(newStart)
Scrolls the content to place itemNum as the start item in the view
(if size is specified, the last element will not scroll past the end.
|
|
|
setProperty(property, value, silent)
|
|
|
show()
|
|
|
startAutoPlay(interval)
Starts up autoplay.
|
|
|
Stops autoplay.
|
Class Detail
YAHOO.extension.Carousel(carouselElementID, carouselCfg)
- Parameters:
- {object|string} carouselElementID
- The element ID (id name or id object) of the DIV that will become a carousel
- {object} carouselCfg
- The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
Field Detail
getCarouselItem
For deprecation.
getItem is the replacement for getCarouselItem
{number}
UNBOUNDED_SIZE
Constant denoting that the carousel size is unbounded (no limits set on scrolling)
Method Detail
_areAllItemsLoaded(first, last)
Defined in: carousel_min.js.
- Parameters:
- first
- last
_calculateAllowableScrollExtent()
Defined in: carousel_min.js.
_calculateSize(me)
Defined in: carousel_min.js.
- Parameters:
- me
_calculateVisibleExtent(start, end)
Defined in: carousel_min.js.
- Parameters:
- start
- end
_createItem(idx, innerHTMLOrElem)
Defined in: carousel_min.js.
- Parameters:
- idx
- innerHTMLOrElem
_disableNext()
Defined in: carousel_min.js.
_disablePrev()
Defined in: carousel_min.js.
_enableDisableControls()
Defined in: carousel_min.js.
_enableNext()
Defined in: carousel_min.js.
_enablePrev()
Defined in: carousel_min.js.
_getStyleVal(li, style, returnFloat)
Defined in: carousel_min.js.
- Parameters:
- li
- style
- returnFloat
_handleAnimationComplete(type, args, argList)
Defined in: carousel_min.js.
- Parameters:
- type
- args
- argList
_insertAfterItem(refIdx, innerHTMLOrElem)
Defined in: carousel_min.js.
- Parameters:
- refIdx
- innerHTMLOrElem
_insertBeforeItem(refIdx, innerHTMLOrElem)
Defined in: carousel_min.js.
- Parameters:
- refIdx
- innerHTMLOrElem
_isExtraRevealed()
Defined in: carousel_min.js.
_isValidObj(obj)
Defined in: carousel_min.js.
- Parameters:
- obj
_loadInitial()
_loadInitial looks at firstItemVisible for the start (not necessarily 1)
_position(newStart, showAnimation)
Defined in: carousel_min.js.
- Parameters:
- newStart
- showAnimation
_prebuildItems(first, last)
Defined in: carousel_min.js.
- Parameters:
- first
- last
_prebuildLiElem(idx)
Defined in: carousel_min.js.
- Parameters:
- idx
_removeChildrenFromNode(node)
Defined in: carousel_min.js.
- Parameters:
- node
_scrollNext(e, carousel)
Defined in: carousel_min.js.
- Parameters:
- e
- carousel
_scrollNextInc(inc, showAnimation)
Defined in: carousel_min.js.
- Parameters:
- inc
- showAnimation
_scrollPrev(e, carousel)
Defined in: carousel_min.js.
- Parameters:
- e
- carousel
_scrollPrevInc(dec, showAnimation)
Defined in: carousel_min.js.
- Parameters:
- dec
- showAnimation
addItem(idx, innerHTML, itemClass)
With patch from Dan Hobbs for handling unordered loading.
- Parameters:
- {number} idx
- which item in the list to potentially create. If item already exists it will not create a new item.
- {string} innerHTML
- The innerHTML string to use to create the contents of an LI element.
- {string} itemClass
- A class optionally supplied to add to the LI item created
calculateSize()
Defined in: carousel_min.js.
clear()
Clears all items from the list and resets to the carousel to its original initial state.
getFirstItemRevealed()
Defined in: carousel_min.js.
getFirstVisible()
Defined in: carousel_min.js.
getItem(idx)
Lookup the element object for a carousel list item by index.
- Parameters:
- {number} idx
- Index of the element to lookup.
getLastItemRevealed()
Defined in: carousel_min.js.
getLastVisible()
Defined in: carousel_min.js.
getProperty(property)
Defined in: carousel_min.js.
- Parameters:
- property
hide()
Defined in: carousel_min.js.
init(carouselElementID, carouselCfg)
Initializes the carousel object and all of its local members.
- Parameters:
- {object|string} carouselElementID
- The element ID (id name or id object) of the DIV that will become a carousel
- {object} carouselCfg
- The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
insertAfter(refIdx, innerHTML)
Inserts a new LI item after the index specified. Uses the innerHTML to create the contents of the new LI item
- Parameters:
- {number} refIdx
- which item in the list to insert this item after.
- {string} innerHTML
- The innerHTML string to use to create the contents of an LI element.
insertAfterEnd(innerHTMLOrElem)
Defined in: carousel_min.js.
- Parameters:
- innerHTMLOrElem
insertBefore(refIdx, innerHTML)
Inserts a new LI item before the index specified. Uses the innerHTML to create the contents of the new LI item
- Parameters:
- {number} refIdx
- which item in the list to insert this item before.
- {string} innerHTML
- The innerHTML string to use to create the contents of an LI element.
isItemLoaded(idx)
Check to see if an element (by index) has been loaded or not. If the item is simply pre-built, but not
loaded this will return false. If the item has not been pre-built it will also return false.
- Parameters:
- {number} idx
- Index of the element to check load status for.
isVertical()
Returns whether the carousel's orientation is set to vertical.
load()
Defined in: carousel_min.js.
moveTo(newStart)
Moves the content to place itemNum as the start item in the view
(if size is specified, the last element will not scroll past the end.)
Ignores animation speed & method; moves directly to the item.
Note that you can also set the firstVisible property upon initialization
to get the carousel to start at a position different than 1.
- Parameters:
- {number} newStart
- The item to move directly to.
reload(numVisible)
Clears all items from the list and calls the loadInitHandler to load new items into the list.
The carousel size is reset to the original size set during creation.
- Parameters:
- {number} numVisible
- Optional parameter: numVisible. If set, the carousel will resize on the reload to show numVisible items.
scrollNext()
Simulates a next button event. Causes the carousel to scroll the next set of content into view.
scrollPrev()
Simulates a prev button event. Causes the carousel to scroll the previous set of content into view.
scrollTo(newStart)
Scrolls the content to place itemNum as the start item in the view
(if size is specified, the last element will not scroll past the end.).
Uses current animation speed & method.
- Parameters:
- {number} newStart
- The item to scroll to.
setProperty(property, value, silent)
Defined in: carousel_min.js.
- Parameters:
- property
- value
- silent
show()
Defined in: carousel_min.js.
startAutoPlay(interval)
Starts up autoplay. If autoPlay has been stopped (by calling stopAutoPlay or by user interaction),
you can start it back up by using this method.
- Parameters:
- {number} interval
- optional parameter that sets the interval for auto play the next time that autoplay fires.
stopAutoPlay()
Stops autoplay. Useful for when you want to control what events will stop the autoplay feature.
Call startAutoPlay() to restart autoplay.