Interface ICarousel

All Superinterfaces:
IAnyGroup<ICarousel>, IChildable<ICarousel,ICarouselitem<IAnyGroup>>, IComponent<ICarousel>, IHtmlBasedComponent<ICarousel>, IXulElement<ICarousel>

Immutable Carousel component.

A carousel (slideshow) container. Children must be ICarouselitem.

Support @Action

Name Action Type
onSelect ActionData: RequestData
Denotes the user moved to another slide; the zero-based index of the new slide can be received from RequestData.getData() with the key "index".
onChanging ActionData: RequestData
Denotes a slide change is starting; RequestData.getData() carries the keys "fromIndex" and "toIndex". Not cancelable.
Since:
11.0.0
Author:
peaker
See Also:
  • Carousel
  • Field Details

    • DEFAULT

      static final ICarousel DEFAULT
      Constant for default attributes of this immutable component.
  • Method Details

    • getWidgetClass

      default String getWidgetClass()
      Returns the client widget class.

      Default: "zul.wgt.Carousel"

      Specified by:
      getWidgetClass in interface IComponent<ICarousel>
    • getActiveIndex

      default int getActiveIndex()
      Returns the index of the currently active slide.

      Unlike Carousel.getActiveIndex(), the stored value is returned as given; the clamp to slideCount - 1 happens at render time only.

      Default: 0.

    • withActiveIndex

      ICarousel withActiveIndex(int activeIndex)
      Returns a copy of this immutable component with the specified activeIndex.

      Sets the index of the currently active slide.

      Note: UiAgent.smartUpdate(Locator, SmartUpdater) is not supported for this property — ICarousel.Updater ships the raw attribute while the initial render ships the value clamped to slideCount - 1. Push a whole component with UiAgent.replaceWith(Locator, IComponent) instead.

      Parameters:
      activeIndex - the zero-based index of the slide to activate. An index past the last slide is clamped to slideCount - 1 when rendered.

      Default: 0.

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if activeIndex is negative.
    • isAutoplay

      default boolean isAutoplay()
      Returns whether the carousel advances through its slides automatically.

      Default: false.

    • withAutoplay

      ICarousel withAutoplay(boolean autoplay)
      Returns a copy of this immutable component with the specified autoplay.

      Sets whether the carousel advances through its slides automatically.

      Parameters:
      autoplay - true to start advancing slides automatically (using the interval), false to leave navigation manual.

      Default: false.

      Returns:
      A modified copy of the this object
    • getInterval

      default int getInterval()
      Returns the autoplay interval in milliseconds.

      Default: 5000.

    • withInterval

      ICarousel withInterval(int interval)
      Returns a copy of this immutable component with the specified interval.

      Sets the autoplay interval in milliseconds.

      Parameters:
      interval - the autoplay interval in milliseconds; must be at least 500.

      Default: 5000.

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if interval is less than 500ms.
    • isShowArrows

      default boolean isShowArrows()
      Returns whether the previous/next navigation arrows are shown.

      Default: true.

    • withShowArrows

      ICarousel withShowArrows(boolean showArrows)
      Returns a copy of this immutable component with the specified showArrows.

      Sets whether the previous/next navigation arrows are shown.

      Parameters:
      showArrows - true to display the navigation arrows, false to hide them.

      Default: true.

      Returns:
      A modified copy of the this object
    • isShowIndicators

      default boolean isShowIndicators()
      Returns whether the slide indicators (the position dots) are shown.

      Default: true.

    • withShowIndicators

      ICarousel withShowIndicators(boolean showIndicators)
      Returns a copy of this immutable component with the specified showIndicators.

      Sets whether the slide indicators (the position dots) are shown.

      Parameters:
      showIndicators - true to display the indicators, false to hide them.

      Default: true.

      Returns:
      A modified copy of the this object
    • isLoop

      default boolean isLoop()
      Returns whether the carousel wraps around from the last slide back to the first (and vice versa).

      Default: true.

    • withLoop

      ICarousel withLoop(boolean loop)
      Returns a copy of this immutable component with the specified loop.

      Sets whether the carousel wraps around from the last slide back to the first (and vice versa).

      Parameters:
      loop - true to wrap around continuously, false to stop at the ends.

      Default: true.

      Returns:
      A modified copy of the this object
    • isPause

      default boolean isPause()
      Returns whether autoplay pauses while the cursor hovers over the carousel.

      Default: true.

    • withPause

      ICarousel withPause(boolean pause)
      Returns a copy of this immutable component with the specified pause.

      Sets whether autoplay pauses while the cursor hovers over the carousel.

      Parameters:
      pause - true to pause autoplay on hover, false to keep advancing.

      Default: true.

      Returns:
      A modified copy of the this object
    • isKeyboard

      default boolean isKeyboard()
      Returns whether the carousel reacts to left/right arrow keys when focused.

      Default: true.

    • withKeyboard

      ICarousel withKeyboard(boolean keyboard)
      Returns a copy of this immutable component with the specified keyboard.

      Sets whether the carousel reacts to left/right arrow keys when focused.

      Parameters:
      keyboard - true to enable arrow-key navigation, false to disable it.

      Default: true.

      Returns:
      A modified copy of the this object
    • getOrient

      @Nullable default String getOrient()
      Returns the orientation along which the slides advance, or null when it was reset to the default.

      Default: "horizontal".

    • withOrient

      ICarousel withOrient(@Nullable String orient)
      Returns a copy of this immutable component with the specified orient.

      Sets the orientation along which the slides advance.

      Parameters:
      orient - either "horizontal" or "vertical".

      Default: "horizontal".

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if orient is neither "horizontal" nor "vertical".
    • getEffect

      @Nullable default String getEffect()
      Returns the transition effect used when moving between slides, or null when it was reset to the default.

      Default: "slide".

    • withEffect

      ICarousel withEffect(@Nullable String effect)
      Returns a copy of this immutable component with the specified effect.

      Sets the transition effect used when moving between slides.

      Parameters:
      effect - one of "slide", "fade" or "none".

      Default: "slide".

      Returns:
      A modified copy of the this object
      Throws:
      org.zkoss.zk.ui.WrongValueException - if effect is none of "slide", "fade" or "none".
    • of

      static ICarousel of(Iterable<? extends ICarouselitem<IAnyGroup>> children)
      Returns the instance with the given ICarouselitem children.
      Parameters:
      children - The children of ICarouselitem
    • of

      static ICarousel of(ICarouselitem<IAnyGroup>... children)
      Returns the instance with the given ICarouselitem children.
      Parameters:
      children - The children of ICarouselitem
    • ofId

      static ICarousel ofId(String id)
      Returns the instance with the given id.
      Parameters:
      id - The id to identify this component