diff --git a/types/swiper/index.d.ts b/types/swiper/index.d.ts index 65872facd2..18fc517275 100644 --- a/types/swiper/index.d.ts +++ b/types/swiper/index.d.ts @@ -1,339 +1,986 @@ -// Type definitions for Swiper 3.4 +// Type definitions for Swiper // Project: https://github.com/nolimits4web/Swiper -// Definitions by: Sebastián Galiano , Luca Trazzi +// Definitions by: Sebastián Galiano +// Definitions by: Luiz Machado // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.5 +// Swiper Version: 4.2.6 -interface SwiperOptions { - initialSlide?: number; - direction?: string; - speed?: number; - setWrapperSize?: boolean; - virtualTranslate?: boolean; - width?: number; - height?: number; - autoHeight?: boolean; - roundLengths?: boolean; - nested?: boolean; +// declare namespace swiper { +declare module 'swiper' { - // Autoplay - autoplay?: number; - autoplayStopOnLast?: boolean; - autoplayDisableOnInteraction?: boolean; + type DOM7Element = any; + type SelectableElement = string | HTMLElement; - // Progress - watchSlidesProgress?: boolean; - watchSlidesVisibility?: boolean; + /* + * Swiper exports the folloing as ES5 module (in swiper.esm.js). + */ - // Freemode - freeMode?: boolean; - freeModeMomentum?: boolean; - freeModeMomentumRatio?: number; - freeModeMomentumVelocityRatio?: number; - freeModeMomentumBounce?: boolean; - freeModeMomentumBounceRatio?: number; - freeModeMinimumVelocity?: number; - freeModeSticky?: boolean; + /** + * Core module + */ + class Swiper { - // Effects - effect?: string; - fade?: {}; - cube?: {}; - coverflow?: {}; - flip?: {}; + constructor(container: SelectableElement, options?: SwiperOptions); - // Parallax - parallax?: boolean; + /** + * Object with passed initialization parameters + */ + params: SwiperOptions; - // Slides grid - spaceBetween?: number; - slidesPerView?: number | string; - slidesPerColumn?: number; - slidesPerColumnFill?: string; - slidesPerGroup?: number; - centeredSlides?: boolean; - slidesOffsetBefore?: number; - slidesOffsetAfter?: number; + /** + * Element with slider container. + */ + el: HTMLElement; - // Grab Cursor - grabCursor?: boolean; + /** + * Dom7 element with slider container HTML element. To get vanilla HTMLElement use el + */ + $el: DOM7Element; - // Touches - touchEventsTarget?: string; - touchRatio?: number; - touchAngle?: number; - simulateTouch?: boolean; - shortSwipes?: boolean; - longSwipes?: boolean; - longSwipesRatio?: number; - longSwipesMs?: number; - followFinger?: boolean; - onlyExternal?: boolean; - threshold?: number; - touchMoveStopPropagation?: boolean; - iOSEdgeSwipeDetection?: boolean; - iOSEdgeSwipeThreshold?: number; + /** + * Slider wrapper HTML element. + */ + wrapperEl: HTMLElement; - // Touch Resistance - resistance?: boolean; - resistanceRatio?: number; + /** + * Dom7 element with slider wrapper HTML element. To get vanilla HTMLElement use wrapperEl + */ + $wrapperEl: DOM7Element; - // Clicks - preventClicks?: boolean; - preventClicksPropagation?: boolean; - slideToClickedSlide?: boolean; + /** + * Dom7 array-like collection of slides HTML elements. To get specific slide HTMLElement use slides[1] + */ + slides: DOM7Element[]; - // Swiping / No swiping - allowSwipeToPrev?: boolean; - allowSwipeToNext?: boolean; - noSwiping?: boolean; - noSwipingClass?: string; - swipeHandler?: string | Element; + /** + * Width of container + */ + width; - // Navigation Controls - uniqueNavElements?: boolean; + /** + * Height of container + */ + height; - // Pagination - pagination?: string | Element; - paginationType?: string; - paginationHide?: boolean; - paginationClickable?: boolean; - paginationElement?: string; - paginationBulletRender?(swiper: Swiper, index: number, className: string): void; - paginationFractionRender?(swiper: Swiper, currentClassName: string, totalClassName: string): void; - paginationProgressRender?(swiper: Swiper, progressbarClass: string): void; - paginationCustomRender?(swiper: Swiper, current: number, total: number): void; + /** + * Current value of wrapper translate + */ + translate; - // Navigation Buttons - nextButton?: string | Element; - prevButton?: string | Element; + /** + * Current progress of wrapper translate (from 0 to 1) + */ + progress; - // Scollbar - scrollbar?: string | Element | SwiperScrollbarOptions; - scrollbarHide?: boolean; - scrollbarDraggable?: boolean; - scrollbarSnapOnRelease?: boolean; + /** + * Index number of currently active slide. + * Note, that in loop mode active index value will be always shifted on a number of looped/duplicated slides + */ + activeIndex; - // Accessibility - a11y?: boolean; - prevSlideMessage?: string; - nextSlideMessage?: string; - firstSlideMessage?: string; - lastSlideMessage?: string; - paginationBulletMessage?: string; + /** + * Index number of currently active slide considering duplicated slides in loop mode + */ + realIndex; - // Keyboard / Mousewheel - keyboardControl?: boolean; - mousewheelControl?: boolean; - mousewheelForceToAxis?: boolean; - mousewheelReleaseOnEdges?: boolean; - mousewheelInvert?: boolean; - mousewheelSensitivity?: number; + /** + * Index number of previously active slide + */ + previousIndex; - // Hash Navigation - hashnav?: boolean; - hashnavWatchState?: boolean; - history?: string; + /** + * true if slider on most "left"/"top" position + */ + isBeginning; - // Images - preloadImages?: boolean; - updateOnImagesReady?: boolean; - lazyLoading?: boolean; - lazyLoadingInPrevNext?: boolean; - lazyLoadingInPrevNextAmount?: number; - lazyLoadingOnTransitionStart?: boolean; + /** + * true if slider on most "right"/"bottom" position + */ + isEnd; - // Loop - loop?: boolean; - loopAdditionalSlides?: number; - loopedSlides?: number; + /** + * true if swiper is in transition + */ + animating; - zoom?: boolean; + /** + * Object with the following touch event properties: + */ + touches: { + startX, + startY, + currentX, + currentY, + diff + }; - // Controller - control?: Swiper; - controlInverse?: boolean; - controlBy?: string; + /** + * Index number of last clicked slide + */ + clickedIndex; - // Observer - observer?: boolean; - observeParents?: boolean; + /** + * Link to last clicked slide (HTMLElement) + */ + clickedSlide; - // Breakpoints - breakpoints?: {}; + /** + * Disable/enable ability to slide to the next slides by assigning false/true to this property + */ + allowSlideNext; - // Callbacks - runCallbacksOnInit?: boolean; - onInit?(swiper: Swiper): void; - onSlideChangeStart?(swiper: Swiper): void; - onSlideChangeEnd?(swiper: Swiper): void; - onSlideNextStart?(swiper: Swiper): void; - onSlideNextEnd?(swiper: Swiper): void; - onSlidePrevStart?(swiper: Swiper): void; - onSlidePrevEnd?(swiper: Swiper): void; - onTransitionStart?(swiper: Swiper): void; - onTransitionEnd?(swiper: Swiper): void; - onTouchStart?(swiper: Swiper, event: Event): void; - onTouchMove?(swiper: Swiper, event: Event): void; - onTouchMoveOpposite?(swiper: Swiper, event: Event): void; - onSliderMove?(swiper: Swiper, event: Event): void; - onTouchEnd?(swiper: Swiper, event: Event): void; - onClick?(swiper: Swiper, event: Event): void; - onTap?(swiper: Swiper, event: Event): void; - onDoubleTap?(swiper: Swiper, event: Event): void; - onImagesReady?(swiper: Swiper): void; - onProgress?(swiper: Swiper, progress: number): void; - onReachBeginning?(swiper: Swiper): void; - onReachEnd?(swiper: Swiper): void; - onDestroy?(swiper: Swiper): void; - onSetTranslate?(swiper: Swiper, translate: any): void; - onSetTransition?(swiper: Swiper, transition: any): void; - onAutoplay?(swiper: Swiper): void; - onAutoplayStart?(swiper: Swiper): void; - onAutoplayStop?(swiper: Swiper): void; - onLazyImageLoad?(swiper: Swiper, slide: any, image: any): void; - onLazyImageReady?(swiper: Swiper, slide: any, image: any): void; - onPaginationRendered?(swiper: Swiper, paginationContainer: any): void; - onScroll?(swiper: Swiper, event: Event): void; - onBeforeResize?(swiper: Swiper): void; - onAfterResize?(swiper: Swiper): void; - onKeyPress?(swiper: Swiper, kc: any): void; + /** + * Disable/enable ability to slide to the previous slides by assigning false/true to this property + */ + allowSlidePrev; - // Namespace - slideClass?: string; - slideActiveClass?: string; - slideVisibleClass?: string; - slideDuplicateClass?: string; - slideNextClass?: string; - slidePrevClass?: string; - wrapperClass?: string; - bulletClass?: string; - bulletActiveClass?: string; - paginationHiddenClass?: string; - paginationCurrentClass?: string; - paginationTotalClass?: string; - paginationProgressbarClass?: string; - buttonDisabledClass?: string; + /** + * Disable/enable ability move slider by grabbing it with + * mouse or by touching it with finger (on touch screens) + * by assigning false/true to this property + */ + allowTouchMove; + + // Methods + + /** + * Run transition to next slide + * speed - number - transition duration (in ms). Optional + * runCallbacks - boolean - Set it to false (by default it is true) and transition will not produce transition events. Optional + */ + slideNext: (speed: number, runCallbacks: boolean) => {}; + + /** + * Run transition to previous slide + // speed - number - transition duration (in ms). Optional + // runCallbacks - boolean - Set it to false (by default it is true) and transition will not produce transition events. Optional + */ + slidePrev: (speed: number, runCallbacks: boolean) => {}; + + /** + * Run transition to the slide with index number equal to 'index' parameter for the duration equal to 'speed' parameter. + * + * @param index - index number of slide + * @param speed - transition duration (in ms). Optional + * @param runCallbacks - Set it to false (by default it is true) and transition will not produce transition events. Optional + */ + slideTo: (index: number, speed: number, runCallbacks: boolean) => {}; + + /** + * You should call it after you add/remove slides + * manually, or after you hide/show it, or do any + * custom DOM modifications with Swiper + * This method also includes subcall of the following + * methods which you can use separately: + */ + update: () => {}; + + /** + * recalculate size of swiper container + */ + updateSize: () => {}; + /** + * recalculate number of slides and their offsets. Useful after you add/remove slides with JavaScript + */ + updateSlides: () => {}; + /** + * recalculate swiper progress + */ + updateProgress: () => {}; + /** + * update active/prev/next classes on slides and bullets + */ + updateSlidesClasses: () => {}; + /** + * tach all events listeners + */ + detachEvents: () => {}; + /** + * Atach all events listeners again + */ + attachEvents: () => {}; + /** + * Destroy slider instance and detach all events listeners, where + */ + destroy: (deleteInstance: any, cleanStyles: any) => {}; + /** + * Set it to false (by default it is true) to not to delete Swiper instance + */ + deleteInstance: boolean; + /** + * Set it to true (by default it is true) and all + * custom styles will be removed from slides, + * wrapper and container. Useful if you need to + * destroy Swiper and to init again with new + * options or in different direction + */ + cleanStyles: boolean; + /** + * Add new slides to the end. slides could be + * HTMLElement or HTML string with new slide or + * array with such slides, for example: + * + * @example appendSlide('
Slide 10"
') + * @example appendSlide(['
Slide 10"
', '
Slide 11"
']); + */ + appendSlide: (slides: string | string[]) => {}; + /** + * Add new slides to the beginning. slides could be + * HTMLElement or HTML string with new slide or array with such slides, for example: + * + * @example prependSlide('
Slide 0"
') + * @example prependSlide(['
Slide 1"
', '
Slide 2"
']); + */ + prependSlide: (slides: string | string[]) => {}; + /** + * Remove selected slides. slideIndex could be a number with slide index to remove or array with indexes. + * + * @example removeSlide(0); // remove first slide + * @example removeSlide([0, 1]); // remove first and second slides + * @example removeAllSlides(); // Remove all slides + */ + removeSlide: (slideIndex: number | number[]) => {}; + /** + * Set custom css3 transform's translate value for swiper wrapper + */ + setTranslate: (translate: any) => {}; + /** + * Get current value of swiper wrapper css3 transform translate + */ + getTranslate: () => {}; + + /** + * Add event listener + */ + on: (event: any, handler: any) => {}; + + /** + * Add event listener that will be executed only once + */ + once: (event: any, handler: any) => {}; + + /** + * Remove event listener for specified event + * If no handler specified, removes all listeners for specified event + */ + off: (event: any, handler?: any) => {}; + + /** + * Disable mousewheel control + */ + disableMousewheelControl: () => {}; + + /** + * Enable mousewheel control + */ + enableMousewheelControl: () => {}; + + /** + * Disable keyboard control + */ + disableKeyboardControl: () => {}; + + /** + * Enable keyboard control + */ + enableKeyboardControl: () => {}; + + /** + * Unset grab cursor + */ + unsetGrabCursor: () => {}; + + /** + * Set grab cursor + */ + setGrabCursor: () => {}; + + /* + * Not documented as property. + */ + public zoom: Zoom; + + static use: (modules: any[]) => void; + } + + /** + * Virtual Slides module (virtual as) + */ + class Virtual { + [x: string]: any; + } + + /** + * Keyboard Control module (keyboard as) + */ + class Keyboard { + [x: string]: any; + } + + /** + * Mousewheel Control module (mousewheel as) + */ + class Mousewheel { + [x: string]: any; + } + + /** + * Navigation module (navigation as) + */ + class Navigation { + [x: string]: any; + } + + /** + * Pagination module (pagination as) + */ + class Pagination { + [x: string]: any; + } + + /** + * Scrollbar module (scrollbar as) + */ + class Scrollbar { + [x: string]: any; + } + + /** + * Parallax module (parallax as) + */ + class Parallax { + [x: string]: any; + } + + /** + * Zoom module (zoom as) + */ + class Zoom { + [x: string]: any; + } + + /** + * Lazy module (lazy as) + */ + class Lazy { + [x: string]: any; + } + + /** + * Controller module (controller as) + */ + class Controller { + [x: string]: any; + } + + /** + * Accessibility module (a11y$) + */ + class A11y { + [x: string]: any; + } + + /** + * History Navigation module (history as) + */ + class History { + [x: string]: any; + } + + /** + * Hash Navigation module (hashNavigation as) + */ + class HashNavigation { + [x: string]: any; + } + + /** + * Autoplay module (autoplay as) + */ + class Autoplay { + [x: string]: any; + } + + /** + * Fade Effect module (effectFade as) + */ + class EffectFade { + [x: string]: any; + } + + /** + * Cube Effect module (effectCube as) + */ + class EffectCube { + [x: string]: any; + } + + /** + * Flip Effect module (effectFlip as) + */ + class EffectFlip { + [x: string]: any; + } + + /** + * Coverflow Effect module (effectCoverflow as) + */ + class EffectCoverflow { + [x: string]: any; + } + + /* + * Swiper options and events. + */ + + /** + * All the Swiper events. + */ + interface SwiperEvents { + + /** + * Fired right after Swiper initialization. + * Note that with swiper.on('init') syntax it will + * work only in case you set init: false parameter. + * + * @example + * var swiper = new Swiper('.swiper-container', { + * init: false, + * // other parameters + * }); + * + * @example + * swiper.on('init', function() { + * // do something + * }); + * + * @example + * // init Swiper + * swiper.init(); + * + * @example + * // Otherwise use it as the parameter: + * var swiper = new Swiper('.swiper-container', { + * // other parameters + * on: { + * init: function () { + * // do something + * }, + * } + * }); + */ + init: () => {}; + + /** + * Event will be fired right beforey Swiper destoryed + */ + beforeDestroy: () => {}; + + /** + * Event will be fired when currently active slide is changed + */ + slideChange: () => {}; + + /** + * Event will be fired in the beginning of animation to other slide (next or previous). + */ + slideChangeTransitionStart: () => {}; + + /** + * Event will be fired after animation to other slide (next or previous). + */ + slideChangeTransitionEnd: () => {}; + + /** + * Same as "slideChangeTransitionStart" but for "forward" direction only + */ + slideNextTransitionStart: () => {}; + + /** + * Same as "slideChangeTransitionEnd" but for "forward" direction only + */ + slideNextTransitionEnd: () => {}; + + /** + * Same as "slideChangeTransitionStart" but for "backward" direction only + */ + slidePrevTransitionStart: () => {}; + + /** + * Same as "slideChangeTransitionEnd" but for "backward" direction only + */ + slidePrevTransitionEnd: () => {}; + + /** + * Event will be fired in the beginning of transition. + */ + transitionStart: () => {}; + + /** + * Event will be fired after transition. + */ + transitionEnd: () => {}; + + /** + * Event will be fired when user touch Swiper. Receives 'touchstart' event as an arguments. + */ + touchStart: (event: any) => {}; + + /** + * Event will be fired when user touch and move finger over Swiper. Receives 'touchmove' event as an arguments. + */ + touchMove: (event: any) => {}; + + /** + * Fired when user touch and move finger over + * Swiper in direction opposite to direction parameter. + * Receives 'touchmove' event as an arguments. + */ + touchMoveOpposite: (event: any) => {}; + + /** + * Event will be fired when user touch and move finger over Swiper and move it. Receives 'touchmove' event as an arguments. + */ + sliderMove: (event: any) => {}; + + /** + * Event will be fired when user release Swiper. Receives 'touchend' event as an arguments. + */ + touchEnd: (event: any) => {}; + + /** + * Event will be fired when user click/tap on Swiper after 300ms delay. Receives 'touchend' event as an arguments. + */ + click: (event: any) => {}; + + /** + * Event will be fired when user click/tap on Swiper. Receives 'touchend' event as an arguments. + */ + tap: (event: any) => {}; + + /** + * Event will be fired when user double tap on Swiper's container. Receives 'touchend' event as an arguments + */ + doubleTap: (event: any) => {}; + + /** + * Event will be fired right after all inner images are loaded. updateOnImagesReady should be also enabled + */ + imagesReady: () => {}; + + /** + * Event will be fired when Swiper progress is changed, as an arguments it receives progress that is always from 0 to 1 + */ + progress: (progress: any) => {}; + + /** + * Event will be fired when Swiper reach its beginning (initial position) + */ + reachBeginning: () => {}; + + /** + * Event will be fired when Swiper reach last slide + */ + reachEnd: () => {}; + + /** + * Event will be fired when Swiper goes from beginning or end position + */ + fromEdge: () => {}; + + /** + * Event will be fired when swiper's wrapper change its position. Receives current translate value as an arguments + */ + setTranslate: (translate: any) => {}; + + + /** + * Event will be fired everytime when swiper starts animation. Receives current transition duration (in ms) as an arguments, + */ + setTransition: (transition: any) => {}; + + /** + * Event will be fired on window resize right before swiper's onresize manipulation + */ + resize: () => {}; + } + + /* + * Options + */ + + interface SwiperOptions { + + init?: boolean; + initialSlide?: number; + direction?: string; + speed?: number; + setWrapperSize?: boolean; + virtualTranslate?: boolean; + width?: number; + height?: number; + autoHeight?: boolean; + roundLengths?: boolean; + nested?: boolean; + uniqueNavElements?: boolean; + effect?: string; + runCallbacksOnInit?: boolean; + watchOverflow?: boolean; + on?: EventsOptions; + + // Slides grid + spaceBetween?: number; + slidesPerView?: number | string; // 'auto' + slidesPerColumn?: number; + slidesPerColumnFill?: string; + slidesPerGroup?: number; + centeredSlides?: boolean; + slidesOffsetBefore?: number; + slidesOffsetAfter?: number; + normalizeSlideIndex?: boolean; + + // Grab Cursor + grabCursor?: boolean; + + // Touches + touchEventsTarget?: string; + touchRatio?: number; + touchAngle?: number; + simulateTouch?: boolean; + shortSwipes?: boolean; + longSwipes?: boolean; + longSwipesRatio?: number; + longSwipesMs?: number; + followFinger?: boolean; + allowTouchMove?: boolean; + threshold?: number; + touchMoveStopPropagation?: boolean; + iOSEdgeSwipeDetection?: boolean; + iOSEdgeSwipeThreshold?: number; + touchReleaseOnEdges?: boolean; + passiveListeners?: boolean; + + // Touch Resistance + resistance?: boolean; + resistanceRatio?: number; + + // Swiping / No swiping + allowSlidePrev?: boolean; + allowSlideNext?: boolean; + noSwiping?: boolean; + noSwipingClass?: string; + swipeHandler?: SelectableElement; + + // Clicks + preventClicks?: boolean; + preventClicksPropagation?: boolean; + slideToClickedSlide?: boolean; + + // Freemode + freeMode?: boolean; + freeModeMomentum?: boolean; + freeModeMomentumRatio?: number; + freeModeMomentumVelocityRatio?: number; + freeModeMomentumBounce?: boolean; + freeModeMomentumBounceRatio?: number; + freeModeMinimumVelocity?: number; + freeModeSticky?: boolean; + + // Progress + watchSlidesProgress?: boolean; + watchSlidesVisibility?: boolean; + + // Images + preloadImages?: boolean; + updateOnImagesReady?: boolean; + + // Loop + loop?: boolean; + loopAdditionalSlides?: number; + loopedSlides?: number; + loopFillGroupWithBlank?: boolean; + + // Breakpoints + breakpoints?: object; + + // Observer + observer?: boolean; + observeParents?: boolean; + + // Namespace + containerModifierClass?: string; + slideClass?: string; + slideActiveClass?: string; + slideDuplicatedActiveClass?: string; + slideVisibleClass?: string; + slideDuplicateClass?: string; + slideNextClass?: string; + slideDuplicatedNextClass?: string; + slidePrevClass?: string; + slideDuplicatedPrevClass?: string; + wrapperClass?: string; + + // Components + navigation?: NavigationOptions; + pagination?: PaginationOptions; + scrollbar?: ScrollbarOptions; + autoplay?: AutoplayOptions | boolean; + parallax?: boolean; + lazy?: LazyOptions | boolean; + fadeEffect?: EffectFadeOptions; + coverflowEffect?: EffectCoverflowOptions; + flipEffect?: EffectFlipOptions; + cubeEffect?: EffectCubeOptions; + zoom?: ZoomOptions | boolean; + keyboard?: KeyboardOptions | boolean; + mousewheel?: MousewheelOptions | boolean; + virtual?: VirtualOptions | boolean; + hashNavigation?: HashNavigationOptions | boolean; + history?: HistoryNavigationOptions | boolean; + a11y?: A11yOptions | boolean; + } + + interface EventsOptions { + init: () => {}; + beforeDestroy: () => {}; + slideChange: () => {}; + slideChangeTransitionStart: () => {}; + slideChangeTransitionEnd: () => {}; + slideNextTransitionStart: () => {}; + slideNextTransitionEnd: () => {}; + slidePrevTransitionStart: () => {}; + slidePrevTransitionEnd: () => {}; + transitionStart: () => {}; + transitionEnd: () => {}; + touchStart: (event: any) => {}; + touchMove: (event: any) => {}; + touchMoveOpposite: (event: any) => {}; + sliderMove: (event: any) => {}; + touchEnd: (event: any) => {}; + click: (event: any) => {}; + tap: (event: any) => {}; + doubleTap: (event: any) => {}; + imagesReady: () => {}; + progress: (progress: any) => {}; + reachBeginning: () => {}; + reachEnd: () => {}; + fromEdge: () => {}; + setTranslate: (translate: any) => {}; + setTransition: (transition: any) => {}; + resize: () => {}; + } + + interface NavigationOptions { + + /** + * String with CSS selector or HTML element of the element that will work like "next" button after click on it + * + * @default null + */ + nextEl?: SelectableElement; + + /** + * String with CSS selector or HTML element of the element that will work like "prev" button after click on it + * + * @default null + */ + prevEl?: SelectableElement; + + /** + * buttons visibility after click on Slider's container + * + * @default false Toggle navigation + */ + hideOnClick?: boolean; + + /** + * CSS class name added to navigation button when it becomes disabled + * + * @default 'swiper-button-disabled' + */ + disabledClass?: string; + + /** + * CSS class name added to navigation button when it becomes hidden + * + * @default 'swiper-button-hidden' + */ + hiddenClass?: string; + + } + + interface OptionsWithElement { + el: SelectableElement; + } + + interface PaginationOptions extends OptionsWithElement { + type?: string; + bulletElement?: string; + dynamicBullets?: boolean; + hideOnClick?: boolean; + clickable?: boolean; + renderBullet?: (index: any, className: any) => {}; + renderFraction?: (currentClass: any, totalClass: any) => {}; + renderProgressbar?: (progressbarFillClass: any) => {}; + renderCustom?: (swiper: any, current: any, total: any) => {}; + bulletClass?: string; + bulletActiveClass?: string; + modifierClass?: string; + currentClass?: string; + totalClass?: string; + hiddenClass?: string; + progressbarFillClass?: string; + clickableClass?: string; + } + + interface ScrollbarOptions extends OptionsWithElement { + hide: boolean; + draggable: boolean; + snapOnRelease: boolean; + dragSize: string | number; + } + + interface AutoplayOptions { + + /** + * Delay between transitions (in ms). If this parameter is not specified, auto play will be disabled + * + * If you need to specify different delay for specifi slides you can do it by using data-swiper-autoplay (in ms) attribute on slide. + * + * @example + * + *
+ * stopOnLast: boolean // default: false Enable this parameter and autoplay will be stopped when it reaches last slide (has no effect in loop mode) + * + * @default 3000 + */ + delay?: number; + + /** + * Set to false and autoplay will not be disabled after + * user interactions (swipes), it will be restarted + * every time after interaction + * + * @default true + */ + disableOnInteraction?: boolean; + + /** + * Enables autoplay in reverse direction + * + * @default false + */ + reverseDirection?: boolean; + + /** + * When enabled autoplay will wait for wrapper transition to continue. Can be disabled in case of using Virtual Translate when your + * slider may not have transition + * + * @default true + */ + waitForTransition?: boolean; + + } + + interface LazyOptions { + loadPrevNext: boolean; + loadPrevNextAmount: number; + loadOnTransitionStart: boolean; + elementClass: string; + loadingClass: string; + loadedClass: string; + preloaderClass: string; + } + + /* + * Options - Effects + */ + + interface EffectFadeOptions { + crossfade: boolean; + } + + interface EffectCoverflowOptions { + slideShadows: boolean; + rotate: number; + stretch: number; + depth: number; + modifier: number; + } + + interface EffectFlipOptions { + slideShadows: boolean; + limitRotation: boolean; + } + + interface EffectCubeOptions { + slideShadows: boolean; + shadow: boolean; + shadowOffset: number; + shadowScale: number; + } + + interface ZoomOptions { + maxRatio?: number; + minRatio?: number; + toggle?: boolean; + containerClass?: string; + zoomedSlideClass?: string; + } + + interface KeyboardOptions { + enabled: boolean; + onlyInViewport: boolean; + } + + interface MousewheelOptions { + forceToAxis: boolean; + releaseOnEdges: boolean; + invert: boolean; + sensitivity: number; + eventsTarged: SelectableElement; + } + + interface VirtualOptions { + slides: any[]; + cache: boolean; + renderSlide: (slide: any, index: any) => {}; + renderExternal: (data: any) => {}; + } + + interface HashNavigationOptions { + watchState: boolean; + replaceState: boolean; + } + + interface HistoryNavigationOptions { + replaceState: boolean; + key: string; + } + + interface ControllerOptions { + control: Swiper; + inverse: boolean; + by: string; + } + + interface A11yOptions { + prevSlideMessage: string; + nextSlideMessage: string; + firstSlideMessage: string; + lastSlideMessage: string; + paginationBulletMessage: string; + notificationClass: string; + } } -interface SwiperScrollbarOptions { - container: string; // Default: '.swiper-scrollbar' - draggable?: boolean; // Default: true - hide?: boolean; // Default: true - snapOnRelease?: boolean; // Default: false +declare module 'swiper/dist/js/swiper.esm' { + import alias = require('swiper'); + export = alias; } -declare class SwiperSlide { - append(): SwiperSlide; - clone(): SwiperSlide; - getWidth(): number; - getHeight(): number; - getOffset(): { top: number; left: number; }; - insertAfter(index: number): SwiperSlide; - prepend(): SwiperSlide; - remove(): void; -} - -declare class Swiper { - constructor(container: string | Element, options?: SwiperOptions); - - // Properties - width: number; - height: number; - params: any; - positions: any; - wrapper: any; - virtualSize: number; - - // Feature detection - support: { - touch: boolean; - transforms: boolean; - transforms3d: boolean; - transitions: boolean; - }; - - // Browser detection - browser: { - ie8: boolean; - ie10: boolean; - }; - - // Navigation - activeIndex: number; - activeLoopIndex: number; - activeLoaderIndex: number; - previousIndex: number; - swipeNext(internal?: boolean): boolean; - swipePrev(internal?: boolean): boolean; - swipeReset(): boolean; - swipeTo(index: number, speed?: number, runCallbacks?: boolean): boolean; - activeSlide(): SwiperSlide; - updateActiveSlide(index: number): void; - - // Events - touches: any; - isTouched: boolean; - clickedSlideIndex: number; - clickedSlide: SwiperSlide; - wrapperTransitionEnd(callback: () => void, permanent: boolean): void; - - // Init/reset - destroy(deleteInstance: boolean, cleanupStyles: boolean): void; - reInit(forceCalcSlides?: boolean): void; - resizeFix(reInit?: boolean): void; - - // Autoplaying - autoplay: boolean; - startAutoplay(): void; - stopAutoplay(): void; - - // Other methods - getWrapperTranslate(axis: string): number; // 'x' or 'y' - setWrapperTranslate(x: number, y: number, z: number): void; - setWrapperTransition(duration: any): void; - - // Slides API - - slides: SwiperSlide[]; - - slidePrev(runCallbacks?: boolean, speed?: number): void; - slideNext(runCallbacks?: boolean, speed?: number): void; - slideTo(index: number, speed?: number, runCallbacks?: boolean): void; - update(updateTranslate?: boolean): void; - onResize(): void; - detachEvents(): void; - attachEvents(): void; - - appendSlide(slides: HTMLElement | string | string[]): void; - prependSlide(slides: HTMLElement | string | string[]): void; - removeSlide(slideIndex: number): void; - removeAllSlides(): void; - - lockSwipeToNext(): void; - unlockSwipeToNext(): void; - lockSwipeToPrev(): void; - unlockSwipeToPrev(): void; - lockSwipes(): void; - unlockSwipes(): void; - disableMousewheelControl(): void; - enableMousewheelControl(): void; - disableKeyboardControl(): void; - enableKeyboardControl(): void; - disableTouchControl(): void; - enableTouchControl(): void; - unsetGrabCursor(): void; - setGrabCursor(): void; - - plugins?: { - debugger?(swiper: any, params: any): void; - }; -} - -declare module "swiper" { - const swiper: { - new (element: Element | string, options?: SwiperOptions): Swiper; - }; - - export = swiper; +declare module 'swiper/dist/js/swiper.esm.js' { + import alias = require('swiper'); + export = alias; }