Class Swipe<CallbacksMap, StaticProps, MutableProps>

Manages swipe interactions:

  • Tracks movement and detects direction
  • Emits events on start, move, and end
  • Supports inertia-based movement

Notes:

  • Does not transform elements, only computes coordinates.
  • Does not persist state after swipe completion.

Documentation

Type Parameters

Hierarchy (View Summary)

Constructors

Properties

_callbacks: Callbacks<CallbacksMap>

Callbacks instance

_coords: ISwipeCoords

Swipe tracking data

_cursorStyles: HTMLStyleElement

Cursor styles

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

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

Inertia animation

_isAborted: boolean = false

If swiping has been aborted

_isDestroyed: boolean = false

Tracks whether the module has been destroyed

_isSwiping: boolean = false

If swiping has started

_pointers: Pointers

Pointer event manager

_props: TTRequiredProps<MutableProps & StaticProps>

Current properties

_startCoord: undefined | ISwipeVec2

Initial swipe coordinates (internal use)

_startTime: undefined | number

Swipe start time

_velocities: ISwipeVelocity[]

Velocity tracking

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

  • get velocity(): undefined | { angle: number; x: number; y: number }

    Returns current velocity

    Returns undefined | { angle: number; x: number; y: number }

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