@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
143 lines (142 loc) • 6.97 kB
TypeScript
import { ESLIntersectionEvent } from '../../../esl-event-listener/core';
import { ESLCarouselPlugin } from '../esl-carousel.plugin';
import type { ESLCarouselAutoplayBehaviour, ESLCarouselAutoplayReason, ESLCarouselAutoplayState } from './esl-carousel.autoplay.types';
export interface ESLCarouselAutoplayConfig {
/** Global autoplay duration (ms) or media rule pattern. 0 means "no default cycle"; negative / invalid disables plugin */
duration: string | number;
/** Navigation command executed each cycle */
command: string;
/** Intersection threshold used to (auto) pause when out of viewport */
intersection: number;
/** Enable hover / focus based pausing */
trackInteraction: boolean;
/** Scope selector for interaction tracking subscriptions (defaults to host (carousel)) */
interactionScope?: string;
/** CSS selector (Element.matches) to exclude items from the effective interaction scope. Does not affect subscriptions */
interactionScopeExclude?: string;
/** CSS class applied to the carousel container while autoplay is enabled */
containerCls?: string;
/** Behaviour of runtime blockers */
blockBehaviour: ESLCarouselAutoplayBehaviour;
/** Selector for items that, when active, should disable autoplay */
blockerSelector?: string;
/** Events that should trigger blocking state re-check when fired anywhere in the document */
watchEvents: string;
}
/**
* Autoplay plugin mixin for {@link ESLCarousel}.
* Schedules slide navigation by timeout while allowed by viewport, interaction and config constraints.
*/
export declare class ESLCarouselAutoplayMixin extends ESLCarouselPlugin<ESLCarouselAutoplayConfig> {
static is: string;
static DEFAULT_CONFIG: ESLCarouselAutoplayConfig;
static DEFAULT_CONFIG_KEY: keyof ESLCarouselAutoplayConfig;
/** Per-slide override attribute name for timeout */
static SLIDE_DURATION_ATTRIBUTE: string;
/** Manual stop flag */
private _stoppedByUser;
/** Manual pause flag */
private _pausedByUser;
/** Last known viewport intersection state */
private _inViewport;
/** Active cycle timeout id (null if no cycle scheduled) */
private _timeout;
/** Remaining time until the current cycle ends */
private _remaining;
/** Current cycle full duration */
private _cycleDuration;
/** Current cycle scheduling start timestamp */
private _cycleStartedAt;
/** Last dispatch reason */
private _lastReason;
/** Last dispatched state snapshot key to suppress duplicate events */
private _lastDispatchKey;
/** True when a navigation timeout is currently scheduled */
get active(): boolean;
/** True when autoplay is paused explicitly by user action and can potentially be resumed */
get paused(): boolean;
/** Exclusive summary state for autoplay runtime */
get state(): ESLCarouselAutoplayState;
/** True when autoplay cannot run due to runtime blockers */
get blocked(): boolean;
/**
* Effective enabled state.
* True when autoplay is not manually stopped and global duration is non-negative / valid.
*/
get enabled(): boolean;
/** Backward-compatible manual enable / disable API */
set enabled(value: boolean);
/** Global base duration in ms (raw config parsed). Negative / NaN considered as disabled */
get duration(): number;
/**
* Effective current slide duration.
* Tries active slide attribute; falls back to global duration.
* Non-positive result pauses cycle for the slide only (unless global invalid disables plugin).
*/
get effectiveDuration(): number;
/** Remaining time of the current/paused cycle */
get remaining(): number;
/** Interaction scope elements used as event subscription targets (memoized) */
get $interactionScope(): HTMLElement[];
/** Effective interaction scope after exclusion rules are applied */
get $effectiveInteractionScope(): HTMLElement[];
/** True if active slide contains any blocking items */
get hasActiveBlockingItems(): boolean;
/** True if any scope element is hovered */
get hovered(): boolean;
/** True if keyboard-visible focus is within scope */
get focused(): boolean;
/** Backward-compatible alias for runtime allowance */
get allowed(): boolean;
/** Runtime predicate: autoplay may have an active timeout right now */
get canRun(): boolean;
/** True if autoplay can be scheduled for the current slide */
protected get canSchedule(): boolean;
/** True if autoplay may be re-started automatically by runtime conditions */
protected get canAutoStart(): boolean;
/** True if runtime listeners should sync blocking state right now */
protected get shouldProcessBlockingState(): boolean;
/** Start autoplay or resume paused cycle */
start(reason?: ESLCarouselAutoplayReason): void;
/** Pause autoplay preserving remaining time when possible */
pause(reason?: ESLCarouselAutoplayReason): void;
/** Stop autoplay and clear current cycle state */
stop(reason?: ESLCarouselAutoplayReason): void;
/** Toggle autoplay state according to the specified control behaviour */
toggle(behaviour?: ESLCarouselAutoplayBehaviour): void;
/** Init lifecycle hook */
protected onInit(): void;
/** React to config changes (rebuild memoized queries, re-evaluate state) */
protected onConfigChange(): void;
/** Suspend & cleanup on disconnect */
protected disconnectedCallback(): void;
/** Update classes and listeners and synchronize state markers */
protected update(): void;
/** Update UI markers reflecting effective autoplay state */
protected updateMarkers(): void;
/** Reset current cycle state completely */
protected resetCycle(): void;
/** Clear active timer only */
protected clearTimer(): void;
/** Schedule next autoplay cycle */
protected schedule(duration: number, total?: number, reason?: ESLCarouselAutoplayReason): void;
/** Sync current state markers and dispatch autoplay event */
protected syncState(reason?: ESLCarouselAutoplayReason): void;
/** Apply blocking logic according to configured block behaviour */
protected syncBlockingState(): void;
/** Internal cycle handler (execute navigation then schedule next cycle if needed) */
protected _onCycle(exec?: boolean): Promise<void>;
/** Viewport intersection listener controlling runtime allowance */
protected _onIntersection(e: ESLIntersectionEvent): void;
/** Hover/focus interaction listener toggling pause state */
protected _onInteract(): void;
/** Slide change listener (forces cycle restart) */
protected _onSlideChange(): void;
/** Subscribe to events that block autoplay */
protected _onBlockingEvent(): void;
}
declare global {
export interface ESLCarouselNS {
Autoplay: typeof ESLCarouselAutoplayMixin;
}
}