Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c2be790

Browse files
add types
1 parent 7e32a39 commit c2be790

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/hilongjw/vue-lazyload.git"
1717
},
18+
"typings": "types/index.d.ts",
1819
"keywords": [
1920
"vue-lazyload",
2021
"vue",
@@ -62,6 +63,6 @@
6263
"rollup-plugin-node-resolve": "^3.2.0",
6364
"rollup-plugin-replace": "^2.0.0",
6465
"rollup-plugin-uglify": "^1.0.1",
65-
"vue": "^2.5.13"
66+
"vue": "^2.5.16"
6667
}
6768
}

‎types/index.d.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import "./vue";
2+
import { VueLazyLoad } from "./lazyload";
3+
4+
export default VueLazyLoad;
5+
6+
export {
7+
LazyloadImage,
8+
LazyOptions,
9+
LazyloadHandler,
10+
} from "./lazyload";

‎types/lazyload.d.ts‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import Vue, { PluginObject } from "vue";
2+
3+
interface IntersectionObserverInit {
4+
root?: Element | null;
5+
rootMargin?: string;
6+
threshold?: number | number[];
7+
}
8+
9+
export interface LazyloadImage {
10+
src: string;
11+
error: string;
12+
loading: string;
13+
}
14+
15+
export interface LazyOptions {
16+
lazyComponent?: boolean;
17+
preLoad?: number;
18+
error?: string;
19+
loading?: string;
20+
attempt?: number;
21+
listenEvents?: string[];
22+
adapter?: any;
23+
filter?: any;
24+
dispatchEvent?: boolean;
25+
throttleWait?: number;
26+
observer?: boolean;
27+
observerOptions?: IntersectionObserverInit;
28+
silent?: boolean;
29+
preLoadTop?: number;
30+
scale?: number;
31+
hasbind?: boolean;
32+
}
33+
34+
export interface ReactiveListener {
35+
el: Element;
36+
src: string;
37+
error: string;
38+
loading: string;
39+
bindType: string;
40+
attempt: number;
41+
naturalHeight: number;
42+
naturalWidth: number;
43+
options: LazyOptions;
44+
rect: DOMRect;
45+
$parent: Element
46+
elRenderer: Function;
47+
performanceData: {
48+
init: number,
49+
loadStart: number,
50+
loadEnd: number
51+
};
52+
}
53+
54+
export interface LazyloadHandler {
55+
$on (event: string, callback: Function): void;
56+
$once (event: string, callback: Function): void;
57+
$off (event: string, callback?: Function): void;
58+
lazyLoadHandler (): void;
59+
}
60+
61+
export interface VueLazyLoad extends PluginObject<LazyOptions> {}

‎types/vue.d.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Augment the typings of Vue.js
3+
*/
4+
5+
import Vue from "vue";
6+
import { LazyloadHandler } from "./index";
7+
8+
declare module "vue/types/vue" {
9+
interface Vue {
10+
$Lazyload: LazyloadHandler;
11+
}
12+
}
13+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /