Skip to content

Commit 515a2fd

Browse files
Merge pull request #7 from dutchenkoOleg/master
Add TypeScript support
2 parents 00413ab + d69744a commit 515a2fd

File tree

4 files changed

+356
-107
lines changed

4 files changed

+356
-107
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/WezomAgency/web-plugin-abstract-slick-carousel/blob/master/LICENSE)
44
[![npm](https://img.shields.io/badge/npm-install-orange.svg)](https://www.npmjs.com/package/web-plugin-abstract-slick-carousel)
55
[![Javascript Style Guide](https://img.shields.io/badge/code_style-wezom_relax-red.svg)](https://github.com/WezomAgency/eslint-config-wezom-relax#readme)
6+
![types](https://img.shields.io/badge/types-TypeScript-blue)

index.d.ts

Lines changed: 352 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,352 @@
1+
// ----------------------------------------
2+
// Imports
3+
// ----------------------------------------
4+
5+
import $ from 'jquery';
6+
import 'jquery-inview';
7+
import { WebPluginInterface } from 'web-plugin-interface';
8+
9+
// ----------------------------------------
10+
// Public
11+
// ----------------------------------------
12+
13+
14+
15+
export interface JQuerySlickProps {
16+
pauseAutoplayInOutOfView: boolean;
17+
cssReadyClass: string;
18+
cssInitializedClass: string;
19+
$listSelector: string;
20+
$dotsSelector: string;
21+
$prevArrowSelector: string;
22+
$nextArrowSelector: string;
23+
}
24+
25+
export interface JQuerySlickOptions {
26+
/**
27+
* Enables tabbing and arrow key navigation
28+
* Default: true
29+
*/
30+
accessibility?: boolean;
31+
32+
/**
33+
* Enables adaptive height for single slide horizontal carousels.
34+
* Default: false
35+
*/
36+
adaptiveHeight?: boolean;
37+
38+
/**
39+
* Enables Autoplay
40+
* Default: false
41+
*/
42+
autoplay?: boolean;
43+
44+
/**
45+
* Autoplay Speed in milliseconds
46+
* Default: 3000
47+
*/
48+
autoplaySpeed?: number;
49+
50+
/**
51+
* Prev/Next Arrows
52+
* Default: true
53+
*/
54+
arrows?: boolean;
55+
56+
/**
57+
* Set the slider to be the navigation of other slider
58+
* Default: null
59+
*/
60+
asNavFor?: Element | JQuery | string;
61+
62+
/**
63+
* Change where the navigation arrows are attached (Selector, htmlString, Array, Element, jQuery object)
64+
* `false` will prevent arrows from being created/appended
65+
* Default: $(element)
66+
*/
67+
appendArrows?: Element | Element[] | JQuery | string | boolean;
68+
69+
/**
70+
* Change where the navigation dots are attached (Selector, htmlString, Array, Element, jQuery object)
71+
* Default: $(element)
72+
*/
73+
appendDots?: Element | Element[] | JQuery | string;
74+
75+
/**
76+
* Allows you to select a node or customize the HTML for the "Previous" arrow.
77+
* Default: <button type="button" class="slick-prev">Previous</button>
78+
*/
79+
prevArrow?: Element | JQuery | string;
80+
81+
/**
82+
* Allows you to select a node or customize the HTML for the "Next" arrow.
83+
* Default: <button type="button" class="slick-next">Next</button>
84+
*/
85+
nextArrow?: Element | JQuery | string;
86+
87+
/**
88+
* Enables centered view with partial prev/next slides. Use with odd numbered slidesToShow counts.
89+
* Default: false
90+
*/
91+
centerMode?: boolean;
92+
93+
/**
94+
* Side padding when in center mode (px or %)
95+
* Default: '50px'
96+
*/
97+
centerPadding?: string;
98+
99+
/**
100+
* CSS3 Animation Easing
101+
* Default: 'ease'
102+
*/
103+
cssEase?: string;
104+
105+
/**
106+
* Custom paging templates. See source for use example.
107+
* Default: n/a
108+
*/
109+
customPaging?: (slider: any, i: number) => string;
110+
111+
/**
112+
* Show dot indicators
113+
* Default: false
114+
*/
115+
dots?: boolean;
116+
117+
/**
118+
* Class for slide indicator dots container
119+
* Default: 'slick-dots'
120+
*/
121+
dotsClass?: string;
122+
123+
/**
124+
* Enable mouse dragging
125+
* Default: true
126+
*/
127+
draggable?: boolean;
128+
129+
/**
130+
* Enable fade
131+
* Default: false
132+
*/
133+
fade?: boolean;
134+
135+
/**
136+
* Puts focus on slide after change
137+
* Default: false
138+
*/
139+
focusOnChange?: boolean;
140+
141+
/**
142+
* Enable focus on selected element (click)
143+
* Default: false
144+
*/
145+
focusOnSelect?: boolean;
146+
147+
/**
148+
* Add easing for jQuery animate. Use with easing libraries or default easing methods
149+
* Default: 'linear'
150+
*/
151+
easing?: string;
152+
153+
/**
154+
* Resistance when swiping edges of non-infinite carousels
155+
* Default: 0.15
156+
*/
157+
edgeFriction?: number;
158+
159+
/**
160+
* Infinite loop sliding
161+
* Default: true
162+
*/
163+
infinite?: boolean;
164+
165+
/**
166+
* Slide to start on
167+
* Default: 0
168+
*/
169+
initialSlide?: number;
170+
171+
/**
172+
* Set lazy loading technique. Accepts 'ondemand' or 'progressive'.
173+
* Default: 'ondemand'
174+
*/
175+
lazyLoad?: string;
176+
177+
/**
178+
* Responsive settings use mobile first calculation
179+
* Default: false
180+
*/
181+
mobileFirst?: boolean;
182+
183+
/**
184+
* Pause Autoplay On Focus
185+
* Default: true
186+
*/
187+
pauseOnFocus?: boolean;
188+
189+
/**
190+
* Pause Autoplay On Hover
191+
* Default: true
192+
*/
193+
pauseOnHover?: boolean;
194+
195+
/**
196+
* Pause Autoplay when a dot is hovered
197+
* Default: false
198+
*/
199+
pauseOnDotsHover?: boolean;
200+
201+
/**
202+
* Width that responsive object responds to. Can be 'window', 'slider' or 'min' (the smaller of the two)
203+
* Default: 'window'
204+
*/
205+
respondTo?: string;
206+
207+
/**
208+
* Object containing breakpoints and settings objects (see demo).
209+
* Enables settings sets at given screen width.
210+
* Set settings to "unslick" instead of an object to disable slick at a given breakpoint.
211+
* Default: none
212+
*/
213+
responsive?: Object;
214+
215+
/**
216+
* Setting this to more than 1 initializes grid mode. Use slidesPerRow to set how many slides should be in each row.
217+
* Default: 1
218+
*/
219+
rows?: number;
220+
221+
/**
222+
* Element query to use as slide
223+
* Default: 'div'
224+
*/
225+
slide?: string;
226+
227+
/**
228+
* With grid mode intialized via the rows option, this sets how many slides are in each grid row.
229+
* Default: 1
230+
*/
231+
slidesPerRow?: number;
232+
233+
/**
234+
* # of slides to show
235+
* Default: 1
236+
*/
237+
slidesToShow?: number;
238+
239+
/**
240+
* # of slides to scroll
241+
* Default: 1
242+
*/
243+
slidesToScroll?: number;
244+
245+
/**
246+
* Slide/Fade animation speed (ms)
247+
* Default: 300
248+
*/
249+
speed?: number;
250+
251+
/**
252+
* Enable swiping
253+
* Default: true
254+
*/
255+
swipe?: boolean;
256+
257+
/**
258+
* Allow users to drag or swipe directly to a slide irrespective of slidesToScroll.
259+
* Default: false
260+
*/
261+
swipeToSlide?: boolean;
262+
263+
/**
264+
* Enable slide motion with touch
265+
* Default: true
266+
*/
267+
touchMove?: boolean;
268+
269+
/**
270+
* To advance slides, the user must swipe a length of (1/touchThreshold) * the width of the slider.
271+
* Default: 5
272+
*/
273+
touchThreshold?: number;
274+
275+
/**
276+
* Enable/Disable CSS Transitions
277+
* Default: true
278+
*/
279+
useCSS?: boolean;
280+
281+
/**
282+
* Enable/Disable CSS Transforms
283+
* Default: true
284+
*/
285+
useTransform?: boolean;
286+
287+
/**
288+
* Variable width slides.
289+
* Default: false
290+
*/
291+
variableWidth?: boolean;
292+
293+
/**
294+
* Vertical slide mode
295+
* Default: false
296+
*/
297+
vertical?: boolean;
298+
299+
/**
300+
* Vertical swipe mode
301+
* Default: false
302+
*/
303+
verticalSwiping?: boolean;
304+
305+
/**
306+
* Change the slider's direction to become right-to-left
307+
* Default: false
308+
*/
309+
rtl?: boolean;
310+
311+
/**
312+
* Change the slider's direction to become right-to-left
313+
* Default: false
314+
*/
315+
waitForAnimate?: boolean;
316+
317+
/**
318+
* Set the zIndex values for slides, useful for IE9 and lower
319+
* Default: 1000
320+
*/
321+
zIndex?: number;
322+
}
323+
324+
export class AbstractSlickCarousel extends WebPluginInterface {
325+
$container: JQuery;
326+
props: Partial<JQuerySlickProps>;
327+
settings: Partial<JQuerySlickOptions>;
328+
$list: JQuery;
329+
$dots: JQuery;
330+
$prevArrow: JQuery;
331+
$nextArrow: JQuery;
332+
$arrows: JQuery;
333+
isInitialized: boolean;
334+
firstInitialize: boolean;
335+
336+
constructor(
337+
$container: JQuery,
338+
clientSettings: Partial<JQuerySlickOptions> = {},
339+
clientProps: Partial<JQuerySlickProps> = {}
340+
);
341+
get defaultProps(): Partial<JQuerySlickProps>;
342+
get defaultSettings(): Partial<JQuerySlickOptions>;
343+
protected _setup(): void;
344+
protected _beforeInitialize(): void;
345+
protected _afterInitialize(): void;
346+
protected _initialize(): void;
347+
public initialize(): void;
348+
// extend interface
349+
protected _autoplayInViewObserver(): void
350+
public destroy(): void
351+
public update(): void
352+
}

0 commit comments

Comments
 (0)