mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
switched format to module-class.d.ts
https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-class-d-ts.html
This commit is contained in:
Vendored
+471
-85
@@ -17,99 +17,448 @@ export as namespace swiperLib;
|
||||
*/
|
||||
export = Swiper;
|
||||
|
||||
type SelectableElement = string | HTMLElement;
|
||||
|
||||
/*~ Write your module's methods and properties in this class */
|
||||
// @NOTE this is the 3.4.7 class version.
|
||||
// @TODO update this class to the 4.1.0 version.
|
||||
declare class Swiper {
|
||||
|
||||
constructor(container: string | HTMLElement, options?: Options);
|
||||
constructor(container: SelectableElement, options?: Options);
|
||||
|
||||
// Properties
|
||||
width: number;
|
||||
height: number;
|
||||
params: any;
|
||||
positions: any;
|
||||
/**
|
||||
* Object with passed initialization parameters
|
||||
*/
|
||||
params: SwiperOptions;
|
||||
|
||||
// Feature detection
|
||||
support: {
|
||||
touch: boolean;
|
||||
transforms: boolean;
|
||||
transforms3d: boolean;
|
||||
transitions: boolean;
|
||||
/**
|
||||
* Element with slider container.
|
||||
*/
|
||||
el: HTMLElement;
|
||||
|
||||
/**
|
||||
* Dom7 element with slider container HTML element. To get vanilla HTMLElement use el
|
||||
*/
|
||||
$el: DOM7Element;
|
||||
|
||||
/**
|
||||
* Slider wrapper HTML element.
|
||||
*/
|
||||
wrapperEl: HTMLElement;
|
||||
|
||||
/**
|
||||
* Dom7 element with slider wrapper HTML element. To get vanilla HTMLElement use wrapperEl
|
||||
*/
|
||||
$wrapperEl: DOM7Element;
|
||||
|
||||
/**
|
||||
* Dom7 array-like collection of slides HTML elements. To get specific slide HTMLElement use slides[1]
|
||||
*/
|
||||
slides: DOM7Element[];
|
||||
|
||||
/**
|
||||
* Width of container
|
||||
*/
|
||||
width;
|
||||
|
||||
/**
|
||||
* Height of container
|
||||
*/
|
||||
height;
|
||||
|
||||
/**
|
||||
* Current value of wrapper translate
|
||||
*/
|
||||
translate;
|
||||
|
||||
/**
|
||||
* Current progress of wrapper translate (from 0 to 1)
|
||||
*/
|
||||
progress;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Index number of currently active slide considering duplicated slides in loop mode
|
||||
*/
|
||||
realIndex;
|
||||
|
||||
/**
|
||||
* Index number of previously active slide
|
||||
*/
|
||||
previousIndex;
|
||||
|
||||
/**
|
||||
* true if slider on most "left"/"top" position
|
||||
*/
|
||||
isBeginning;
|
||||
|
||||
/**
|
||||
* true if slider on most "right"/"bottom" position
|
||||
*/
|
||||
isEnd;
|
||||
|
||||
/**
|
||||
* true if swiper is in transition
|
||||
*/
|
||||
animating;
|
||||
|
||||
/**
|
||||
* Object with the following touch event properties:
|
||||
*/
|
||||
touches: {
|
||||
startX,
|
||||
startY,
|
||||
currentX,
|
||||
currentY,
|
||||
diff
|
||||
};
|
||||
|
||||
// Browser detection
|
||||
browser: {
|
||||
ie8: boolean;
|
||||
ie10: boolean;
|
||||
};
|
||||
/**
|
||||
* Index number of last clicked slide
|
||||
*/
|
||||
clickedIndex;
|
||||
|
||||
// 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(): Slide;
|
||||
updateActiveSlide(index: number): void;
|
||||
/**
|
||||
* Link to last clicked slide (HTMLElement)
|
||||
*/
|
||||
clickedSlide;
|
||||
|
||||
// Events
|
||||
touches: any;
|
||||
isTouched: boolean;
|
||||
clickedSlideIndex: number;
|
||||
clickedSlide: Slide;
|
||||
wrapperTransitionEnd(callback: () => void, permanent: boolean): void;
|
||||
/**
|
||||
* Disable / enable ability to slide to the next slides by assigning false/true to this property
|
||||
*/
|
||||
allowSlideNext;
|
||||
|
||||
// Init/reset
|
||||
destroy(removeResizeEvent?: boolean): void;
|
||||
reInit(forceCalcSlides?: boolean): void;
|
||||
resizeFix(reInit?: boolean): void;
|
||||
/**
|
||||
* Disable / enable ability to slide to the previous slides by assigning false/true to this property
|
||||
*/
|
||||
allowSlidePrev;
|
||||
|
||||
// Autoplaying
|
||||
autoplay: boolean;
|
||||
startAutoplay(): void;
|
||||
stopAutoplay(): void;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
// Other methods
|
||||
getWrapperTranslate(axis: string): number; // 'x' or 'y'
|
||||
setWrapperTranslate(x: number, y: number, z: number): void;
|
||||
setWrapperTransition(duration: any): void;
|
||||
// Methods
|
||||
|
||||
// Slides API
|
||||
slides: Slide[];
|
||||
createSlide(html: string, slideClassList?: string, element?: string): Slide;
|
||||
appendSlide(html: string, slideClassList?: string, element?: string): Slide;
|
||||
appendSlide(slideInstance: HTMLElement): Slide;
|
||||
prependSlide(html: string, slideClassList?: string, element?: string): Slide;
|
||||
prependSlide(slideInstance: HTMLElement): Slide;
|
||||
insertSlideAfter(index: number, html: string, slideClassList?: string, element?: string): Slide;
|
||||
insertSlideAfter(index: number, slideInstance: HTMLElement): Slide;
|
||||
removeSlide(index: number): boolean;
|
||||
removeLastSlide(): boolean;
|
||||
removeAllSlides(): void;
|
||||
getSlide(index: number): Slide;
|
||||
getLastSlide(): Slide;
|
||||
getFirstSlide(): Slide;
|
||||
/**
|
||||
* 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('<div class="swiper-slide">Slide 10"</div>')
|
||||
* @example appendSlide(['<div class="swiper-slide">Slide 10"</div>', '<div class="swiper-slide">Slide 11"</div>']);
|
||||
*/
|
||||
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('<div class="swiper-slide">Slide 0"</div>')
|
||||
* @example prependSlide(['<div class="swiper-slide">Slide 1"</div>', '<div class="swiper-slide">Slide 2"</div>']);
|
||||
*/
|
||||
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);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
off: (event: any, handler: any) => {};
|
||||
|
||||
/**
|
||||
* Remove all listeners for specified event
|
||||
*/
|
||||
off: (event: 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: () => {};
|
||||
}
|
||||
|
||||
|
||||
namespace Swiper {
|
||||
|
||||
// @NOTE take a look on this one after
|
||||
declare class Slide {
|
||||
append(): Slide;
|
||||
clone(): Slide;
|
||||
getWidth(): number;
|
||||
getHeight(): number;
|
||||
getOffset(): { top: number; left: number; };
|
||||
insertAfter(index: number): Slide;
|
||||
prepend(): Slide;
|
||||
remove(): void;
|
||||
export interface SwiperEvents {
|
||||
|
||||
/**
|
||||
* Event will be 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) => {};
|
||||
|
||||
/**
|
||||
* Event will be 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: () => {};
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
export interface SwiperOptions {
|
||||
|
||||
init?: boolean;
|
||||
initialSlide?: number;
|
||||
@@ -169,7 +518,7 @@ namespace Swiper {
|
||||
allowSlideNext?: boolean;
|
||||
noSwiping?: boolean;
|
||||
noSwipingClass?: string;
|
||||
swipeHandler?: string | HTMLElement,
|
||||
swipeHandler?: SelectableElement;
|
||||
|
||||
// Clicks
|
||||
preventClicks?: boolean;
|
||||
@@ -270,15 +619,46 @@ namespace Swiper {
|
||||
}
|
||||
|
||||
interface NavigationOptions {
|
||||
nextEl: string | HTMLElement // default: null String with CSS selector or HTML element of the element that will work like "next" button after click on it
|
||||
prevEl: string | HTMLElement // default: null String with CSS selector or HTML element of the element that will work like "prev" button after click on it
|
||||
hideOnClick: boolean // default: false Toggle navigation buttons visibility after click on Slider's container
|
||||
disabledClass: string // default: 'swiper-button-disabled' CSS class name added to navigation button when it becomes disabled
|
||||
hiddenClass: string // default: 'swiper-button-hidden' CSS class name added to navigation button when it becomes hidden
|
||||
|
||||
/**
|
||||
* 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: string | HTMLElement;
|
||||
el: SelectableElement;
|
||||
}
|
||||
|
||||
interface PaginationOptions extends OptionsWithElement {
|
||||
@@ -309,11 +689,13 @@ namespace Swiper {
|
||||
}
|
||||
|
||||
interface AutoplayOptions extends OptionsWithElement {
|
||||
|
||||
/**
|
||||
* 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:
|
||||
* 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
|
||||
* <!-- hold this slide for 2 seconds -->
|
||||
* <div class="swiper-slide" data-swiper-autoplay="2000">
|
||||
* stopOnLast: boolean // default: false Enable this parameter and autoplay will be stopped when it reaches last slide (has no effect in loop mode)
|
||||
@@ -321,18 +703,21 @@ namespace Swiper {
|
||||
* @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
|
||||
* 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
|
||||
* 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
|
||||
@@ -340,6 +725,7 @@ namespace Swiper {
|
||||
* @default true
|
||||
*/
|
||||
waitForTransition: boolean;
|
||||
|
||||
}
|
||||
|
||||
interface LazyOptions {
|
||||
@@ -396,7 +782,7 @@ namespace Swiper {
|
||||
releaseOnEdges: boolean;
|
||||
invert: boolean;
|
||||
sensitivity: number;
|
||||
eventsTarged: string | HTMLElement;
|
||||
eventsTarged: SelectableElement;
|
||||
}
|
||||
|
||||
interface VirtualOptions {
|
||||
|
||||
Reference in New Issue
Block a user