123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- import { I18N } from '../constants/i18n';
- /**
- * The interface for options.
- *
- * @since 3.0.0
- */
- export interface Options extends ResponsiveOptions {
- /**
- * The type of the slider.
- * - 'slide': A slider with the slide transition
- * - 'loop' : A carousel slider
- * - 'fade' : A slider with the fade transition. This does not support the perPage option.
- */
- type?: string;
- /**
- * The `role` attribute for the root element.
- * If the tag is `<section>`, this value will not be used. The default value is `'region'`.
- */
- role?: string;
- /**
- * Determines whether to disable any actions while the slider is transitioning.
- * Even if `false`, the slider forcibly waits for transition on the loop points.
- */
- waitForTransition?: boolean;
- /**
- * If `true`, the width of slides are determined by their width.
- * The `perPage` and `perMove` options should be `1`.
- */
- autoWidth?: boolean;
- /**
- * If `true`, the height of slides are determined by their height.
- * The `perPage` and `perMove` options should be `1`.
- */
- autoHeight?: boolean;
- /**
- * The start index.
- */
- start?: number;
- /**
- * Changes the arrow SVG path, like 'm7.61 0.807-2.12...'.
- */
- arrowPath?: string;
- /**
- * Determines whether to activate autoplay or not.
- * If `paused`, it will not begin when the slider becomes active.
- * You need to provided play/pause buttons or manually start it by `Autoplay#play()`.
- */
- autoplay?: boolean | 'pause';
- /**
- * The autoplay interval in milliseconds.
- */
- interval?: number;
- /**
- * Determines whether to pause autoplay on mouseover.
- */
- pauseOnHover?: boolean;
- /**
- * Determines whether to pause autoplay when the slider contains the active element (focused element).
- * This should be `true` for accessibility.
- */
- pauseOnFocus?: boolean;
- /**
- * Determines whether to reset the autoplay progress when it is requested to start again.
- */
- resetProgress?: boolean;
- /**
- * Enables lazy loading.
- * Provide the `src` by the `data-splide-lazy` or the `srcset` by the `data-splide-lazy-srcset`.
- * You may also provide `src` for the placeholder, but the value must be different with the data.
- *
- * - `false`: Disables lazy loading
- * - `'nearby'`: Starts loading only images around the active slide (page)
- * - `'sequential'`: Loads images sequentially
- */
- lazyLoad?: boolean | 'nearby' | 'sequential';
- /**
- * Determine how many pages (not slides) around the active slide should be loaded beforehand.
- * This only works when the `lazyLoad` option is `'nearby'`.
- */
- preloadPages?: number;
- /**
- * Enables keyboard shortcuts for the slider control.
- * - `true` or `'global'`: Listens to the `keydown` event of the document.
- * - 'focused': Listens to the `keydown` event of the slider root element with adding `tabindex="0"` to it.
- * - `false`: Disables keyboard shortcuts (default).
- */
- keyboard?: boolean | string;
- /**
- * Enables navigation by the mouse wheel.
- * Set `waitForTransition` to `ture` or provide the `wheelSleep` duration.
- */
- wheel?: boolean;
- /**
- * The threshold to cut off the small delta produced by inertia scroll.
- */
- wheelMinThreshold?: number;
- /**
- * The sleep time in milliseconds until accepting next wheel.
- * The timer starts when the transition begins.
- */
- wheelSleep?: number;
- /**
- * Determines whether to release the wheel event when the slider reaches the first or last slide.
- */
- releaseWheel?: boolean;
- /**
- * The direction of the slider.
- * - 'ltr': Left to right
- * - 'rtl': Right to left
- * - 'ttb': Top to bottom
- */
- direction?: 'ltr' | 'rtl' | 'ttb';
- /**
- * Converts the image `src` to the css `background-image` URL of the parent element.
- * This requires `fixedHeight` or `heightRatio` option.
- */
- cover?: boolean;
- /**
- * Determines whether to add `tabindex="0"` to visible slides or not.
- */
- slideFocus?: boolean;
- /**
- * If `true`, the slider makes slides clickable to navigate another slider.
- * Use `Splide#sync()` to sync multiple sliders.
- */
- isNavigation?: boolean;
- /**
- * Determines whether to trim spaces before/after the slider if the `focus` option is available.
- * - `true`: Trims spaces. The slider may stay on the same location even when requested to move.
- * - `'move'`: Trims spaces and focuses to move the slider when requested.
- */
- trimSpace?: boolean | 'move';
- /**
- * Updates the `is-active` status of slides just before moving the slider.
- */
- updateOnMove?: boolean;
- /**
- * If `min`, the media query for breakpoints will be `min-width`, or otherwise, `max-width`.
- */
- mediaQuery?: 'min' | 'max';
- /**
- * The selector to get focusable elements
- * where `tabindex="-1"` will be assigned when their ascendant slide is hidden.
- */
- focusableNodes?: string;
- /**
- * The selector for nodes that cannot be dragged.
- */
- noDrag?: string;
- /**
- * Enables the live region by `aria-live`.
- * If `true`, screen readers will read a content of each slide whenever slide changes.
- */
- live?: boolean;
- /**
- * Determines whether to use the Transition component or not.
- */
- useScroll?: boolean;
- /**
- * Options for specific breakpoints.
- *
- * @example
- * ```ts
- * {
- * 1000: {
- * perPage: 3,
- * gap : 20
- * },
- * 600: {
- * perPage: 1,
- * gap : 5,
- * },
- * }
- * ```
- */
- breakpoints?: Record<string | number, ResponsiveOptions>,
- /**
- * The collection of class names.
- */
- classes?: Record<string, string>;
- /**
- * The collection of i18n strings.
- */
- i18n?: Record<keyof typeof I18N | string, string>;
- }
- /**
- * The interface for options that can correspond with breakpoints.
- *
- * @since 3.0.0
- */
- export interface ResponsiveOptions {
- /**
- * Accepts arbitrary properties for extensions, although it's not ideal typing.
- */
- [ key: string ]: any;
- /**
- * The transition speed in milliseconds.
- */
- speed?: number;
- /**
- * Determines whether to rewind the slider or not.
- */
- rewind?: boolean;
- /**
- * The transition speed on rewind in milliseconds.
- */
- rewindSpeed?: number;
- /**
- * Allows to rewind by drag.
- * The slider `type` must be `slide` (or `undefined`) and the `drag` option must be enabled.
- */
- rewindByDrag?: boolean;
- /**
- * Defines the slider max width, accepting the CSS format such as 10em, 80vw.
- */
- width?: number | string;
- /**
- * Defines the slider height, accepting the CSS format.
- */
- height?: number | string;
- /**
- * Fixes width of slides, accepting the CSS format.
- * The slider will ignore the `perPage` option if you provide this value.
- */
- fixedWidth?: number | string;
- /**
- * Fixes height of slides, accepting the CSS format.
- * The slider will ignore the `heightRatio` option if you provide this value.
- */
- fixedHeight?: number | string;
- /**
- * Determines height of slides by the ratio to the slider width.
- * For example, when the slider width is `1000` and the ratio is `0.5`, the height will be `500`.
- */
- heightRatio?: number;
- /**
- * Determines the number of slides to display in a page.
- */
- perPage?: number;
- /**
- * Determines the number of slides to move at once.
- */
- perMove?: number;
- /**
- * Determine the number of clones on each side of the slider.
- * In most cases, you don't need to provide this value.
- */
- clones?: number;
- /**
- * Determines whether to clone status classes for clones or not.
- */
- cloneStatus?: boolean;
- /**
- * Determines which slide should be active if there are multiple slides in a page.
- * Numbers and `'center'` are acceptable.
- */
- focus?: number | 'center';
- /**
- * The gap between slides. The CSS format is acceptable, such as `1em`.
- */
- gap?: number | string;
- /**
- * Sets padding left/right or top/bottom of the slider.
- * The CSS format is acceptable, such as `1em`.
- *
- * @example
- * ```ts
- * // By number
- * padding: 10,
- *
- * // By the CSS format
- * padding: '1rem',
- *
- * // Specifies each value for a horizontal slider
- * padding: { left: 10, right: 20 },
- * padding: { left: '1rem', right: '2rem' },
- *
- * // Specified each value for a vertical slider
- * padding: { top: 10, bottom: 20 },
- * ```
- */
- padding?:
- | number
- | string
- | { left?: number | string, right?: number | string }
- | { top?: number | string, bottom?: number | string };
- /**
- * Determines whether to create/find arrows or not.
- */
- arrows?: boolean;
- /**
- * Determines whether to create pagination (indicator dots) or not.
- */
- pagination?: boolean;
- /**
- * Determines whether to enable keyboard shortcuts for pagination when it contains focus.
- * The default value is `true`.
- */
- paginationKeyboard?: boolean;
- /**
- * Explicitly sets the pagination direction that does not only affect appearance but also shortcuts and ARIA attributes.
- * The default value is same with the carousel direction.
- */
- paginationDirection?: Options['direction'];
- /**
- * The timing function for the CSS transition. For example, `linear`, ease or `cubic-bezier()`.
- */
- easing?: string;
- /**
- * The easing function for the drag free mode.
- * The default function is the `easeOutQuart` interpolation.
- */
- easingFunc?: ( t: number ) => number;
- /**
- * Allows to drag the slider by a mouse or swipe.
- * If `free`, the slider does not snap to a slide after drag.
- */
- drag?: boolean | 'free';
- /**
- * Snaps the closest slide in the drag-free mode.
- */
- snap?: boolean;
- /**
- * The required distance to start moving the slider by the touch action.
- * If you want to define the threshold for the mouse, provide an object.
- */
- dragMinThreshold?: number | { mouse: number, touch: number };
- /**
- * Determine the power of "flick". The larger number this is, the farther the slider runs.
- * Around 500 is recommended.
- */
- flickPower?: number;
- /**
- * Limits the number of pages to move by "flick".
- */
- flickMaxPages?: number;
- /**
- * Destroys the slider.
- */
- destroy?: boolean | 'completely';
- }
|