SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

carouselControls

Adds --ui-prev/--ui-next/--ui-goto command handling to a Carousel viewport, scrolling by page or to a data-slide index and, on every command, scroll and resize, re-syncing what the invokers say: each --ui-prev/--ui-next button's disabled state.

tsx
import { carouselControls } from "@sdxc/ui/mixins";

Signature

typescript
carouselControls(): MixinDescriptor<HTMLElement>

Examples

tsx
<div id="cart-carousel" mix={carouselControls()}>
  <div data-carousel-slide>Slide 1</div>
  <div data-carousel-slide>Slide 2</div>
</div>
<button commandfor="cart-carousel" command="--ui-prev">Previous</button>
<button commandfor="cart-carousel" command="--ui-next">Next</button>
<button commandfor="cart-carousel" command="--ui-goto" data-slide="1">Slide 2</button>

The events, constants and types its module publishes, each imported from @sdxc/ui/mixins too.

Constant

Attribute every Carousel slide exposes itself on. carouselControls queries every element carrying this attribute beneath the viewport, in document order, to resolve the slide a --ui-goto command targets.

typescript
const CAROUSEL_SLIDE_ATTRIBUTE = "data-carousel-slide"
Constant

Set on a Carousel root once carouselSync runs it, for controls that need script.

typescript
const CAROUSEL_READY_ATTRIBUTE = "data-carousel-ready"
@sdxc/ui

Can’t find it? Contact us