Skip to content

Commit f9aec20

Browse files
committed
Add TypeScript declaration file
1 parent e9fcbd6 commit f9aec20

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
"version": "2.2.3",
44
"description": "An infinite scroll plugin for Vue.js",
55
"main": "dist/vue-infinite-loading.js",
6+
"typings": "types/index.d.ts",
67
"files": [
78
"dist/vue-infinite-loading.js",
9+
"types/*.d.ts",
810
"src"
911
],
1012
"author": {

types/index.d.ts

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Type definitions for vue-infinite-loading v2.3.0
2+
// Project: https://github.com/PeachScript/vue-infinite-loading
3+
// Definitions by: Phil Scott <https://github.com/enkafan>
4+
// PeachScript <https://github.com/PeachScript>
5+
6+
import Vue, { VNode } from 'vue';
7+
8+
declare namespace InfiniteLoading {
9+
type SpinnerType = 'default' | 'bubbles' | 'circles' | 'spiral' | 'waveDots';
10+
11+
type DirectionType = 'top' | 'bottom';
12+
13+
interface Slots {
14+
spinner: VNode[];
15+
'no-result': VNode[];
16+
'no-more': VNode[];
17+
[key: string]: VNode[];
18+
}
19+
20+
interface StateChanger {
21+
loaded(): void;
22+
complete(): void;
23+
reset(): void;
24+
}
25+
}
26+
27+
declare class InfiniteLoading extends Vue {
28+
// The trigger distance
29+
distance: number;
30+
31+
// The load spinner type
32+
spinner: InfiniteLoading.SpinnerType;
33+
34+
// The scroll direction
35+
direction: InfiniteLoading.DirectionType;
36+
37+
// Whether find the element which has `infinite-wrapper` attribute as the scroll wrapper
38+
forceUseInfiniteWrapper: boolean;
39+
40+
// Infinite event handler
41+
onInfinite: ($state: InfiniteLoading.StateChanger) => void;
42+
43+
// The method collection used to change infinite state
44+
stateChanger: InfiniteLoading.StateChanger;
45+
46+
// Slots
47+
$slots: InfiniteLoading.Slots;
48+
}
49+
50+
export = InfiniteLoading;

0 commit comments

Comments
 (0)