UNPKG

@frsource/tiny-carousel-core

Version:

Core module for @frsource/tiny-carousel, based on CSS scroll snap feature 🚀

61 lines (60 loc) • 2.29 kB
import './index.scss'; import type { DeepPartial, OmitFirstItem } from './helpers'; export declare type PluginDefinition<C extends unknown[] | undefined = undefined> = C extends unknown[] ? { install(instance: TinyCarousel, ...args: C): void; } : { install(instance: TinyCarousel): void; }; export interface Config { /** * Index of the item which should be activated during carousel initialization * More info: https://www.frsource.org/tiny-carousel/api-reference/core/#config */ active: number; /** * To be changed together with `$class-name` Sass variable * More info: https://www.frsource.org/tiny-carousel/api-reference/core/#styling */ className: string; /** * To be changed together with `$class-name-overflow` Sass variable * More info: https://www.frsource.org/tiny-carousel/api-reference/core/#styling */ classNameOverflow: string; /** * To be changed together with `$item-class-name` Sass variable * More info: https://www.frsource.org/tiny-carousel/api-reference/core/#styling */ itemClassName: string; /** * To be changed together with `$frs-hide-scroll` Sass variable * More info: https://www.frsource.org/tiny-carousel/api-reference/core/#styling */ hideScrollClassName: string; /** * Allows toggling the overflow behavior on or off. Default: true * More info: https://www.frsource.org/tiny-carousel/api-reference/core/#config */ overflow: boolean; items: HTMLElement[]; } export declare class TinyCarousel { carouselElement: HTMLElement; config: Config; private _active?; private _resetActive; private _handleOverflow; static get defaultConfig(): Config; static updateDefaultConfig(config: DeepPartial<Config>): void; constructor(carouselElement: HTMLElement, config?: DeepPartial<Config>); private handleOverflow; use<PD extends PluginDefinition>(pluginDefinition: PD, ...args: OmitFirstItem<Parameters<PD['install']>>): this; init(): this; destroy(): this; get active(): number; goTo(n: number): this; next(): this; prev(): this; resetActive(): void; findPossibleItems(): HTMLElement[]; }