Add typings for OwlCarousel2 library

This commit is contained in:
Ismael Gorissen 2017-08-23 10:01:48 +02:00
parent a77d0ea37f
commit 41a9cb0c8d
4 changed files with 159 additions and 0 deletions

130
types/owl.carousel/index.d.ts vendored Normal file
View File

@ -0,0 +1,130 @@
// Type definitions for owl.carousel 2.2
// Project: https://github.com/OwlCarousel2/OwlCarousel2
// Definitions by: Ismael Gorissen <https://github.com/igorissen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery"/>
declare namespace OwlCarousel {
interface Options {
// OPTIONS
items?: number;
margin?: number;
loop?: boolean;
center?: boolean;
mouseDrag?: boolean;
touchDrag?: boolean;
pullDrag?: boolean;
freeDrag?: boolean;
stagePadding?: number;
merge?: boolean;
mergeFit?: boolean;
autoWidth?: boolean;
startPosition?: number | string;
URLhashListener?: boolean;
nav?: boolean;
rewind?: boolean;
navText?: string[];
navElement?: string;
slideBy?: number | string;
dots?: boolean;
dotsEach?: number | boolean;
dotData?: boolean;
lazyLoad?: boolean;
lazyContent?: boolean;
autoplay?: boolean;
autoplayTimeout?: number;
autoplayHoverPause?: boolean;
smartSpeed?: boolean;
fluidSpeed?: boolean;
autoplaySpeed?: number | boolean;
navSpeed?: number | boolean;
dotsSpeed?: number | boolean;
dragEndSpeed?: number | boolean;
callbacks?: boolean;
responsive?: { [breakpoint: string]: Options };
responsiveRefreshRate?: number;
responsiveBaseElement?: Element;
video?: boolean;
videoHeight?: number | boolean;
videoWidth?: number | boolean;
animateOut?: string | boolean;
animateIn?: string | boolean;
fallbackEasing?: string;
info?: Function;
nestedItemSelector?: string;
itemElement?: string;
stageElement?: string;
navContainer?: string | boolean;
dotsContainer?: string | boolean;
// CLASSES
refreshClass?: string;
loadingClass?: string;
loadedClass?: string;
rtlClass?: string;
dragClass?: string;
grabClass?: string;
stageClass?: string;
stageOuterClass?: string;
navContainerClass?: string;
navClass?: string[];
controlsClass?: string;
dotClass?: string;
dotsClass?: string;
autoHeightClass?: string;
responsiveClass?: string | boolean;
// EVENTS
onInitialize?: Function;
onInitialized?: Function;
onResize?: Function;
onResized?: Function;
onRefresh?: Function;
onRefreshed?: Function;
onDrag?: Function;
onDragged?: Function;
onTranslate?: Function;
onTranslated?: Function;
onChange?: Function;
onChanged?: Function;
onLoadLazy?: Function;
onLoadedLazy?: Function;
onStopVideo?: Function;
onPlayVideo?: Function;
}
type OnEvent = 'initialize.owl.carousel'
| 'initialized.owl.carousel'
| 'resize.owl.carousel'
| 'resized.owl.carousel'
| 'refresh.owl.carousel'
| 'refreshed.owl.carousel'
| 'drag.owl.carousel'
| 'dragged.owl.carousel'
| 'translate.owl.carousel'
| 'translated.owl.carousel'
| 'change.owl.carousel'
| 'changed.owl.carousel'
| 'load.owl.lazy'
| 'loaded.owl.lazy'
| 'stop.owl.video'
| 'play.owl.video';
type TriggerEvent = 'refresh.owl.carousel'
| 'next.owl.carousel'
| 'prev.owl.carousel'
| 'to.owl.carousel'
| 'destroy.owl.carousel'
| 'replace.owl.carousel'
| 'add.owl.carousel'
| 'remove.owl.carousel'
| 'play.owl.autoplay'
| 'stop.owl.autoplay';
}
interface JQuery {
owlCarousel(options?: OwlCarousel.Options | 'destroy'): JQuery;
on(event: OwlCarousel.OnEvent, handler: (...args: any[]) => void): JQuery;
trigger(event: OwlCarousel.TriggerEvent): JQuery;
}

View File

@ -0,0 +1,5 @@
$('#first').owlCarousel();
$('#second').owlCarousel({});
$('#third').owlCarousel('destroy');

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"owl.carousel-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }