ESL Carousel Autoplay

The esl-carousel-autoplay is a custom attribute (plugin/mixin) for ESLCarousel that provides autoplay functionality. It lets the carousel automatically navigate between slides on a timed cycle, issuing a navigation command at each interval. Attach the plugin directly on the esl-carousel element (it will self‑remove if applied elsewhere). The plugin supports ESL media rule syntax, enabling responsive configuration. Features include: hover/focus pause, separate external control/progress mixins, and per‑slide timeout overrides.

Configuration

The only configuration source is the esl-carousel-autoplay attribute value (plugin config system). Supports ESL media rule syntax (either unified arrow syntax or tuple form bound to the carousel media attribute).

Configuration properties:

Configuration notes:

Public properties / state

Public methods

reason is an optional compact machine-readable token. Typical values are:

Notes:

Manual control

Programmatic examples:

Migration note for 6.2

In 6.2 autoplay controls are no longer configured through the esl-carousel-autoplay config object.

If you used:

<esl-carousel esl-carousel-autoplay="{control: '.btn', controlBehaviour: 'pause'}"></esl-carousel>

switch to a dedicated control mixin placed directly on the control element:

<div class="esl-carousel-nav-container">
  <button esl-carousel-autoplay-control="pause">Pause autoplay</button>
  <esl-carousel esl-carousel-autoplay="8s">...</esl-carousel>
</div>

In other words:

ESL Carousel Autoplay State Attribute

esl-carousel-autoplay-state is a read-only state mixin hosted directly on any element. It resolves a target carousel, listens for autoplay state changes and reflects current autoplay state on the host.

Configuration

Usage

Register the mixin:

ESLCarouselAutoplayStateMixin.register();

Then attach it to any element that only needs the autoplay status:

<div class="esl-carousel-nav-container">
  <span esl-carousel-autoplay-state></span>
  <esl-carousel esl-carousel-autoplay="8s">...</esl-carousel>
</div>

Runtime State Attributes

When attached to an element the mixin manages the following state markers on the host:

esl-carousel-autoplay-control and esl-carousel-autoplay-progress extend the same state model and add their own behaviour on top.

ESL Carousel Autoplay Control Attribute

esl-carousel-autoplay-control is a separate control mixin hosted directly on the control element. It extends esl-carousel-autoplay-state and adds action/a11y semantics.

Configuration

Usage

Register the mixin:

ESLCarouselAutoplayControlMixin.register();

Then attach it to any external or internal control element:

<div class="esl-carousel-nav-container">
  <button esl-carousel-autoplay-control="stop">Toggle autoplay</button>
  <esl-carousel esl-carousel-autoplay="8s">...</esl-carousel>
</div>

Or with explicit targeting:

<button
  esl-carousel-autoplay-control="pause"
  esl-carousel-autoplay-target="::next">
  Pause autoplay
</button>
<esl-carousel esl-carousel-autoplay="8s">...</esl-carousel>

Runtime State Attributes

When attached to an element the mixin manages the following state markers on the host:

The mixin also manages aria-controls and aria-pressed for basic toggle accessibility.

Per‑Slide Timeout Customization

Use esl-carousel-autoplay-timeout on a slide to override the cycle duration for that slide. If omitted, the global duration (which may be 0) is used. If parsing fails or value is invalid, the global duration is used (NOT treated as pause unless that global duration itself is 0 / non‑positive). <= 0 per‑slide value pauses autoplay only while that slide is active.

Note: An intentionally invalid value in a media rule branch can be used to fallback to the global duration. Example:

<esl-carousel-slide esl-carousel-autoplay-timeout="0 | @desktop => inherit"></esl-carousel-slide>

Here 0 disables autoplay for this slide on non‑desktop breakpoints, while the invalid inherit token on @desktop resolves to the global autoplay duration (so autoplay runs there).

Example:

<esl-carousel esl-carousel-autoplay="3s">
  <esl-carousel-slide>Default timeout (3s)</esl-carousel-slide>
  <esl-carousel-slide esl-carousel-autoplay-timeout="5s">Custom (5s)</esl-carousel-slide>
  <esl-carousel-slide esl-carousel-autoplay-timeout="1s">Fast (1s)</esl-carousel-slide>
  <esl-carousel-slide esl-carousel-autoplay-timeout="0">Paused on this slide</esl-carousel-slide>
</esl-carousel>

Media Queries for per‑slide

<esl-carousel-slide esl-carousel-autoplay-timeout="2s | @XS => 4s | @LG => 0">
  Adaptive durations (paused on @LG)
</esl-carousel-slide>

Tuple syntax variant (bound to carousel media):

<esl-carousel media="all | @XS | @SM" esl-carousel-autoplay="3s">
  <esl-carousel-slide esl-carousel-autoplay-timeout="2s | 3s | 0"></esl-carousel-slide>
</esl-carousel>

Supported time formats:

Events

esl:autoplay:change (non-bubbling, non-cancelable) emitted on the carousel when:

Event payload fields:

Use case examples: progress indicator, custom UI state, analytics.

ESL Carousel Autoplay Progress Attribute

esl-carousel-autoplay-progress is a read-only progress mixin hosted directly on any element. It extends esl-carousel-autoplay-state and adds autoplay progress CSS variables / animation markers.

Configuration

Usage

Register the mixin:

ESLCarouselAutoplayProgressMixin.register();

Then attach it to any element that should reflect autoplay progress:

<div class="esl-carousel-nav-container">
  <button esl-carousel-autoplay-progress></button>
  <esl-carousel esl-carousel-autoplay="8s">...</esl-carousel>
</div>

Or with explicit targeting:

<button
  esl-carousel-autoplay-progress
  esl-carousel-autoplay-target="::next">
</button>
<esl-carousel esl-carousel-autoplay="8s">...</esl-carousel>

Runtime State Attributes

Like esl-carousel-autoplay-state, the progress mixin reflects the shared autoplay state model on the host:

Progress Markers

The mixin also manages the following progress-specific markers on the host:

paused and blocked are intentionally separate here too:

Examples

Basic autoplay

<esl-carousel esl-carousel-autoplay="10s">
  <ul esl-carousel-slides>
    <li esl-carousel-slide>Slide 1</li>
    <li esl-carousel-slide>Slide 2</li>
    <li esl-carousel-slide>Slide 3</li>
  </ul>
</esl-carousel>

Base suppressed (duration 0) with per‑slide override

<esl-carousel esl-carousel-autoplay="0">
  <ul esl-carousel-slides>
    <li esl-carousel-slide esl-carousel-autoplay-timeout="4s">Only this slide auto advances</li>
    <li esl-carousel-slide>Static (no cycle here)</li>
  </ul>
</esl-carousel>

Disable below breakpoint

<esl-carousel esl-carousel-autoplay="8s | @XS => none">

(or use a negative value instead of none).

Responsive with controls and container class

<div class="esl-carousel-nav-container">
  <button esl-carousel-autoplay-control="pause">Toggle autoplay</button>
  <esl-carousel esl-carousel-autoplay="{duration: 0, containerCls: 'autoplay-enabled'} | @MD => 5s | @LG => 10s">
    <ul esl-carousel-slides>
      <li esl-carousel-slide>Slide 1</li>
      <li esl-carousel-slide>Slide 2</li>
    </ul>
  </esl-carousel>
</div>

This keeps plugin ready (duration 0) on small screens and starts cycles only from @MD / @LG.


Short reference: