Class Snap<CallbacksMap, StaticProps, MutableProps>

Snap/Carousel handler. This class manages sliding progress with options like swipe, wheel interactions, and smooth transitions.

Please not that the class does not apply any styles to the slides, it only handles the logic.

Documentation

Type Parameters

Hierarchy (View Summary)

Constructors

Properties

_activeIndex: number

Active slide index

_callbacks: Callbacks<CallbacksMap>

Callbacks instance

_destroyable: () => void[] = []

Stores actions that need to be executed when the module is destroyed

_domSize: number = 0

Container size

_isDestroyed: boolean = false

Tracks whether the module has been destroyed

_keyboard: SnapKeyboard

Snap keyboard

_props: TTRequiredProps<MutableProps & StaticProps>

Current properties

_raf: Raf

Animation frame for smooth animations

_resizeHandler: IOnResize

Resize handler

_slides: SnapSlide[] = []

All slides

_swipe: SnapSwipe

Swipe events

Timeline for smooth transitions

_track: SnapTrack

Snap Track

_wheel: SnapWheel

Wheel events

Accessors

  • get isDestroyed(): boolean

    Checks if the module has been destroyed.

    Returns boolean

  • get name(): string

    The name of the module, derived from the class name

    Returns string

  • get prefix(): string

    Optional prefix for classnames used by the module

    Returns string

Methods

  • Adds a class name on an element, and keeps track of it for removal when the module is destroyed.

    Parameters

    • element: Element

      The target DOM element.

    • className: string

      The class name to toggle.

    Returns void

  • Helper function to generate classnames with the module's prefix.

    Parameters

    • ...classNames: string[]

      The class names to generate.

    Returns string

    A string of class names with the module's prefix applied.

  • Adds a callback on the module's destruction.

    Parameters

    • action: () => void

      The function to execute during destruction.

    Returns void

  • Request resize (handled with debounce timeout)

    Parameters

    • isManual: boolean = false

    Returns void